Skip to content

More changes to docs #73

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

Merged
merged 35 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
3bd7f1b
Update launcher.py
pmcurtin Oct 19, 2024
2ce3576
Merge branch 'main' into docs-2
apoorvkh Oct 19, 2024
2731d31
Merge branch 'main' into docs-2
apoorvkh Oct 20, 2024
0b9c1df
moved log_handlers into .run()
apoorvkh Oct 20, 2024
af8c829
update contributing
apoorvkh Oct 20, 2024
4ac384e
add tyro, remove setuptools from extras
apoorvkh Oct 20, 2024
cbf40b9
enabled linting for docs; clarified public/private functions
apoorvkh Oct 20, 2024
76aa20f
docs for utils.py
apoorvkh Oct 20, 2024
de93aaf
docs for logging_utils
apoorvkh Oct 20, 2024
e4977fd
Merge branch 'docs-2' of github.com:apoorvkh/torchrunx into worker-ex…
apoorvkh Oct 20, 2024
e697257
advanced docs
apoorvkh Oct 20, 2024
748c2b7
adding napoleon for google docs
apoorvkh Oct 21, 2024
24f4a98
linkcode
apoorvkh Oct 21, 2024
cb6620c
update linkcode
apoorvkh Oct 21, 2024
3eb297c
try again
apoorvkh Oct 21, 2024
e609f54
fix?
apoorvkh Oct 21, 2024
e88e320
now linkcode works
apoorvkh Oct 21, 2024
bef8b28
updates
apoorvkh Oct 21, 2024
86bb67b
automethod run for launcher
apoorvkh Oct 21, 2024
d80d822
maximum_signature_line_length
apoorvkh Oct 21, 2024
9950e96
switch to members?
apoorvkh Oct 21, 2024
8276abc
Merge branch 'main' of github.com:apoorvkh/torchrunx into docs-2
apoorvkh Oct 29, 2024
f335140
created utils/
apoorvkh Oct 29, 2024
0b5e316
moved functions to worker.py
apoorvkh Oct 29, 2024
084061f
renamed to worker_entrypoint
apoorvkh Oct 29, 2024
6cc9311
completed docs for utils
apoorvkh Oct 29, 2024
490f2a8
more launcher docs
apoorvkh Oct 29, 2024
e54a533
more updates to docs
apoorvkh Oct 29, 2024
455c3f3
switched LaunchResult to get
apoorvkh Oct 29, 2024
f967218
bump hash in pixi lock
apoorvkh Oct 29, 2024
3a68eb6
removed overloading from LaunchResult
apoorvkh Oct 29, 2024
9e2d5f4
update all docs
apoorvkh Oct 30, 2024
a29212e
fix
apoorvkh Oct 30, 2024
7bf9222
small edits
apoorvkh Oct 30, 2024
122febc
how it works
apoorvkh Oct 30, 2024
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
Prev Previous commit
Next Next commit
update linkcode
  • Loading branch information
apoorvkh committed Oct 21, 2024
commit cb6620c5406bc96770d17a113b903f36cf58caf0
106 changes: 59 additions & 47 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@

# Configuration file for the Sphinx documentation builder.

# -- Project information

project = "torchrunx"

# -- General configuration
github_username = "apoorvkh"
github_repository = "torchrunx"
html_theme = "furo"

extensions = [
"sphinx.ext.duration",
Expand All @@ -23,67 +22,80 @@
"sphinx.ext.linkcode",
]

autodoc_typehints = "both"
#typehints_defaults = "comma"

github_username = "apoorvkh"
github_repository = "torchrunx"
autodoc_typehints = "description"

autodoc_mock_imports = ["torch", "fabric", "cloudpickle", "typing_extensions"]

intersphinx_mapping = {
"python": ("https://docs.python.org/3/", None),
"sphinx": ("https://www.sphinx-doc.org/en/master/", None),
}
intersphinx_disabled_domains = ["std"]

templates_path = ["_templates"]

# -- Options for HTML output

html_theme = "furo"
## Link code to Github source
# From: https://github.com/scikit-learn/scikit-learn/blob/main/doc/sphinxext/github_link.py

# -- Options for EPUB output
epub_show_urls = "footnote"
import inspect
import os
import subprocess
import sys
from functools import partial
from operator import attrgetter

# code block syntax highlighting
#pygments_style = "sphinx"

code_url = f"https://github.com/{github_username}/{github_repository}/blob/{commit}"
def _linkcode_resolve(domain, info, package, url_fmt, revision):
if revision is None:
return
if domain not in ("py", "pyx"):
return
if not info.get("module") or not info.get("fullname"):
return

import importlib
import inspect
class_name = info["fullname"].split(".")[0]
module = __import__(info["module"], fromlist=[class_name])
obj = attrgetter(info["fullname"])(module)

def linkcode_resolve(domain, info):
# Non-linkable objects from the starter kit in the tutorial.
if domain == "js" or info["module"] == "connect4":
# Unwrap the object to get the correct source
# file in case that is wrapped by a decorator
obj = inspect.unwrap(obj)

try:
fn = inspect.getsourcefile(obj)
except Exception:
fn = None
if not fn:
try:
fn = inspect.getsourcefile(sys.modules[obj.__module__])
except Exception:
fn = None
if not fn:
return

assert domain == "py", "expected only Python objects"
fn = os.path.relpath(fn, start=os.path.dirname(__import__(package).__file__))
try:
lineno = inspect.getsourcelines(obj)[1]
except Exception:
lineno = ""
return url_fmt.format(revision=revision, package=package, path=fn, lineno=lineno)

mod = importlib.import_module(info["module"])
if "." in info["fullname"]:
objname, attrname = info["fullname"].split(".")
obj = getattr(mod, objname)
try:
# object is a method of a class
obj = getattr(obj, attrname)
except AttributeError:
# object is an attribute of a class
return None
else:
obj = getattr(mod, info["fullname"])

def make_linkcode_resolve(package, url_fmt):
try:
file = inspect.getsourcefile(obj)
lines = inspect.getsourcelines(obj)
except TypeError:
# e.g. object is a typing.Union
return None
file = os.path.relpath(file, os.path.abspath(".."))
if not file.startswith("src/websockets"):
# e.g. object is a typing.NewType
return None
start, end = lines[1], lines[1] + len(lines[0]) - 1

return f"{code_url}/{file}#L{start}-L{end}"
revision = (
subprocess.check_output("git rev-parse --short HEAD".split()).strip().decode("utf-8")
)
except (subprocess.CalledProcessError, OSError):
print("Failed to execute git to get revision")
revision = None
return partial(_linkcode_resolve, revision=revision, package=package, url_fmt=url_fmt)


linkcode_resolve = make_linkcode_resolve(
"torchrunx",
(
f"https://github.com/{github_username}/{github_repository}/"
"blob/{revision}/{package}/{path}#L{lineno}"
),
)
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Documentation = "https://torchrunx.readthedocs.io"

[tool.ruff]
include = ["pyproject.toml", "src/**/*.py", "tests/**/*.py"]
exclude = ["docs"]
line-length = 100
src = ["src", "tests"]
[tool.ruff.lint]
Expand Down
Loading