-
Notifications
You must be signed in to change notification settings - Fork 275
Add Jupyter Book documentation infrastructure with auto-generated API reference via sphinx-autoapi #272
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
Open
Mohit-Lakra
wants to merge
20
commits into
mllam:main
Choose a base branch
from
Mohit-Lakra:Auto-doc
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add Jupyter Book documentation infrastructure with auto-generated API reference via sphinx-autoapi #272
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
6c7b113
Generated Autodocs using autoapi
Mohit-Lakra b16b3dd
torch dependency removed
Mohit-Lakra 41f1b15
Merge branch 'main' into Auto-doc
Mohit-Lakra dd1b02a
build: migrate docs workflow from pdm to hatchling and fix duplicate …
Mohit-Lakra 3a1f335
Updating branch with latest changes
Mohit-Lakra 15fe5ad
docs: Overhaul documentation system
Mohit-Lakra 880dc48
Resolve pyproject.toml uv extra conflicts for CI
Mohit-Lakra 3702b9d
fix: prevent browser auto-open from crashing headless GitHub Actions …
Mohit-Lakra 71e7e7f
Merge branch 'main' into Auto-doc
sadamov d5b7820
docs: clean up prose, migrate to sphinx autoapi, and fix formatting
Mohit-Lakra b02bf79
docs : Formatting Fix
Mohit-Lakra 2776af6
- Remove tool.setuptools from pyproject.toml
Mohit-Lakra 2821398
Removing mermaid dependencies, correcting slack channel link, and som…
Mohit-Lakra 517175b
docs: address review feedback
Mohit-Lakra c419422
Merge branch 'main' into Auto-doc
sadamov 5bc53ee
changed hilam to hi_lam
Mohit-Lakra 589e52a
dropping cpu --extra
Mohit-Lakra 1bfa846
Merge branch 'main' into Auto-doc
sadamov ad849a5
added graph_storage_spec to toctree
sadamov 9f5a79f
moved the References into their own section
sadamov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| name: Documentation | ||
| on: | ||
| push: | ||
| branches: ["main"] | ||
| paths: | ||
| - "neural_lam/**" | ||
| - "docs/**" | ||
| - "pyproject.toml" | ||
| - ".github/workflows/docs.yml" | ||
| pull_request: | ||
| branches: ["main"] | ||
| paths: | ||
| - "neural_lam/**" | ||
| - "docs/**" | ||
| - "pyproject.toml" | ||
| - ".github/workflows/docs.yml" | ||
| workflow_dispatch: | ||
|
|
||
| concurrency: | ||
| group: "docs-${{ github.ref }}" | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| build-docs: | ||
| name: Build docs | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Set up uv | ||
| uses: astral-sh/setup-uv@v5 | ||
|
|
||
| - name: Set up Python 3.11 | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.11" | ||
|
|
||
| - name: Install docs dependencies | ||
| run: uv sync --extra docs --group dev --no-cache | ||
|
|
||
|
|
||
|
|
||
| - name: Build docs with sphinx | ||
| run: uv run sphinx-build -W --keep-going -b html docs/ docs/_build/html/ | ||
|
|
||
| - name: Upload docs artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: docs-html | ||
| path: docs/_build/html/ | ||
|
|
||
| linkcheck: | ||
| name: Link check | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Set up uv | ||
| uses: astral-sh/setup-uv@v5 | ||
|
|
||
| - name: Set up Python 3.11 | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.11" | ||
|
|
||
| - name: Install docs dependencies | ||
| run: uv sync --extra docs --group dev --no-cache | ||
|
|
||
|
|
||
|
|
||
| - name: Run linkcheck | ||
| run: uv run sphinx-build -W --keep-going -b linkcheck docs/ docs/_build/linkcheck/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| version: 2 | ||
|
|
||
| build: | ||
| os: ubuntu-22.04 | ||
| tools: | ||
| python: "3.11" | ||
| commands: | ||
| - pip install uv | ||
| - uv sync --extra docs --group dev | ||
| - uv run sphinx-build -W --keep-going -b html docs/ docs/_build/html/ | ||
| - cp -r docs/_build/html/* $READTHEDOCS_OUTPUT/html/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| # Standard library | ||
| import os | ||
| import sys | ||
|
|
||
| # Add the project root to sys.path so sphinx can find neural_lam | ||
| sys.path.insert(0, os.path.abspath("..")) | ||
|
|
||
| project = "Neural-LAM" | ||
| copyright = "2024–2026, MLLAM Community" | ||
| author = "MLLAM Community" | ||
|
|
||
| # General Sphinx configuration | ||
| exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] | ||
|
|
||
| extensions = [ | ||
| "autoapi.extension", | ||
| "myst_nb", | ||
| "sphinx.ext.napoleon", | ||
| "sphinx.ext.viewcode", | ||
| "sphinx.ext.intersphinx", | ||
| "sphinx_copybutton", | ||
| "sphinxext.opengraph", | ||
| ] | ||
|
|
||
| # AutoAPI settings | ||
| autoapi_dirs = ["../neural_lam"] | ||
| autoapi_root = "api" | ||
| autoapi_type = "python" | ||
| autoapi_options = [ | ||
| "members", | ||
| "undoc-members", | ||
| "show-inheritance", | ||
| "show-module-summary", | ||
| ] | ||
| autoapi_python_class_content = "both" | ||
| autoapi_member_order = "groupwise" | ||
| autoapi_python_use_implicit_namespaces = False | ||
| autoapi_keep_files = True | ||
| autoapi_add_toctree_entry = True | ||
| autoapi_ignore = ["**/tests/**", "**/conftest.py"] | ||
|
|
||
| # Napoleon settings | ||
| napoleon_numpy_docstring = True | ||
| napoleon_google_docstring = False | ||
| napoleon_include_init_with_doc = True | ||
| napoleon_include_private_with_doc = False | ||
| napoleon_include_special_with_doc = False | ||
| napoleon_use_param = True | ||
| napoleon_use_rtype = True | ||
| napoleon_use_ivar = True | ||
|
|
||
| # Intersphinx settings | ||
| intersphinx_mapping = { | ||
| "python": ("https://docs.python.org/3", None), | ||
| "numpy": ("https://numpy.org/doc/stable", None), | ||
| "torch": ("https://pytorch.org/docs/stable", None), | ||
| "pytorch_lightning": ("https://lightning.ai/docs/pytorch/stable/", None), | ||
| "torch_geometric": ( | ||
| "https://pytorch-geometric.readthedocs.io/en/latest/", | ||
| None, | ||
| ), | ||
| } | ||
|
|
||
| # MyST / Notebook settings | ||
| myst_enable_extensions = [ | ||
| "colon_fence", | ||
| "dollarmath", | ||
| "linkify", | ||
| "substitution", | ||
| "tasklist", | ||
| "deflist", | ||
| "fieldlist", | ||
| "html_admonition", | ||
| "html_image", | ||
| "smartquotes", | ||
| "attrs_inline", | ||
| ] | ||
| nb_execution_mode = "off" | ||
|
|
||
| # HTML Theme | ||
| html_theme = "sphinx_book_theme" | ||
| html_logo = "_static/logo.png" | ||
| html_static_path = ["_static"] | ||
|
|
||
| html_theme_options = { | ||
| "repository_url": "https://github.com/mllam/neural-lam", | ||
| "use_repository_button": True, | ||
| "use_issues_button": True, | ||
| "use_edit_page_button": True, | ||
| "repository_branch": "main", | ||
| "path_to_docs": "docs", | ||
| "show_navbar_depth": 2, | ||
| "show_toc_level": 2, | ||
| "extra_footer": ( | ||
| '<p>Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> | ' | ||
| '<a href="https://github.com/mllam/neural-lam">Source</a></p>' | ||
| ), | ||
| } | ||
|
|
||
| # OpenGraph settings | ||
| ogp_site_url = "https://neural-lam.readthedocs.io/en/latest/" | ||
| ogp_image = "_static/logo.png" | ||
| ogp_use_first_image = True | ||
|
|
||
| suppress_warnings = [ | ||
| "autoapi.python_import_resolution", | ||
| "myst.xref_missing", | ||
| ] | ||
|
|
||
| # Linkcheck settings | ||
| linkcheck_ignore = [ | ||
| r"https://kutt\.to/mllam", # Returns 403 Forbidden for bots | ||
| r"https://docs\.pytorch\.org/.*", # Flaky anchors in intersphinx | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # Installation | ||
|
|
||
| ## Prerequisites | ||
| - Python >=3.10 | ||
| - Git | ||
| - (Optional) CUDA-capable GPU for training | ||
|
|
||
| ```{include} ../../README.md | ||
| :start-after: "# Installing Neural-LAM" | ||
| :end-before: "# Using Neural-LAM" | ||
| ``` | ||
|
|
||
| ## Building Documentation Locally | ||
|
|
||
| ```{code-block} bash | ||
| # Install docs dependencies | ||
| uv sync --extra docs --group dev | ||
|
|
||
| # Build the documentation | ||
| sphinx-build -b html docs/ docs/_build/html/ | ||
|
|
||
| # Open in browser | ||
| open docs/_build/html/index.html # macOS | ||
| # xdg-open docs/_build/html/index.html # Linux | ||
| ``` | ||
|
|
||
| ```{seealso} | ||
| See the {doc}`quickstart` guide to run your first training. | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| # Quickstart | ||
|
|
||
| ## Overview | ||
|
|
||
| This guide walks through the minimum steps to get started with Neural-LAM: | ||
| 1. Set up example data | ||
| 2. Create a graph | ||
| 3. Train a model | ||
| 4. Evaluate the model | ||
|
|
||
| ## Step 1: Download Example Data | ||
|
|
||
| When running tests for the first time, example data is automatically downloaded from S3. You can trigger this download by running a minimal test. | ||
|
|
||
| ```{code-block} bash | ||
| # Run a minimal test to trigger the data download | ||
| pytest tests/test_training.py -vv -s -k "test_training" | ||
| ``` | ||
|
|
||
| ## Step 2: Create a Graph | ||
|
|
||
| Before training, you must construct a graph mesh for your data. | ||
|
|
||
| ```{code-block} bash | ||
| python -m neural_lam.create_graph --config_path <path-to-config> --name <graph-name> | ||
| ``` | ||
|
|
||
| This script builds the mesh graph required by the GNN models. | ||
|
|
||
| ## Step 3: Train a Model | ||
|
|
||
| Now you can train a model using the graph and configuration. | ||
|
|
||
| ```{code-block} bash | ||
| python -m neural_lam.train_model --config_path <path-to-config> --model graph_lam --graph <graph-name> | ||
| ``` | ||
|
|
||
| Neural-LAM supports several models like `graph_lam`, `hi_lam`, and `hi_lam_parallel`. | ||
|
|
||
| ## Step 4: Evaluate | ||
|
|
||
| After training, you can evaluate the model on the test set by loading the saved checkpoint. | ||
|
|
||
| ```{code-block} bash | ||
| python -m neural_lam.train_model --eval test --config_path <path-to-config> --load <checkpoint-path> | ||
| ``` | ||
|
|
||
| ## Configuration | ||
|
|
||
| Neural-LAM uses a YAML configuration system powered by `dataclass-wizard`. The configuration defines the dataset paths, training parameters, and model hyperparameters. For complete details, see the API reference for {py:class}`neural_lam.config.NeuralLAMConfig`. | ||
|
|
||
| - {doc}`../api/index` for complete API reference |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # Neural-LAM | ||
|
|
||
| Neural-LAM is a PyTorch and PyTorch Lightning framework for high-resolution weather prediction using Graph Neural Networks. It provides a modular approach to Limited Area Modeling, supporting multiple graph-based architectures such as GraphLAM, HiLAM, and HiLAMParallel to process and predict meteorological data efficiently. | ||
|
|
||
| ```{toctree} | ||
| :maxdepth: 2 | ||
| :hidden: | ||
|
|
||
| getting-started/installation | ||
| getting-started/quickstart | ||
| ``` | ||
|
|
||
| ```{toctree} | ||
| :maxdepth: 2 | ||
| :caption: Tutorials | ||
| :hidden: | ||
|
|
||
| notebooks/create_reduced_meps_dataset | ||
| ``` | ||
|
|
||
| ```{toctree} | ||
| :maxdepth: 2 | ||
| :caption: Reference | ||
| :hidden: | ||
|
|
||
| api/index | ||
| graph_storage_spec | ||
| ``` | ||
|
|
||
| - **[🚀 Getting Started](getting-started/installation.md)**: Installation guide and quickstart tutorial to get you up and running. | ||
| - **[📚 API Reference](api/index)**: Auto-generated reference for all modules, classes, and functions. | ||
|
|
||
| ## Key Features | ||
|
|
||
| - **Modular design**: Swap datastores, models, and graph structures independently | ||
| - **Multiple model architectures**: GraphLAM (flat), HiLAM (hierarchical), HiLAMParallel (parallel hierarchical) | ||
| - **Flexible data handling**: Abstract datastore interface supporting zarr, numpy, and custom formats via mllam-data-prep | ||
| - **Production-ready**: PyTorch Lightning for training, W&B/MLflow logging, checkpoint management | ||
|
|
||
| ## Quick Links | ||
|
|
||
| - [GitHub Repository](https://github.com/mllam/neural-lam) | ||
| - [Issue Tracker](https://github.com/mllam/neural-lam/issues) | ||
| - [MLLAM Community Slack](https://kutt.to/mllam) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.