Skip to content

docs/schedulers: add runopts to documentation #374

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"sphinx.ext.autosectionlabel",
"sphinx_gallery.gen_gallery",
"compatibility",
"runopts",
"nbsphinx",
"IPython.sphinxext.ipython_console_highlighting",
]
Expand Down
19 changes: 0 additions & 19 deletions docs/source/ext/compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,6 @@ class CompatibilityDirective(SphinxDirective):
has_content = True

def run(self):
"""
targetid = "todo-%d" % self.env.new_serialno("todo")
targetnode = nodes.target("", "", ids=[targetid])
todo_node = todo("\n".join(self.content))
todo_node += nodes.title(_("Todo"), _("Todo"))
self.state.nested_parse(self.content, self.content_offset, todo_node)
if not hasattr(self.env, "todo_all_todos"):
self.env.todo_all_todos = []

self.env.todo_all_todos.append(
{
"docname": self.env.docname,
"lineno": self.lineno,
"todo": todo_node.deepcopy(),
"target": targetnode,
}
)
"""

raw_content = "\n".join(self.content)
args = yaml.safe_load(raw_content)
fields = COMPATIBILITY_SETS[args["type"]]
Expand Down
38 changes: 38 additions & 0 deletions docs/source/ext/runopts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

from pydoc import locate

import yaml
from docutils import nodes
from sphinx.util.docutils import SphinxDirective


class RunOptsDirective(SphinxDirective):
# this enables content in the directive
has_content = True

def run(self):
raw_content = "\n".join(self.content)
args = yaml.safe_load(raw_content)
cls = locate(args["class"])

body = nodes.literal_block(text=str(cls.run_opts(None)))
return [
body,
]


def setup(app):
app.add_directive("runopts", RunOptsDirective)

return {
"version": "0.1",
"parallel_read_safe": True,
"parallel_write_safe": True,
}
7 changes: 7 additions & 0 deletions torchx/schedulers/kubernetes_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,13 @@ class KubernetesScheduler(Scheduler):
$ torchx status kubernetes://torchx_user/1234
...

**Config Options**

.. runopts::
class: torchx.schedulers.kubernetes_scheduler.KubernetesScheduler

**Compatibility**

.. compatibility::
type: scheduler
features:
Expand Down
12 changes: 9 additions & 3 deletions torchx/schedulers/local_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,10 +528,16 @@ class LocalScheduler(Scheduler):
.. note::
The orphan cleanup only works if `LocalScheduler` is instantiated from the main thread.

**Config Options**

.. runopts::
class: torchx.schedulers.local_scheduler.LocalScheduler

**Compatibility**

.. note::
Use this scheduler sparingly since an application that runs successfully
on a session backed by this scheduler may not work on an actual
production cluster using a different scheduler.
Due to scheduler differences jobs that run locally may not work when
using a different scheduler due to network or software dependencies.

.. compatibility::
type: scheduler
Expand Down
8 changes: 8 additions & 0 deletions torchx/schedulers/slurm_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,13 @@ class SlurmScheduler(Scheduler):
$ less slurm-1234.out
...

**Config Options**

.. runopts::
class: torchx.schedulers.slurm_scheduler.SlurmScheduler

**Compatibility**

.. compatibility::
type: scheduler
features:
Expand All @@ -210,6 +217,7 @@ class SlurmScheduler(Scheduler):
describe: |
Partial support. SlurmScheduler will return job and replica
status but does not provide the complete original AppSpec.

"""

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