Skip to content

Commit de2dba4

Browse files
committed
Render the README animations on Read the Docs instead of committing them
The GIFs and the animated logo are build artifacts of docs/make_animations.py, and every refresh added megabytes to the history. The Read the Docs build now renders them (ffmpeg from apt, Chrome for kaleido from plotly_get_chrome), in parallel with the notebooks, and the README links to the copies on adaptive.readthedocs.io, like it already does for the logo. make_animations.py renders each animation in its own process, so the slow LearnerND render overlaps the others.
1 parent 50b14da commit de2dba4

8 files changed

Lines changed: 27 additions & 10 deletions

File tree

‎README.md‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ With the same number of points, adaptive sampling resolves features that a homog
2929
<!-- --8<-- [end:summary] -->
3030

3131
<p align="center">
32-
<img src="https://raw.githubusercontent.com/python-adaptive/adaptive/main/docs/_static/readme/learner1d.gif" width="43%" alt="Learner1D: homogeneous grid versus adaptive sampling of a sharp peak">
33-
<img src="https://raw.githubusercontent.com/python-adaptive/adaptive/main/docs/_static/readme/learner2d.gif" width="36%" alt="Learner2D: homogeneous grid versus adaptive triangulation of a ring">
34-
<img src="https://raw.githubusercontent.com/python-adaptive/adaptive/main/docs/_static/readme/learnerND.gif" width="19%" alt="LearnerND: sampled points concentrate on a spherical shell">
32+
<img src="https://adaptive.readthedocs.io/en/latest/_static/readme/learner1d.gif" width="43%" alt="Learner1D: homogeneous grid versus adaptive sampling of a sharp peak">
33+
<img src="https://adaptive.readthedocs.io/en/latest/_static/readme/learner2d.gif" width="36%" alt="Learner2D: homogeneous grid versus adaptive triangulation of a ring">
34+
<img src="https://adaptive.readthedocs.io/en/latest/_static/readme/learnerND.gif" width="19%" alt="LearnerND: sampled points concentrate on a spherical shell">
3535
</p>
3636

3737
## Example
@@ -175,7 +175,9 @@ uv run --group docs python docs/build_notebooks.py
175175
uv run --group docs zensical serve # preview on http://localhost:8000
176176
```
177177

178-
The README animations are made from real learner runs with `uv run --group docs python docs/make_animations.py`, which needs `ffmpeg` and Chrome or Chromium.
178+
The README animations and the animated logo are made from real learner runs by `uv run --group docs python docs/make_animations.py`, which needs `ffmpeg` and Chrome or Chromium (`uv run --group docs plotly_get_chrome` installs one).
179+
They are not version controlled: the Read the Docs build renders them, and the README links to those copies.
180+
Run the script once before `zensical serve` to see them locally.
179181

180182
## Citing
181183

‎docs/.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@
55
*.ipynb
66
# Written by notebooks during execution
77
/notebooks/tutorial/data/
8+
# Rendered by docs/make_animations.py during the docs build
9+
/_static/readme/
10+
/_static/logo_docs.webm

‎docs/_static/logo_docs.webm‎

-348 KB
Binary file not shown.

‎docs/_static/readme/learner1d.gif‎

-91.7 KB
Binary file not shown.

‎docs/_static/readme/learner2d.gif‎

-1.3 MB
Binary file not shown.

‎docs/_static/readme/learnerND.gif‎

-2.34 MB
Binary file not shown.

‎docs/make_animations.py‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
"""Render the README animations and the animated docs logo from real learner runs.
22
33
Writes docs/_static/readme/{learner1d,learner2d,learnerND}.gif and
4-
docs/_static/logo_docs.webm. Needs ffmpeg, and Chrome or Chromium for kaleido
5-
(set BROWSER_PATH if it is not found).
4+
docs/_static/logo_docs.webm, which are not version controlled: the Read the
5+
Docs build renders them and the README links to the copies on Read the Docs.
6+
Needs ffmpeg, and Chrome or Chromium for kaleido (set BROWSER_PATH if it is not
7+
found, or install one with ``plotly_get_chrome``).
68
79
Usage: python docs/make_animations.py [learner1d learner2d learnerND logo]
810
"""
@@ -13,6 +15,7 @@
1315
import sys
1416
import tempfile
1517
from collections.abc import Callable
18+
from concurrent.futures import ProcessPoolExecutor
1619
from pathlib import Path
1720

1821
import matplotlib
@@ -280,11 +283,16 @@ def draw(fig, i):
280283
}
281284

282285

286+
def make(name: str) -> None:
287+
function, target = ANIMATIONS[name]
288+
function(target)
289+
290+
283291
def main(names: list[str]) -> None:
284292
(STATIC / "readme").mkdir(exist_ok=True)
285-
for name in names or ANIMATIONS:
286-
function, target = ANIMATIONS[name]
287-
function(target)
293+
# One process per animation, so the others render while LearnerND runs.
294+
with ProcessPoolExecutor() as pool:
295+
list(pool.map(make, names or ANIMATIONS))
288296

289297

290298
if __name__ == "__main__":

‎readthedocs.yml‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ version: 2
22

33
build:
44
os: ubuntu-24.04
5+
apt_packages:
6+
- ffmpeg # docs/make_animations.py encodes the animations
57
tools:
68
python: "3.13"
79
jobs:
@@ -15,9 +17,11 @@ build:
1517
- uv venv "${READTHEDOCS_VIRTUALENV_PATH}"
1618
install:
1719
- UV_PROJECT_ENVIRONMENT="${READTHEDOCS_VIRTUALENV_PATH}" uv sync --group docs
20+
- UV_PROJECT_ENVIRONMENT="${READTHEDOCS_VIRTUALENV_PATH}" uv run --group docs plotly_get_chrome -y # for kaleido
1821
build:
1922
html:
20-
- UV_PROJECT_ENVIRONMENT="${READTHEDOCS_VIRTUALENV_PATH}" uv run --group docs python docs/build_notebooks.py
23+
# The animations are not version controlled; render them while the notebooks run.
24+
- UV_PROJECT_ENVIRONMENT="${READTHEDOCS_VIRTUALENV_PATH}" uv run --group docs python docs/make_animations.py & UV_PROJECT_ENVIRONMENT="${READTHEDOCS_VIRTUALENV_PATH}" uv run --group docs python docs/build_notebooks.py && wait $!
2125
- UV_PROJECT_ENVIRONMENT="${READTHEDOCS_VIRTUALENV_PATH}" uv run --group docs zensical build --strict
2226
- mkdir -p "${READTHEDOCS_OUTPUT}/html"
2327
- cp -r _site/. "${READTHEDOCS_OUTPUT}/html/"

0 commit comments

Comments
 (0)