Skip to content

Commit 9d8c74d

Browse files
d4l3kfacebook-github-bot
authored andcommitted
docs/schedulers: add runopts to documentation (#374)
Summary: This adds the runopts to the documentation for the schedulers. It uses a sphinx plugin to load the scheduler and generate the CLI help text which it places in a code block. Pull Request resolved: #374 Test Plan: ``` make clean html ``` ![Screenshot 2022-01-25 at 14-57-50 Slurm — PyTorch TorchX main documentation](https://user-images.githubusercontent.com/909104/151073867-f03ceffc-a4cf-44e4-96f6-2138f741b6de.png) ![Screenshot 2022-01-25 at 14-57-43 Kubernetes — PyTorch TorchX main documentation](https://user-images.githubusercontent.com/909104/151073869-f7b07523-4e20-4a95-b28b-b2c75f49f952.png) ![Screenshot 2022-01-25 at 14-57-31 Local — PyTorch TorchX main documentation](https://user-images.githubusercontent.com/909104/151073875-84f5f205-6cc7-49f8-8f8d-71e2b4d7ff4f.png) Reviewed By: aivanou Differential Revision: D33778344 Pulled By: d4l3k fbshipit-source-id: cc8b52db083ecc199233ab2f419ebfd5d1e53c46
1 parent 46257ed commit 9d8c74d

File tree

6 files changed

+63
-22
lines changed

6 files changed

+63
-22
lines changed

docs/source/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
"sphinx.ext.autosectionlabel",
6262
"sphinx_gallery.gen_gallery",
6363
"compatibility",
64+
"runopts",
6465
"nbsphinx",
6566
"IPython.sphinxext.ipython_console_highlighting",
6667
]

docs/source/ext/compatibility.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,6 @@ class CompatibilityDirective(SphinxDirective):
2525
has_content = True
2626

2727
def run(self):
28-
"""
29-
targetid = "todo-%d" % self.env.new_serialno("todo")
30-
targetnode = nodes.target("", "", ids=[targetid])
31-
todo_node = todo("\n".join(self.content))
32-
todo_node += nodes.title(_("Todo"), _("Todo"))
33-
self.state.nested_parse(self.content, self.content_offset, todo_node)
34-
if not hasattr(self.env, "todo_all_todos"):
35-
self.env.todo_all_todos = []
36-
37-
self.env.todo_all_todos.append(
38-
{
39-
"docname": self.env.docname,
40-
"lineno": self.lineno,
41-
"todo": todo_node.deepcopy(),
42-
"target": targetnode,
43-
}
44-
)
45-
"""
46-
4728
raw_content = "\n".join(self.content)
4829
args = yaml.safe_load(raw_content)
4930
fields = COMPATIBILITY_SETS[args["type"]]

docs/source/ext/runopts.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
# Copyright (c) Meta Platforms, Inc. and affiliates.
4+
# All rights reserved.
5+
#
6+
# This source code is licensed under the BSD-style license found in the
7+
# LICENSE file in the root directory of this source tree.
8+
9+
from pydoc import locate
10+
11+
import yaml
12+
from docutils import nodes
13+
from sphinx.util.docutils import SphinxDirective
14+
15+
16+
class RunOptsDirective(SphinxDirective):
17+
# this enables content in the directive
18+
has_content = True
19+
20+
def run(self):
21+
raw_content = "\n".join(self.content)
22+
args = yaml.safe_load(raw_content)
23+
cls = locate(args["class"])
24+
25+
body = nodes.literal_block(text=str(cls.run_opts(None)))
26+
return [
27+
body,
28+
]
29+
30+
31+
def setup(app):
32+
app.add_directive("runopts", RunOptsDirective)
33+
34+
return {
35+
"version": "0.1",
36+
"parallel_read_safe": True,
37+
"parallel_write_safe": True,
38+
}

torchx/schedulers/kubernetes_scheduler.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,13 @@ class KubernetesScheduler(Scheduler):
331331
$ torchx status kubernetes://torchx_user/1234
332332
...
333333
334+
**Config Options**
335+
336+
.. runopts::
337+
class: torchx.schedulers.kubernetes_scheduler.KubernetesScheduler
338+
339+
**Compatibility**
340+
334341
.. compatibility::
335342
type: scheduler
336343
features:

torchx/schedulers/local_scheduler.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -528,10 +528,16 @@ class LocalScheduler(Scheduler):
528528
.. note::
529529
The orphan cleanup only works if `LocalScheduler` is instantiated from the main thread.
530530
531+
**Config Options**
532+
533+
.. runopts::
534+
class: torchx.schedulers.local_scheduler.LocalScheduler
535+
536+
**Compatibility**
537+
531538
.. note::
532-
Use this scheduler sparingly since an application that runs successfully
533-
on a session backed by this scheduler may not work on an actual
534-
production cluster using a different scheduler.
539+
Due to scheduler differences jobs that run locally may not work when
540+
using a different scheduler due to network or software dependencies.
535541
536542
.. compatibility::
537543
type: scheduler

torchx/schedulers/slurm_scheduler.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,13 @@ class SlurmScheduler(Scheduler):
224224
$ less slurm-1234.out
225225
...
226226
227+
**Config Options**
228+
229+
.. runopts::
230+
class: torchx.schedulers.slurm_scheduler.SlurmScheduler
231+
232+
**Compatibility**
233+
227234
.. compatibility::
228235
type: scheduler
229236
features:
@@ -233,6 +240,7 @@ class SlurmScheduler(Scheduler):
233240
describe: |
234241
Partial support. SlurmScheduler will return job and replica
235242
status but does not provide the complete original AppSpec.
243+
236244
"""
237245

238246
def __init__(self, session_name: str) -> None:

0 commit comments

Comments
 (0)