Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Stop the pip cache key duplicating itself on every Python patch bump (#9377)

Daniel Hanbcd0f6a785af
diff --git a/.github/actions/pip-cache-restore/action.yml b/.github/actions/pip-cache-restore/action.yml
index 564d7ed560e..33f18260b59 100644
--- a/.github/actions/pip-cache-restore/action.yml
+++ b/.github/actions/pip-cache-restore/action.yml
@@ -63,7 +63,20 @@ runs:
set -euo pipefail
dir="$(python -m pip cache dir)"
echo "dir=$dir" >> "$GITHUB_OUTPUT"
- pyver="$(python -c 'import sys; print("%d.%d.%d" % sys.version_info[:3])')"
+ # Minor, deliberately not patch. Nothing in this repo pins a patch version:
+ # 53 steps ask for '3.12' and the one matrix offers '3.11' and '3.13', so the
+ # patch is whatever the hosted image happens to ship that week. Carrying it in
+ # the key duplicated the WHOLE cache every time GitHub bumped it, which is not
+ # a hypothetical -- measured 2026-08-20, two entries differing in nothing but
+ # 3.12.13 vs 3.12.14 held 10.85 and 11.21 GiB, 44% of the repo's 50 GiB budget
+ # between them, against a total that had climbed back to 99.1% full. The same
+ # pairing showed up in 10 of the 12 pip entries.
+ #
+ # Safe because of WHAT is cached, the same argument the uv cache rests on: pip
+ # stores downloaded wheels, tagged cp312 and so ABI-compatible across every
+ # 3.12.x, behind an HTTP cache addressed by URL and hash. A stale entry cannot
+ # serve wrong content; the worst it can do is miss.
+ pyver="$(python -c 'import sys; print("%d.%d" % sys.version_info[:2])')"
hash="${{ hashFiles(inputs.key-files) }}"
# Empty means the globs matched nothing, which would silently collapse
# every job onto one key. Loud here, where the cause is one line away.
diff --git a/tests/studio/test_cache_budget_discipline.py b/tests/studio/test_cache_budget_discipline.py
index 61689e9fffe..77eea8026c0 100644
--- a/tests/studio/test_cache_budget_discipline.py
+++ b/tests/studio/test_cache_budget_discipline.py
@@ -372,6 +372,35 @@ def test_the_pip_cache_save_action_is_gated_on_the_default_branch():
)
+def test_the_pip_cache_key_carries_the_interpreter_minor_not_its_patch():
+ """
+ A key field more specific than anything the workflows request is pure churn.
+
+ No step in this repo pins a patch version: 53 ask for '3.12' and the one matrix
+ offers '3.11' and '3.13'. So the patch is whatever the hosted image ships that
+ week, and putting it in the key duplicates the ENTIRE cache each time GitHub
+ bumps it. Measured 2026-08-20: two entries alike in everything but 3.12.13 vs
+ 3.12.14 held 10.85 and 11.21 GiB, 44% of the 50 GiB budget between them, with the
+ same pairing in 10 of the 12 pip entries.
+
+ Nothing goes red when that happens. The cache simply sits at 99% full and evicts
+ entries someone else was about to read, which is the failure this whole file is
+ about.
+ """
+ body = (REPO / ".github" / "actions" / "pip-cache-restore" / "action.yml").read_text(
+ encoding = "utf-8"
+ )
+ assert 'print("%d.%d" % sys.version_info[:2])' in body, (
+ "the pip cache key no longer derives the interpreter version as a minor. If it "
+ "went back to sys.version_info[:3], every runner-image patch bump silently "
+ "doubles the largest family in the cache."
+ )
+ assert "sys.version_info[:3]" not in body, (
+ "the pip cache key is back to the full patch version, which duplicated 22.06 "
+ "GiB across two otherwise identical entries the last time it was measured"
+ )
+
+
def _workflows_by_name():
return dict(_workflows())