Skip to content

Commit 81411f4

Browse files
authored
Merge pull request #414 from dhellmann/doc-config
add auto-generated config reference documentation
2 parents b6766a2 + cbe03d0 commit 81411f4

File tree

8 files changed

+120
-37
lines changed

8 files changed

+120
-37
lines changed

.readthedocs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ sphinx:
1111
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
1212
python:
1313
install:
14-
- requirements: docs/requirements.txt
14+
- requirements: .[docs]
1515
- method: pip
1616
path: .
1717

docs/conf.py

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,40 @@
99
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
1010

1111
project = "Fromager"
12-
copyright = "2024, Doug Hellmann"
13-
author = "Doug Hellmann"
12+
copyright = "2024, Fromager Authors"
13+
author = "Fromager Authors"
1414
release = metadata.version("fromager")
1515

1616
# -- General configuration ---------------------------------------------------
1717
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
1818

19-
extensions = ["sphinx_click",
20-
"myst_parser"
21-
]
19+
extensions = [
20+
"sphinx_click",
21+
"myst_parser",
22+
"sphinxcontrib.autodoc_pydantic",
23+
]
2224

2325
# Recognized suffixes
2426
source_suffix = [
25-
".rst", ".md",
27+
".rst",
28+
".md",
2629
]
2730

28-
templates_path = ['_templates']
29-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
31+
templates_path = ["_templates"]
32+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
3033

31-
language = 'English'
34+
language = "English"
3235

3336
# -- Options for HTML output -------------------------------------------------
3437
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
3538

36-
html_theme = 'alabaster'
37-
html_static_path = ['_static']
39+
html_theme = "sphinx_rtd_theme"
40+
html_static_path = ["_static"]
41+
42+
suppress_warnings = [
43+
"ref", # autodoc generates a lot of warnings for missing classes that we do not want to include
44+
]
45+
autodoc_pydantic_model_show_json = False
46+
autodoc_pydantic_model_show_config_summary = False
47+
autodoc_pydantic_model_show_validator_summary = False
48+
autodoc_pydantic_model_show_validator_members = False

docs/config-reference.rst

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Configuration Reference
2+
=======================
3+
4+
Per-package Settings
5+
--------------------
6+
7+
Settings for individual packages can be placed in the `overrides/settings/`
8+
directory. Files should be named using the canonicalized name of the package.
9+
For example `flash_attn.yaml`.
10+
11+
.. autopydantic_model:: fromager.packagesettings.PackageSettings
12+
13+
.. autopydantic_model:: fromager.packagesettings.BuildOptions
14+
15+
.. autopydantic_model:: fromager.packagesettings.DownloadSource
16+
17+
.. autopydantic_model:: fromager.packagesettings.ResolverDist
18+
19+
.. autopydantic_model:: fromager.packagesettings.ProjectOverride
20+
21+
Global Settings
22+
---------------
23+
24+
The global changelogs can be placed in `overrides/settings.yaml`.
25+
26+
If you prefer managing a single settings file, per-package settings can also be
27+
kept in this file.
28+
29+
.. autopydantic_model:: fromager.packagesettings.SettingsFile

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ those special cases directly into fromager.
2828

2929
using.md
3030
customization.md
31+
config-reference.rst
3132
cli.rst
3233
develop.md
3334
files.md

docs/requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
sphinx
22
sphinx-click
33
myst-parser
4-
4+
sphinx-rtd-theme
5+
autodoc-pydantic

pyproject.toml

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ requires-python = ">=3.11"
3333
optional-dependencies.build = { file = ["requirements-build.txt"] }
3434
optional-dependencies.mypy = { file = ["requirements-mypy.txt"] }
3535
optional-dependencies.test = { file = ["requirements-test.txt"] }
36+
optional-dependencies.docs = { file = ["docs/requirements.txt"] }
3637
dependencies = { file = ["requirements.txt"] }
3738

3839
[project.urls]
@@ -57,19 +58,11 @@ build_wheel = "fromager.wheels:default_build_wheel"
5758
branch = true
5859
parallel = true
5960
relative_files = true
60-
source = [
61-
"fromager",
62-
"tests/",
63-
]
61+
source = ["fromager", "tests/"]
6462

6563
[tool.coverage.paths]
66-
source = [
67-
"src/fromager",
68-
".tox/**/site-packages/fromager",
69-
]
70-
tests =[
71-
"tests/",
72-
]
64+
source = ["src/fromager", ".tox/**/site-packages/fromager"]
65+
tests = ["tests/"]
7366

7467
[tool.coverage.report]
7568
show_missing = true
@@ -129,10 +122,10 @@ mypy_path = ["src"]
129122
# TODO: remove excludes and silent follow
130123
follow_imports = "silent"
131124
exclude = [
132-
"^src/fromager/sources\\.py$",
133-
"^src/fromager/sdist\\.py$",
134-
"^src/fromager/commands/build\\.py$",
135-
"^src/fromager/settings\\.py$",
125+
"^src/fromager/sources\\.py$",
126+
"^src/fromager/sdist\\.py$",
127+
"^src/fromager/commands/build\\.py$",
128+
"^src/fromager/settings\\.py$",
136129
]
137130

138131
[[tool.mypy.overrides]]

src/fromager/packagesettings.py

Lines changed: 56 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,14 @@ def _validate_envkey(v: typing.Any) -> str:
108108

109109

110110
class ResolverDist(pydantic.BaseModel):
111-
"""Packages resolver dist"""
111+
"""Packages resolver dist
112+
113+
::
114+
115+
sdist_server_url: https://pypi.org/simple/
116+
include_sdists: True
117+
include_wheels: False
118+
"""
112119

113120
model_config = MODEL_CONFIG
114121

@@ -126,6 +133,11 @@ class DownloadSource(pydantic.BaseModel):
126133
"""Package download source
127134
128135
Download package sources from an alternative source, e.g. GitHub release.
136+
137+
::
138+
139+
url: https://example.com/package.tar.gz
140+
destination_filename: ${dist_name}-${version}.tar.gz
129141
"""
130142

131143
model_config = MODEL_CONFIG
@@ -145,12 +157,19 @@ def validate_destination_filename(cls, v):
145157

146158

147159
class BuildOptions(pydantic.BaseModel):
148-
"""Build system options"""
160+
"""Build system options
161+
162+
::
163+
164+
build_ext_parallel: False
165+
cpu_cores_per_job: 1
166+
memory_per_job_gb: 1.0
167+
"""
149168

150169
model_config = MODEL_CONFIG
151170

152171
build_ext_parallel: bool = False
153-
"""Configure build_ext[parallel] in DIST_EXTRA_CONFIG
172+
"""Configure `build_ext[parallel]` in `DIST_EXTRA_CONFIG`
154173
155174
This enables parallel builds of setuptools extensions. Incompatible
156175
with some packages, e.g. numba 0.60.0.
@@ -160,20 +179,31 @@ class BuildOptions(pydantic.BaseModel):
160179
"""Scale parallel jobs by available CPU cores
161180
162181
Examples:
182+
163183
1: as many parallel jobs as CPU logical cores
184+
164185
2: allocate 2 cores per job
165186
"""
166187

167188
memory_per_job_gb: float = Field(default=1.0, ge=0.1)
168189
"""Scale parallel jobs by available virtual memory (without swap)
169190
170191
Examples:
192+
171193
0.5: assume each parallel job requires 512 MB virtual memory
172194
"""
173195

174196

175197
class ProjectOverride(pydantic.BaseModel):
176-
"""Override pyproject.toml settings"""
198+
"""Override pyproject.toml settings
199+
200+
::
201+
202+
update_build_requires:
203+
- setuptools
204+
remove_build_requires:
205+
- ninja
206+
"""
177207

178208
model_config = MODEL_CONFIG
179209

@@ -194,7 +224,16 @@ def validate_update_build_requires(cls, v: list[str]) -> list[str]:
194224

195225

196226
class VariantInfo(pydantic.BaseModel):
197-
"""Variant information for a package"""
227+
"""Variant information for a package
228+
229+
::
230+
231+
env:
232+
VAR1: "value 1"
233+
VAR2: "2.0
234+
wheel_server_url: https://pypi.org/simple/
235+
pre_build: False
236+
"""
198237

199238
model_config = MODEL_CONFIG
200239

@@ -214,7 +253,8 @@ class VariantInfo(pydantic.BaseModel):
214253
class PackageSettings(pydantic.BaseModel):
215254
"""Package settings
216255
217-
yaml::
256+
::
257+
218258
build_dir: python
219259
changelog:
220260
"1.0.1":
@@ -611,7 +651,16 @@ def serialize(self, **kwargs) -> dict[str, typing.Any]:
611651

612652

613653
class SettingsFile(pydantic.BaseModel):
614-
"""Models global settings file `settings.yaml`"""
654+
"""Models global settings file `settings.yaml`
655+
656+
::
657+
658+
changelog:
659+
cuda:
660+
- "2024-09-13: updated CUDA version"
661+
rocm:
662+
- "2024-09-01: updated ROCm version"
663+
"""
615664

616665
model_config = MODEL_CONFIG
617666

tox.ini

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ commands=
8181
[testenv:docs]
8282
description = sphinx docs
8383
basepython = python3.11
84-
deps =
85-
-r docs/requirements.txt
84+
deps = .[docs]
8685
commands =
8786
sphinx-build -M html docs docs/_build -j auto --keep-going {posargs:--fail-on-warning --fresh-env -n}

0 commit comments

Comments
 (0)