From 3ea89cbc1ca67ddb3cf73ca83122da7e88b2417d Mon Sep 17 00:00:00 2001 From: quotentiroler Date: Thu, 22 Oct 2026 20:00:34 +0200 Subject: [PATCH] [CI] Only save the pretrained model cache on pushes to main The models are cached with actions/cache, which saves in a post-job step whenever the restore missed. A pull request that misses writes its own branch-scoped copy, and such a copy is visible only to that pull request. doctr-models-pytest-torch-v1 is 5.7 GB against a 10 GB repository limit, so one of those pushes main's entry out and the next run misses again. Every cache the repository holds today is scoped to a single pull request, and there is none on refs/heads/main: 5678838518 refs/pull/2177/merge doctr-models-pytest-torch-v1 437478278 refs/pull/2177/merge setup-python-... 7394980 refs/pull/2177/merge torchinductor-... 3372 refs/pull/2177/merge index-torch-viz-html-... So keep actions/cache on pushes, where its post-job save is what fills main's entry, and restore only on everything else. Twenty jobs across main.yml, references.yml, scripts.yml and demo.yml take this cache from the input's default, so the choice belongs in the action rather than in a save step per workflow. --- .github/actions/setup-env/action.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/actions/setup-env/action.yml b/.github/actions/setup-env/action.yml index ca711d49d7..6b19b65115 100644 --- a/.github/actions/setup-env/action.yml +++ b/.github/actions/setup-env/action.yml @@ -39,8 +39,10 @@ runs: references/requirements.txt demo/pt-requirements.txt + # A pull request only restores: a branch-scoped copy it saved would be + # visible to nothing else and would evict main's, which every run reuses. - name: Cache pretrained models - if: inputs.cache-models == 'true' + if: inputs.cache-models == 'true' && github.event_name == 'push' uses: actions/cache@v6 with: path: | @@ -49,6 +51,15 @@ runs: # Bump the -v1 suffix to invalidate if the set of models a job uses changes key: doctr-models-${{ github.job }}-v1 + - name: Restore pretrained models + if: inputs.cache-models == 'true' && github.event_name != 'push' + uses: actions/cache/restore@v6 + with: + path: | + ~/.cache/doctr + ~/.cache/huggingface + key: doctr-models-${{ github.job }}-v1 + # The default PyPI torch wheel on Linux bundles CUDA (multi-GB) which CI # runners can't use. Pre-installing CPU wheels satisfies the torch # requirement so the package install below won't pull the CUDA build.