fix(tests): skip test_model_loading when the [flax] extra is missing - #484
fix(tests): skip test_model_loading when the [flax] extra is missing#484LngelKyo wants to merge 2 commits into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
tests/test_model_loading.py imports the flax backend at module top level, so on a torch-only install (`pip install .[torch]`) pytest fails at collection time and the 59 unrelated tests are lost with it (reported in google-research#480). Gate the module on the optional flax dependencies instead: einshape and flax are both extras, so a plain install legitimately lacks them. After this change the rest of the suite reports 59 passed, 1 skipped instead of a collection error.
75e05aa to
9f48a3c
Compare
sylvesterkaczmarek
left a comment
There was a problem hiding this comment.
The module-level pytest.importorskip skips this entire file when Flax/einshape is absent, but three of the four tests are PyTorch-only. On the minimal install this PR is targeting, that removes all Torch model-loading and torch.compile coverage too. Could the skip be scoped to test_flax_model_init_kwargs (or the imports split) so the Torch tests still run?
…ading tests still run The module-level pytest.importorskip calls skipped the whole file when flax/einshape were absent, but three of the four tests are PyTorch-only: on a minimal install that removed all Torch model-loading and torch.compile coverage too (raised by sylvesterkaczmarek in google-research#484). Move the flax import and both importorskip calls into test_flax_model_init_kwargs, the only test that needs them. A minimal install now runs 3 passed + 1 skipped (with an actionable skip reason); a [flax] install runs all 4.
|
Right, the module-level skip took the three torch tests with it. The flax import and both importorskip calls now live inside test_flax_model_init_kwargs, so a minimal install runs the torch model-loading and torch.compile tests (3 passed, 1 skipped) and a [flax] install runs all four. Verified both ways; commands and output in the PR description. |
|
ر #488 |
tests/test_model_loading.pyimports the flax backend at module top level:On a torch-only install (
pip install ".[torch]"),flaxandeinshapeareabsent (both are optional extras), so pytest fails at collection time and the
59 unrelated tests are lost with it (raised by sylvesterkaczmarek in review: three
of the four tests in this file are PyTorch-only, so a module-level skip also
removed the Torch model-loading and
torch.compilecoverage).Gate only the one flax test on its optional dependencies. The flax import and both
importorskipcalls now live insidetest_flax_model_init_kwargs.a. minimal install (no flax extra):
b. with the [flax] extra installed:
Full suite (
PYTHONPATH=src python -m pytest tests -q): 63 passed. The skipreason names the missing extra, so a user who actually wants the flax test gets
an actionable message. Related: #480.