docs: make ReadTheDocs build deps-free and reliable (D6) - #25
Merged
Conversation
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>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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.py—autodoc_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/pandaskept real so intersphinx resolves their types.conf.py—autodoc_class_signature = 'separated': without it,TCRIModelrenders asTCRIModel(*args, **kwargs)because the mocked scviBaseModelClassinjects 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 parsingpyproject.toml(so the version is right even without an install)..readthedocs.yaml: Python3.9 → 3.12(pyproject requires>=3.10); drop thepip install .step; HTML-only.docs/requirements.txt: trimmed to the Sphinx toolchain + numpy/pandas; pinnedsphinx>=7,<9,sphinx-rtd-theme>=2.0,myst-parser>=2.0.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.joint_distribution_posterior,save_tcri_session, andTCRIModel.__init__(adata, n_latent=128, …). Version resolves to0.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