Skip to content

Commit 6ddf088

Browse files
mmckyclaude
andauthored
Build matplotlib's font cache before the lectures run (#664)
Builds matplotlib's font cache in a step of its own, after the jax install, in cache.yml, ci.yml and publish.yml: `python -c "import matplotlib.font_manager"`. On a freshly launched runner the first matplotlib import scans the system fonts from a cold disk, which can take over 5 s, and matplotlib then prints "Matplotlib is building the font cache" into the first notebook that imports it. With the cache built first, no page depends on that timing. No package or lecture changes. Merged on @mmcky's "Merge all three" in the infrastructure organiser session. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 030e81f commit 6ddf088

3 files changed

Lines changed: 30 additions & 0 deletions

File tree

‎.github/workflows/cache.yml‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ jobs:
3030
pip install "jax[cuda13]==0.11.0"
3131
pip install numpyro
3232
python scripts/test-jax-install.py
33+
- name: Build matplotlib's font cache
34+
shell: bash -l {0}
35+
run: |
36+
# On a freshly launched runner the first matplotlib import scans the
37+
# system fonts from a cold disk, which can take over 5 s, and
38+
# matplotlib then prints "Matplotlib is building the font cache; this
39+
# may take a moment." into the output of the first notebook that
40+
# imports it. Build the cache here, so no page depends on that timing:
41+
# the font manager builds it on import, with no backend involved.
42+
python -c "import matplotlib.font_manager"
3343
- name: Check nvidia drivers
3444
shell: bash -l {0}
3545
run: |

‎.github/workflows/ci.yml‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ jobs:
3535
pip install "jax[cuda13]==0.11.0"
3636
pip install numpyro
3737
python scripts/test-jax-install.py
38+
- name: Build matplotlib's font cache
39+
shell: bash -l {0}
40+
run: |
41+
# On a freshly launched runner the first matplotlib import scans the
42+
# system fonts from a cold disk, which can take over 5 s, and
43+
# matplotlib then prints "Matplotlib is building the font cache; this
44+
# may take a moment." into the output of the first notebook that
45+
# imports it. Build the cache here, so no page depends on that timing:
46+
# the font manager builds it on import, with no backend involved.
47+
python -c "import matplotlib.font_manager"
3848
- name: Install latex dependencies
3949
run: |
4050
sudo apt-get -qq update

‎.github/workflows/publish.yml‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ jobs:
4747
pip install "jax[cuda13]==0.11.0"
4848
pip install numpyro
4949
python scripts/test-jax-install.py
50+
- name: Build matplotlib's font cache
51+
shell: bash -l {0}
52+
run: |
53+
# On a freshly launched runner the first matplotlib import scans the
54+
# system fonts from a cold disk, which can take over 5 s, and
55+
# matplotlib then prints "Matplotlib is building the font cache; this
56+
# may take a moment." into the output of the first notebook that
57+
# imports it. Build the cache here, so no page depends on that timing:
58+
# the font manager builds it on import, with no backend involved.
59+
python -c "import matplotlib.font_manager"
5060
- name: Check nvidia drivers
5161
shell: bash -l {0}
5262
run: |

0 commit comments

Comments
 (0)