diff --git a/.github/workflows/smoke-tests.yml b/.github/workflows/smoke-tests.yml index a679b96d..e3bcf1d1 100644 --- a/.github/workflows/smoke-tests.yml +++ b/.github/workflows/smoke-tests.yml @@ -446,7 +446,7 @@ jobs: id: numba-cache continue-on-error: true with: - path: ${{ github.workspace }}/.numba_cache + path: /tmp/numba_cache key: pyauto-numba-${{ runner.os }}-py${{ steps.keys.outputs.pyfull }}-e${{ env.PYAUTO_CACHE_EPOCH }}-${{ github.run_id }} restore-keys: | pyauto-numba-${{ runner.os }}-py${{ steps.keys.outputs.pyfull }}-e${{ env.PYAUTO_CACHE_EPOCH }}- @@ -459,7 +459,7 @@ jobs: continue-on-error: true env: JAX_PATH: ${{ github.workspace }}/.pyauto_jax_cache - NUMBA_PATH: ${{ github.workspace }}/.numba_cache + NUMBA_PATH: /tmp/numba_cache DS_PATH: workspace/dataset run: | measure() { @@ -638,11 +638,16 @@ jobs: # This runner is the other surface that executes workspace scripts # under JAX, so it needs the same treatment. JAX_TRACEBACK_FILTERING: "off" - # The restored-and-saved directory, not a per-run temporary: the - # runner copies this job env into every script subprocess, so all - # of them share the one numba cache the steps above and below - # carry between runs. - NUMBA_CACHE_DIR: ${{ github.workspace }}/.numba_cache + # The restored-and-saved directory: the runner copies this job env + # into every script subprocess, so all of them share the one numba + # cache the steps above and below carry between runs. It MUST be + # /tmp/numba_cache: every workspace's profile_smoke.yaml sets + # `NUMBA_CACHE_DIR: "/tmp/numba_cache"` as a default, and profile + # defaults override this inherited value (autohands env_config + # apply_profile). While this pointed at a workspace path, numba wrote + # to /tmp while the cache steps restored and saved an empty + # directory, so the numba cache missed on every leg. + NUMBA_CACHE_DIR: /tmp/numba_cache MPLCONFIGDIR: /tmp/matplotlib PYTHONPATH: ${{ github.workspace }}/PyAutoHands/autohands # autonerves defaults this to ~/.cache/pyauto_jax when it is unset; an @@ -702,7 +707,7 @@ jobs: JAX_EXACT: ${{ steps.jax-cache.outputs.cache-hit }} JAX_MB_BEFORE: ${{ steps.cache-before.outputs.jax_mb }} JAX_N_BEFORE: ${{ steps.cache-before.outputs.jax_n }} - NUMBA_PATH: ${{ github.workspace }}/.numba_cache + NUMBA_PATH: /tmp/numba_cache NUMBA_KEY_RESTORED: ${{ steps.numba-cache.outputs.cache-matched-key }} NUMBA_EXACT: ${{ steps.numba-cache.outputs.cache-hit }} NUMBA_MB_BEFORE: ${{ steps.cache-before.outputs.numba_mb }} @@ -878,7 +883,7 @@ jobs: continue-on-error: true uses: actions/cache/save@v4 with: - path: ${{ github.workspace }}/.numba_cache + path: /tmp/numba_cache key: pyauto-numba-${{ runner.os }}-py${{ steps.keys.outputs.pyfull }}-e${{ env.PYAUTO_CACHE_EPOCH }}-${{ github.run_id }} - name: Save simulated datasets diff --git a/tests/test_smoke_tests_wiring.py b/tests/test_smoke_tests_wiring.py index 70ef6550..cae5aebb 100644 --- a/tests/test_smoke_tests_wiring.py +++ b/tests/test_smoke_tests_wiring.py @@ -94,11 +94,13 @@ def test_the_epoch_salt_is_declared_once_at_the_job_level(): def test_the_runner_step_names_both_cache_dirs_and_is_otherwise_untouched(): step = _step(_steps(), RUNNER_STEP) cache_dir = step["env"]["JAX_COMPILATION_CACHE_DIR"] - # numba's directory moved out of /tmp: a per-run temporary is neither - # restorable nor saveable, so it bought nothing across runs. + # numba's directory is the one the workspace profiles write: every + # profile_smoke.yaml defaults NUMBA_CACHE_DIR to /tmp/numba_cache, and a + # profile default overrides this inherited value. The restore and save + # steps name the same absolute path, which actions/cache carries between + # runs like any other. numba_dir = step["env"]["NUMBA_CACHE_DIR"] - assert numba_dir.startswith("${{ github.workspace }}/") - assert not numba_dir.startswith("/tmp") + assert numba_dir == NUMBA_DIR # An explicit path under the workspace: the default is a home-directory # cache the cache steps could not name, and the runner copies this job env # into every script subprocess, so all of them share the one directory. @@ -191,7 +193,7 @@ def test_the_numba_key_is_per_full_python_version_and_carries_the_salt(): step = _step(_steps(), NUMBA_RESTORE_STEP) assert step["uses"].startswith("actions/cache/restore@") assert step["id"] == "numba-cache" - assert step["with"]["path"] == "${{ github.workspace }}/.numba_cache" + assert step["with"]["path"] == NUMBA_DIR key = step["with"]["key"] for component in ("${{ runner.os }}", "${{ steps.keys.outputs.pyfull }}", "${{ env.PYAUTO_CACHE_EPOCH }}", "${{ github.run_id }}"): @@ -203,6 +205,24 @@ def test_the_numba_key_is_per_full_python_version_and_carries_the_salt(): assert fallback.endswith("-e${{ env.PYAUTO_CACHE_EPOCH }}-") +NUMBA_DIR = "/tmp/numba_cache" + + +def test_every_numba_reference_names_the_directory_the_profiles_write(): + """Every workspace profile_smoke.yaml sets NUMBA_CACHE_DIR=/tmp/numba_cache + as a default, and profile defaults override the inherited job env. The + restore, measure, run and save steps must all name that same directory, or + the cache carried between runs is an empty one (it was, on every leg, until + this was pinned).""" + text = (WORKFLOWS / "smoke-tests.yml").read_text() + assert ".numba_cache" not in text + steps = _steps() + assert _step(steps, NUMBA_RESTORE_STEP)["with"]["path"] == NUMBA_DIR + assert _step(steps, NUMBA_SAVE_STEP)["with"]["path"] == NUMBA_DIR + assert f"NUMBA_CACHE_DIR: {NUMBA_DIR}" in text + assert f"NUMBA_PATH: {NUMBA_DIR}" in text + + def test_the_stamp_step_makes_the_numba_fallback_safe(): """numba stamps every entry with its source's (mtime, size), and a fresh `pip install` changes every mtime — so without this the restored cache