Skip to content

Commit dc63eaa

Browse files
committed
Add initial auto-generated API and NVIDIA theme
Signed-off-by: Nathan McKimpson <[email protected]>
1 parent c7d040d commit dc63eaa

File tree

13 files changed

+459
-277
lines changed

13 files changed

+459
-277
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ instance/
7171

7272
# Sphinx documentation
7373
docs/_build/
74+
docs/source/api/
7475

7576
# PyBuilder
7677
.pybuilder/

CONTRIBUTING.md

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Not all steps are necessary for some contributions, so read the linked sections
1717
- [Whom should you ask for review:](#whom-should-you-ask-for-review)
1818

1919
## General principles
20+
2021
1. **User-oriented**: make it easy for end users, even at the cost of writing more code in the background
2122
1. **Robust**: make it hard for users to make mistakes.
2223
1. **Reusable**: for every piece of code, think about how it can be reused in the future and make it easy to be reused.
@@ -25,6 +26,7 @@ Not all steps are necessary for some contributions, so read the linked sections
2526
1. **Sensible**: code should make sense. If you think a piece of code might be confusing, write comments.
2627

2728
## Environment Setup
29+
2830
We use [uv](https://docs.astral.sh/uv/) to develop NeMo Run. The following steps should get you started with the dev environment:
2931

3032
1. Install [uv](https://docs.astral.sh/uv/getting-started/installation/)
@@ -34,16 +36,19 @@ We use [uv](https://docs.astral.sh/uv/) to develop NeMo Run. The following steps
3436
If all tests passed, then you should be good to get started with the development of NeMo-Run.
3537

3638
## Code Structure
39+
3740
The repository is home to flexible Python modules, sample scripts, tests, and more.
3841
Here is a brief overview of where everything lives:
42+
3943
- [docker](docker/) - Dockerfiles to build NeMo with NeMo Run.
4044
- [docs](docs/) - Walkthroughs and guides the library.
4145
- [examples](examples/) - Examples for how users may want to use NeMo Run.
4246
- [src](src/) -
43-
- [nemo_run](src/nemo_run/) - The source code for NeMo Run.
47+
- [nemo_run](src/nemo_run/) - The source code for NeMo Run.
4448
- [test](test/) - Unit tests.
4549

4650
## Examples and Documentation
51+
4752
Examples provide an easy way for users to see how the NeMo Run works in action.
4853
They should be incredibly lightweight and rely mostly on `nemo_run` for their functionality
4954
Most should be designed for a user to get up and running on their local machines, but examples on remote clusters are welcomed if it makes sense.
@@ -54,35 +59,49 @@ It should include both an explanation of the API, and how it's used in its corre
5459
The documentation should also cover potential pitfalls and caveats.
5560
This existing examples and documentation should serve as a good reference to what is expected.
5661

62+
### Building Documentation
63+
64+
Run the following commands to switch to the project documentation folder and generate HTML output.
65+
66+
```sh
67+
cd docs/
68+
uv run --group docs sphinx-build source/ _build/html
69+
```
70+
71+
The resulting HTML files are generated in a `_build/html` folder created under the project `docs/` folder.
72+
5773
## Python style
58-
We use [``ruff``](https://docs.astral.sh/ruff/) for linting and formatting. To lint and format your code, you can run `uv run --group lint -- ruff check` and `uv run --group lint -- ruff format` respectively.
74+
75+
We use [`ruff`](https://docs.astral.sh/ruff/) for linting and formatting. To lint and format your code, you can run `uv run --group lint -- ruff check` and `uv run --group lint -- ruff format` respectively.
5976

6077
## Unit tests
78+
6179
Unit tests should be simple and fast.
6280
Developers should be able to run them frequently while developing without any slowdown.
6381

6482
## Pull Requests (PR) Guidelines
6583

6684
**Send your PRs to the `main` or `dev` branch**
6785

68-
1) Make sure your PR does one thing. Have a clear answer to "What does this PR do?".
69-
2) Read General Principles and style guide above
70-
3) Make sure you sign off your commits. E.g. use ``git commit --signoff`` when committing.
71-
4) Make sure all unit tests finish successfully before sending PR
72-
5) Send your PR and request a review
86+
1. Make sure your PR does one thing. Have a clear answer to "What does this PR do?".
87+
2. Read General Principles and style guide above
88+
3. Make sure you sign off your commits. E.g. use `git commit --signoff` when committing.
89+
4. Make sure all unit tests finish successfully before sending PR
90+
5. Send your PR and request a review
7391

7492
The `dev` branch is for active development and may be unstable. Unit tests are expected to pass before merging into `dev` or `main`.
7593
Every release `dev` and `main` will sync to be the same.
7694

7795
## Sign Your Work
7896

79-
* We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license.
97+
- We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license.
98+
99+
- Any contribution which contains commits that are not Signed-Off will not be accepted.
80100

81-
* Any contribution which contains commits that are not Signed-Off will not be accepted.
101+
- To sign off on a commit you simply use the `--signoff` option when committing your changes:
82102

83-
* To sign off on a commit you simply use the `--signoff` option when committing your changes:
84103
```bash
85-
$ git commit --signoff -m "Add cool feature."
104+
git commit --signoff -m "Add cool feature."
86105
```
87106

88107
## Full text of the DCO:

docs/Makefile

Lines changed: 0 additions & 20 deletions
This file was deleted.

docs/make.bat

Lines changed: 0 additions & 35 deletions
This file was deleted.

docs/source/conf.py

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@
66
# -- Project information -----------------------------------------------------
77
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
88

9+
import sys
10+
from pathlib import Path
11+
12+
sys.path.append(str(Path("../../examples").resolve()))
13+
914
project = "NeMo-Run"
10-
copyright = "2024, NVIDIA"
15+
copyright = "2025, NVIDIA"
1116
author = "NVIDIA"
1217
release = "0.1.0"
1318

@@ -16,6 +21,7 @@
1621

1722
extensions = [
1823
"myst_parser",
24+
"autoapi.extension",
1925
"sphinx.ext.autodoc",
2026
"sphinx.ext.doctest",
2127
"sphinx.ext.intersphinx",
@@ -29,16 +35,30 @@
2935
]
3036

3137
templates_path = ["_templates"]
32-
exclude_patterns = []
38+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
3339
python_maximum_signature_line_length = 88
34-
autodoc_default_options = {
35-
"member-order": "bysource",
36-
"special-members": "__init__",
37-
"undoc-members": True,
38-
"exclude-members": "__weakref__",
39-
}
40-
autodoc_class_signature = "separated"
41-
autodoc_inherit_docstrings = True
40+
41+
# Autoapi settings
42+
autoapi_generate_api_docs = True
43+
autoapi_keep_files = False
44+
autoapi_add_toctree_entry = False
45+
autoapi_type = "python"
46+
autoapi_dirs = ["../../nemo_run"]
47+
autoapi_file_pattern = "*.py"
48+
autoapi_root = "api"
49+
autoapi_options = [
50+
"members",
51+
"show-inheritance",
52+
"show-module-summary",
53+
"special-members",
54+
"imported-members",
55+
]
56+
57+
# Autodoc settings
58+
autodoc_typehints = "signature"
59+
60+
# MyST settings
61+
myst_heading_anchors = 3
4262

4363
# Napoleon settings
4464
napoleon_google_docstring = True
@@ -56,5 +76,4 @@
5676
# -- Options for HTML output -------------------------------------------------
5777
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
5878

59-
html_theme = "alabaster"
60-
# html_static_path = ["_static"]
79+
html_theme = "nvidia_sphinx_theme"

docs/source/faqs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def control_flow_config() -> run.Config[llm.PreTrainingDataModule]:
8484

8585
### **Q:** I made a change locally in my git repo and tested it using the local executor. However, the change is not reflected in the remote job.
8686

87-
**A**: This is most likely because you haven't committed the changes. See details about `GitArchivePackager` [here](./execution.md#packagers) to learn more.
87+
**A**: This is most likely because you haven't committed the changes. See details about `GitArchivePackager` [here](guides/execution.md#packagers) to learn more.
8888

8989
### **Q:** I made a change locally _outside_ my git repo and tested it using the local executor. However, the change is not reflected in the remote job.
9090

docs/source/guides/management.md

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,42 @@
22

33
The central component for management of tasks in NeMo-Run is the `Experiment` class. It allows you to define, launch, and manage complex workflows consisting of multiple tasks. This guide provides an overview of the `Experiment` class, its methods, and how to use it effectively.
44

5-
**Creating an Experiment**
6-
---------------------------
5+
## **Creating an Experiment**
76

87
To create an experiment, you can instantiate the `Experiment` class by passing in a descriptive title:
8+
99
```python
1010
exp = Experiment("My Experiment")
1111
```
12+
1213
When executed, it will automatically generate a unique experiment ID for you, which represents one unique run of the experiment.
1314

14-
> [!NOTE]
15-
> `Experiment` is a context manager and `Experiment.add` and `Experiment.run` methods can currently only be used after entering the context manager.
15+
> [!NOTE] > `Experiment` is a context manager and `Experiment.add` and `Experiment.run` methods can currently only be used after entering the context manager.
1616
17-
**Adding Tasks**
18-
-----------------
17+
## **Adding Tasks**
1918

2019
You can add tasks to an experiment using the `add` method. This method supports tasks of the following kind:
2120

22-
1. A single task which is an instance of either `run.Partial` or `run.Script`, along with its executor.
23-
```python
24-
with exp:
25-
exp.add(task_1, executor=run.LocalExecutor())
26-
```
21+
- A single task which is an instance of either `run.Partial` or `run.Script`, along with its executor.
2722

28-
2. A list of tasks, each of which is an instance of either `run.Partial` or `run.Script`, along with a single executor or a list of executors for each task in the group. Currently, all tasks in the group will be executed in parallel.
29-
```python
30-
with exp:
31-
exp.add([task_2, task_3], executor=run.DockerExecutor(...))
32-
```
23+
```python
24+
with exp:
25+
exp.add(task_1, executor=run.LocalExecutor())
26+
```
27+
28+
- A list of tasks, each of which is an instance of either `run.Partial` or `run.Script`, along with a single executor or a list of executors for each task in the group. Currently, all tasks in the group will be executed in parallel.
29+
30+
```python
31+
with exp:
32+
exp.add([task_2, task_3], executor=run.DockerExecutor(...))
33+
```
3334

3435
You can specify a descriptive name for the task using the `name` keyword argument.
3536

3637
`add` also takes in a list of plugins, each an instance of `run.Plugin`. Plugins are used to make changes to the task and executor together, which is useful in some cases - for example, to enable a config option in the task and set an environment variable in the executor related to the config option.
3738

3839
`add` returns a unique id for the task/job. This unique id can be used to define complex dependencies between a group of tasks as follows:
40+
3941
```python
4042
with run.Experiment("dag-experiment", log_level="INFO") as exp:
4143
id1 = exp.add([inline_script, inline_script_sleep], tail_logs=False, name="task-1")
@@ -48,30 +50,31 @@ with run.Experiment("dag-experiment", log_level="INFO") as exp:
4850
)
4951
```
5052

51-
**Launching an Experiment**
52-
---------------------------
53+
## **Launching an Experiment**
5354

5455
Once you have added all tasks to an experiment, you can launch it using the `run` method. This method takes several optional arguments, including `detach`, `sequential`, and `tail_logs` and `direct`:
5556

56-
* `detach`: If `True`, the experiment will detach from the process executing it. This is useful when launching an experiment on a remote cluster, where you may want to end the process after scheduling the tasks in that experiment.
57-
* `sequential`: If `True`, all tasks will be executed sequentially. This is only applicable when the individual tasks do not have any dependencies on each other.
58-
* `tail_logs`: If `True`, logs will be displayed in real-time.
59-
* `direct`: If `True`, each task in the experiment will be executed directly in the same process on your local machine. This does not support task/job groups.
57+
- `detach`: If `True`, the experiment will detach from the process executing it. This is useful when launching an experiment on a remote cluster, where you may want to end the process after scheduling the tasks in that experiment.
58+
- `sequential`: If `True`, all tasks will be executed sequentially. This is only applicable when the individual tasks do not have any dependencies on each other.
59+
- `tail_logs`: If `True`, logs will be displayed in real-time.
60+
- `direct`: If `True`, each task in the experiment will be executed directly in the same process on your local machine. This does not support task/job groups.
6061

6162
```python
6263
with exp:
6364
# Add all tasks
6465
exp.run(detach=True, sequential=False, tail_logs=True, direct=False)
6566
```
6667

67-
**Experiment Status**
68-
---------------------
68+
## **Experiment Status**
6969

7070
You can check the status of an experiment using the `status` method:
71+
7172
```python
7273
exp.status()
7374
```
75+
7476
This method will display information the status of each task in the experiment. The following is a sample output from the status of experiment in [hello_scripts.py](../../../examples/hello-world/hello_scripts.py):
77+
7578
```bash
7679
Experiment Status for experiment_with_scripts_1730761155
7780

@@ -94,24 +97,24 @@ Task 2: simple.add.add_object
9497
- Local Directory: /home/your_user/.nemo_run/experiments/experiment_with_scripts/experiment_with_scripts_1730761155/simple.add.add_object
9598
```
9699

97-
**Canceling a Task**
98-
---------------------
100+
## **Canceling a Task**
99101

100102
You can cancel a task using the `cancel` method:
103+
101104
```python
102105
exp.cancel("task_id")
103106
```
104107

105-
**Viewing Logs**
106-
-----------------
108+
## **Viewing Logs**
107109

108110
You can view the logs of a task using the `logs` method:
111+
109112
```python
110113
exp.logs("task_id")
111114
```
112115

113-
**Experiment output**
114-
-----------------
116+
## **Experiment output**
117+
115118
Once an experiment is run, NeMo-Run displays information on ways to inspect and reproduce past experiments. This allows you to check logs, sync artifacts (in the future), cancel running tasks, and rerun an old experiment.
116119

117120
```python
@@ -129,6 +132,7 @@ nemorun experiment status experiment_with_scripts_1720556256
129132
nemorun experiment logs experiment_with_scripts_1720556256 0
130133
nemorun experiment cancel experiment_with_scripts_1720556256 0
131134
```
135+
132136
This information is specific to each experiment on how to manage it.
133137

134-
See [this notebook](examples/hello-world/hello_experiments.ipynb) for more details and a playable experience.
138+
See [this notebook](../../../examples/hello-world/hello_experiments.ipynb) for more details and a playable experience.

0 commit comments

Comments
 (0)