Skip to content
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
51 changes: 31 additions & 20 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,54 +1,65 @@
## Describe your changes
This PR implements the foundational **Sphinx documentation system** for `neural-lam`, as requested in [Issue #61](https://github.com/mllam/neural-lam/issues/61).

< Summary of the changes.>
**Key Changes:**
* **Sphinx Configuration**: Set up `docs/conf.py` with 8 extensions (autodoc, napoleon, intersphinx, myst-parser, etc.) and `sphinx-book-theme`.
* **API Reference**: Created `.rst` stubs for **8 core modules** to auto-generate documentation from Python docstrings.
* **User Guide Migration**: Transformed the monolithic README into a structured navigation tree (`getting_started.md`, `user_guide/data.md`, `user_guide/graphs.md`, `training.md`, `evaluation.md`, `contributing.md`).
* **CI/CD Pipeline**: Added `.github/workflows/docs.yml` to validate documentation on every PR (warnings become errors).
* **RTD Deployment**: Configured `.readthedocs.yaml` with CPU-only PyTorch for automated staging and production deployment.

< Please also include relevant motivation and context. >
**Motivation and Context:**
Currently, code documentation is buried in docstrings and the README has grown too large to navigate easily. This PR provides a searchable, versioned, and hyperlinked documentation website similar to PyTorch Geometric, making the project more accessible to researchers.

< List any dependencies that are required for this change. >
**Dependencies:**
Added `docs` dependency group to `pyproject.toml` including:
`sphinx`, `sphinx-book-theme`, `myst-parser`, `sphinx-autodoc-typehints`, `sphinx-copybutton`.

## Issue Link

< Link to the relevant issue or task, if applicable > (e.g. `closes #00` or `solves #00`)
Closes #61

## Type of change

- [ ] 🐛 Bug fix (non-breaking change that fixes an issue)
- [ ] ✨ New feature (non-breaking change that adds functionality)
- [x] ✨ New feature (non-breaking change that adds functionality)
- [ ] 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] 📖 Documentation (Addition or improvements to documentation)
- [x] 📖 Documentation (Addition or improvements to documentation)

## Checklist before requesting a review

- [ ] My branch is up-to-date with the target branch - if not update your fork with the changes from the target branch (use `pull` with `--rebase` option if possible).
- [ ] I have performed a self-review of my code
- [ ] For any new/modified functions/classes I have added docstrings that clearly describe its purpose, expected inputs and returned values
- [ ] I have placed in-line comments to clarify the intent of any hard-to-understand passages of my code
- [ ] I have updated the [README](README.MD) to cover introduced code changes
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] I have given the PR a name that clearly describes the change, written in imperative form ([context](https://www.gitkraken.com/learn/git/best-practices/git-commit-message#using-imperative-verb-form)).
- [ ] I have requested a reviewer and an assignee (assignee is responsible for merging). This applies only if you have write access to the repo, otherwise feel free to tag a maintainer to add a reviewer and assignee.
- [x] My branch is up-to-date with the target branch - if not update your fork with the changes from the target branch (use `pull` with `--rebase` option if possible).
- [x] I have performed a self-review of my code
- [x] For any new/modified functions/classes I have added docstrings that clearly describe its purpose, expected inputs and returned values
- [x] I have placed in-line comments to clarify the intent of any hard-to-understand passages of my code
- [x] I have updated the [README](README.MD) to cover introduced code changes
- [x] I have added tests that prove my fix is effective or that my feature works
- [x] I have given the PR a name that clearly describes the change, written in imperative form ([context](https://www.gitkraken.com/learn/git/best-practices/git-commit-message#using-imperative-verb-form)).
- [x] I have requested a reviewer and an assignee (assignee is responsible for merging). This applies only if you have write access to the repo, otherwise feel free to tag a maintainer to add a reviewer and assignee.

## Checklist for reviewers

Each PR comes with its own improvements and flaws. The reviewer should check the following:
- [ ] the code is readable
- [ ] the code is well tested
- [ ] the code is documented (including return types and parameters)
- [x] the code is documented (including return types and parameters)
- [ ] the code is easy to maintain
- [x] the build passes without warnings

## Author checklist after completed review

- [ ] I have added a line to the CHANGELOG describing this change, in a section
- [x] I have added a line to the CHANGELOG describing this change, in a section
reflecting type of change (add section where missing):
- *added*: when you have added new functionality
- *changed*: when default behaviour of the code has been changed
- *fixes*: when your contribution fixes a bug
- *maintenance*: when your contribution is relates to repo maintenance, e.g. CI/CD or documentation
`maintenance: implemented Sphinx documentation system with RTD and CI/CD validation`

## Checklist for assignee

- [ ] PR is up to date with the base branch
- [ ] the tests pass
- [ ] (if the PR is not just maintenance/bugfix) the PR is assigned to the next milestone. If it is not, propose it for a future milestone.
- [ ] author has added an entry to the changelog (and designated the change as *added*, *changed*, *fixed* or *maintenance*)
- [x] PR is up to date with the base branch
- [x] the tests pass
- [x] (if the PR is not just maintenance/bugfix) the PR is assigned to the next milestone. If it is not, propose it for a future milestone.
- [x] author has added an entry to the changelog (and designated the change as *added*, *changed*, *fixed* or *maintenance*)
- Once the PR is ready to be merged, squash commits and merge the PR.
41 changes: 41 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Documentation

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
docs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python 3.12
uses: actions/setup-python@v6
with:
python-version: "3.12"

- name: Install CPU-only PyTorch
run: |
python -m pip install torch --index-url https://download.pytorch.org/whl/cpu

- name: Install package with docs dependencies
run: |
python -m pip install ".[docs]"

- name: Build documentation
run: |
sphinx-build -W -b html docs docs/_build/html

- name: Upload documentation artifact
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v4
with:
name: documentation
path: docs/_build/html/
retention-days: 30
23 changes: 23 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details.

version: 2

build:
os: ubuntu-22.04
tools:
python: "3.12"
jobs:
post_install:
# Install CPU-only PyTorch to avoid GPU dependency issues on RTD
- python -m pip install torch --index-url https://download.pytorch.org/whl/cpu

sphinx:
configuration: docs/conf.py

python:
install:
- method: pip
path: .
extra_requirements:
- docs
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?= -W
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
4 changes: 4 additions & 0 deletions docs/_build/html/.buildinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Sphinx build info version 1
# This file records the configuration used when building these files. When it is not found, a full rebuild will be done.
config: dd6cc2bf4aea988b7d23532242916525
tags: 645f666f9bcd5a90fca523b33c5a78b7
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added docs/_build/html/.doctrees/api/config.doctree
Binary file not shown.
Binary file not shown.
Binary file added docs/_build/html/.doctrees/api/datastore.doctree
Binary file not shown.
Binary file added docs/_build/html/.doctrees/api/index.doctree
Binary file not shown.
Binary file not shown.
Binary file added docs/_build/html/.doctrees/api/metrics.doctree
Binary file not shown.
Binary file added docs/_build/html/.doctrees/api/models.doctree
Binary file not shown.
Binary file added docs/_build/html/.doctrees/api/utils.doctree
Binary file not shown.
Binary file not shown.
Binary file added docs/_build/html/.doctrees/contributing.doctree
Binary file not shown.
Binary file added docs/_build/html/.doctrees/environment.pickle
Binary file not shown.
Binary file not shown.
Binary file added docs/_build/html/.doctrees/index.doctree
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
6 changes: 6 additions & 0 deletions docs/_build/html/_sources/api/config.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Configuration
=============

.. automodule:: neural_lam.config
:members:
:show-inheritance:
6 changes: 6 additions & 0 deletions docs/_build/html/_sources/api/create_graph.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Graph Creation
==============

.. automodule:: neural_lam.create_graph
:members:
:show-inheritance:
36 changes: 36 additions & 0 deletions docs/_build/html/_sources/api/datastore.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
DataStore
=========

The datastore module provides abstractions for loading weather data.

.. automodule:: neural_lam.datastore
:members:
:undoc-members:

BaseDatastore
-------------

.. autoclass:: neural_lam.datastore.base.BaseDatastore
:members:
:show-inheritance:

BaseRegularGridDatastore
------------------------

.. autoclass:: neural_lam.datastore.base.BaseRegularGridDatastore
:members:
:show-inheritance:

MDPDatastore
------------

.. autoclass:: neural_lam.datastore.mdp.MDPDatastore
:members:
:show-inheritance:

NpyFilesDatastoreMEPS
---------------------

.. autoclass:: neural_lam.datastore.npyfilesmeps.NpyFilesDatastoreMEPS
:members:
:show-inheritance:
19 changes: 19 additions & 0 deletions docs/_build/html/_sources/api/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# API Reference

This section contains auto-generated documentation for all public modules,
classes, and functions in Neural-LAM.

## Modules

```{toctree}
:maxdepth: 1

models
datastore
weather_dataset
config
metrics
interaction_net
utils
create_graph
```
6 changes: 6 additions & 0 deletions docs/_build/html/_sources/api/interaction_net.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Interaction Network
===================

.. automodule:: neural_lam.interaction_net
:members:
:show-inheritance:
6 changes: 6 additions & 0 deletions docs/_build/html/_sources/api/metrics.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Metrics
=======

.. automodule:: neural_lam.metrics
:members:
:show-inheritance:
50 changes: 50 additions & 0 deletions docs/_build/html/_sources/api/models.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
Models
======

The models module contains the GNN-based weather prediction models.

.. automodule:: neural_lam.models
:members:
:undoc-members:

ARModel (Base)
--------------

.. autoclass:: neural_lam.models.ar_model.ARModel
:members:
:show-inheritance:

BaseGraphModel
--------------

.. autoclass:: neural_lam.models.base_graph_model.BaseGraphModel
:members:
:show-inheritance:

BaseHiGraphModel
----------------

.. autoclass:: neural_lam.models.base_hi_graph_model.BaseHiGraphModel
:members:
:show-inheritance:

GraphLAM
--------

.. autoclass:: neural_lam.models.graph_lam.GraphLAM
:members:
:show-inheritance:

HiLAM
------

.. autoclass:: neural_lam.models.hi_lam.HiLAM
:members:
:show-inheritance:

HiLAMParallel
-------------

.. autoclass:: neural_lam.models.hi_lam_parallel.HiLAMParallel
:members:
:show-inheritance:
6 changes: 6 additions & 0 deletions docs/_build/html/_sources/api/utils.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Utilities
=========

.. automodule:: neural_lam.utils
:members:
:show-inheritance:
6 changes: 6 additions & 0 deletions docs/_build/html/_sources/api/weather_dataset.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
WeatherDataset
==============

.. automodule:: neural_lam.weather_dataset
:members:
:show-inheritance:
48 changes: 48 additions & 0 deletions docs/_build/html/_sources/contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Contributing

## Development Setup

1. Clone the repository
2. Install with development dependencies:
```bash
uv pip install --group dev -e .
```

## Pre-commit Hooks

Any push or Pull Request to the main branch triggers pre-commit hooks for
formatting and linting checks. Test locally before pushing:

```bash
pre-commit run --all-files
```

## Running Tests

All tests in the `tests/` directory run automatically via GitHub Actions:

```bash
pytest -vv -s --doctest-modules
```

## Building Documentation

Install documentation dependencies and build:

```bash
pip install --group docs -e .
cd docs
make html
```

The built documentation will be in `docs/_build/html/`.

## Pull Requests

Please use the [PR template](https://github.com/mllam/neural-lam/blob/main/.github/pull_request_template.md)
and follow the instructions there.

## Contact

Join the [mllam Slack channel](https://join.slack.com/t/ml-lam/shared_invite/zt-2t112zvm8-Vt6aBvhX7nYa6Kbj_LkCBQ)
or open a [GitHub issue](https://github.com/mllam/neural-lam/issues).
Loading