Skip to content

docs: make ReadTheDocs build deps-free and reliable (D6) - #25

Merged
nceglia merged 1 commit into
mainfrom
docs/d6-readthedocs-build
Jun 8, 2026
Merged

docs: make ReadTheDocs build deps-free and reliable (D6)#25
nceglia merged 1 commit into
mainfrom
docs/d6-readthedocs-build

Conversation

@nceglia

@nceglia nceglia commented Jun 5, 2026

Copy link
Copy Markdown
Owner

Summary

The RTD build did pip install . (pulling the full ML stack — torch, scvi-tools, scanpy, pyro…) and then let autodoc import it. That's slow and OOM-prone on RTD's runners, and it never actually worked with the D11 autodoc. This rebuilds the API reference from source with the heavy deps mocked, so RTD installs almost nothing.

Changes

  • conf.pyautodoc_mock_imports: torch, pyro, scvi, sklearn, scanpy, anndata, scipy, matplotlib, seaborn, mpltern, umap, tqdm, daft, gseapy. autodoc still reads TCRi's own real signatures/docstrings; only third-party imports are stubbed. numpy/pandas kept real so intersphinx resolves their types.
  • conf.pyautodoc_class_signature = 'separated': without it, TCRIModel renders as TCRIModel(*args, **kwargs) because the mocked scvi BaseModelClass injects a __new__(*args, **kwargs) that shadows the real __init__. With it, autodoc reads __init__ directly and the real constructor signature (n_latent=128, …) renders.
  • conf.py — version: prefer installed metadata, fall back to parsing pyproject.toml (so the version is right even without an install).
  • .readthedocs.yaml: Python 3.9 → 3.12 (pyproject requires >=3.10); drop the pip install . step; HTML-only.
  • docs/requirements.txt: trimmed to the Sphinx toolchain + numpy/pandas; pinned sphinx>=7,<9, sphinx-rtd-theme>=2.0, myst-parser>=2.0.
  • Deleted the stale duplicate docs/.readthedocs.yaml (RTD uses the repo-root file).

Verification

Sphinx's mock finder shadows the locally-installed torch/scvi, so a local build genuinely reproduces the deps-free RTD path:

  • python -m sphinx -b html docs <out>build succeeded, 0 warnings, 0 import failures.
  • Real API renders: joint_distribution_posterior, save_tcri_session, and TCRIModel.__init__(adata, n_latent=128, …). Version resolves to 0.1.0.

Needs RTD-side confirmation

The mocked-build path is verified locally, but the actual RTD environment (network install + RTD resource limits) can only be confirmed by a real RTD build — please trigger/check one after merge. If a mocked module turns out to need un-mocking, it's a one-line edit to autodoc_mock_imports.

Closes Notion D6.

🤖 Generated with Claude Code

The RTD build installed the package with its full ML stack (torch,
scvi-tools, scanpy, ...) and then let autodoc import it - slow and prone to
out-of-memory failures on RTD, and it never actually worked with the new
D11 autodoc.

Build the API reference from source with the heavy deps mocked instead:

- conf.py: autodoc_mock_imports for torch/pyro/scvi/sklearn/scanpy/anndata/
  scipy/matplotlib/seaborn/mpltern/umap/tqdm/daft/gseapy (numpy/pandas kept
  real for intersphinx). autodoc still reads TCRi's own signatures/docstrings.
- conf.py: autodoc_class_signature = 'separated' so TCRIModel's constructor
  renders its real __init__ signature instead of the (*args, **kwargs) that a
  mocked scvi base class would otherwise inject.
- conf.py: resolve version from installed metadata, falling back to parsing
  pyproject.toml (correct even without an install).
- .readthedocs.yaml: bump python 3.9 -> 3.12 (pyproject requires >=3.10), drop
  the `pip install .` step (no heavy deps), HTML-only formats.
- docs/requirements.txt: trim to the Sphinx toolchain + numpy/pandas; pin
  sphinx>=7,<9, sphinx-rtd-theme>=2.0, myst-parser>=2.0.
- delete the stale duplicate docs/.readthedocs.yaml (RTD uses the repo-root one).

Verified locally with mocks engaged (sphinx's mock finder shadows the installed
torch/scvi), reproducing the deps-free RTD path: build succeeded, 0 warnings.
Real API renders (joint_distribution_posterior, save_tcri_session, and
TCRIModel.__init__ with n_latent=128); version resolves to 0.1.0.

Closes Notion D6.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@nceglia
nceglia marked this pull request as ready for review June 8, 2026 01:47
@nceglia
nceglia merged commit 65adc08 into main Jun 8, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant