Repository navigation
Generate the numba test module once per module - #930
Merged
Merged
Conversation
Follow-up to #911, which fixed the xdist race by generating into a pytest temporary directory but left the fixture function-scoped, so the Poisson module was regenerated for each of the four parametrized tests. Make the fixture module-scoped, which needs `tmp_path_factory` since the function-scoped `tmp_path` cannot be requested from a module-scoped fixture. Generation drops from 4 runs to 1 when run serially; under xdist the tests scatter across workers, each with its own module scope, so the count there is unchanged. Also drop the now-dead `poisson_numba.py` from .gitignore and the stale reference to `ffcx.main` in the `add_cwd_to_syspath` docstring: since #911 nothing writes generated code into the working directory except CFFI. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #911, picking up the one part of @jhale's review on #923 that #911 did not carry over.
Background
#911 fixed the
pytest-xdistrace intest_numba.pyby generating into a pytest temporary directory and loading viaspec_from_file_location, rather than sharing./poisson_numba.pyacross workers. That is the approach the review on #923 argued for, and it is what landed.That review also used
scope="module"withtmp_path_factory. #911 kept the fixture function-scoped, so the Poisson module is regenerated for each of the four parametrized tests.Change
Make
generate_poissonmodule-scoped. This requirestmp_path_factory, because the function-scopedtmp_pathcannot be requested from a module-scoped fixture. Sharing one module instance is safe: the tests only readform_poisson_a/expression_poisson_0and wrap them, never mutate the module.Two related tidy-ups, both consequences of #911:
poisson_numba.pyfrom.gitignore. Nothing writes it to the source tree any more — the only reference is under the temporary directory.ffcx.mainfrom theadd_cwd_to_syspathdocstring intest/conftest.py. The fixture is still needed and still autouse, but CFFI is now the only thing compiling into CWD.Verification
Fixture setups, via
pytest --setup-show:mainSerial wall clock for
pytest test/test_numba.py: 1.68–2.18s onmain, 1.57–1.68s here.Passes serially, at
-n 5(5 consecutive runs), and when invoked fromtest/rather than the project root.git status --untracked-files=allis clean after all of those, confirming the.gitignoreremoval is safe.test_jit_forms.py -k "laplace or helmholtz"passes, covering the CFFI path through the touchedconftest.py.ruff checkandruff format --checkare clean.Scope note: the saving is serial-only. Under xdist the four tests scatter across workers, each with its own module scope, so the generation still runs four times — I instrumented the fixture and confirmed one run each on gw1–gw4 at
-n 5. Since CI runs-n auto, this helps local runs and not CI.Test-only; no library change.
🤖 Generated with Claude Code