[Tests] Add xet/no_xet pytest markers to filter Xet vs non-Xet tests#4336
Merged
Conversation
Replace the name-based CI filtering (pytest -k 'test_xet or test_buckets or test_copy_files') and ad-hoc @requires("hf_xet") decorators with explicit pytest markers enforced by an autouse fixture: - @pytest.mark.xet: test requires hf_xet => skipped if not installed, Xet force-enabled otherwise. - @pytest.mark.no_xet: test must run without Xet => Xet force-disabled via HF_HUB_DISABLE_XET, even if hf_xet is installed. - unmarked: test must work regardless of Xet => nothing forced; CI runs unmarked tests both with hf_xet ("Xet only" job, -m 'not no_xet') and without (other jobs, -m 'not xet'). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Don't rely on HF_HUB_DISABLE_XET to force-disable Xet for no_xet tests: skip them instead when hf_xet is installed. They run in the CI jobs where hf_xet is uninstalled. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
…no hf_xet" Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 0a8b1c3. Configure here.
Collaborator
Author
|
Not a hurry but I'd like to have this PR merged to use it in #4336 (currently CI is failing but this PR should make it easy to fix it) |
Wauplin
added a commit
that referenced
this pull request
Jun 11, 2026
* [Tests] Add `inference` pytest marker to filter inference tests Replace the name-based CI filtering (pytest -k 'test_inference' / -k 'not test_inference') with an explicit `pytest.mark.inference` marker, mirroring the xet/no_xet markers introduced in #4336. The six `test_inference_*.py` modules are tagged with `pytestmark = pytest.mark.inference`. CI now selects them with `-m inference` (the "Inference only" job) and excludes them elsewhere with `-m 'not inference'`. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * [Tests] Drop endpoints from inference marker + remove redundant comments test_inference_endpoints.py is mocked InferenceEndpoint logic, not an inference test => unmark it so it runs in the regular jobs. Also drop the now-redundant explanatory comments above each `pytestmark`. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
|
This PR has been shipped as part of the v1.19.0 release. |
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.

Summary
Until now, deciding which tests run with/without
hf_xetrelied on two mechanisms that were rarely in sync: name-based CI filtering (pytest -k 'test_xet or test_buckets or test_copy_files') and@requires("hf_xet")decorators. In the end it was hard to know if a test ran at all, and local runs (hf_xet installed) differed from CI. This PR replaces both with explicit markers enforced by a single autouse fixture (xet_modeintests/conftest.py):@pytest.mark.xet→ test requireshf_xet: skipped if not installed, Xet force-enabled otherwise. Whole modules are marked viapytestmark = pytest.mark.xet(xet upload/download/utils, buckets, copy_files).@pytest.mark.no_xet→ test must run withouthf_xet: skipped ifhf_xetis installed. No reliance onHF_HUB_DISABLE_XET— the test only runs in environments wherehf_xetis genuinely absent.CI mapping (ubuntu + windows):
-m 'not no_xet'→xettests + all unmarked tests, with Xet.-m 'not xet'→no_xettests + all unmarked tests, without Xet.So unmarked tests now run twice in CI (once per mode) — that's what actually verifies "works regardless of Xet" instead of just documenting it. Inference tests stay excluded from the Xet job (they have their own job and don't depend on Xet). Marking a test with both markers is a hard failure, and
--strict-markersis enabled so a typo'd marker is a collection error.Decisions taken
no_xettests are skipped whenhf_xetis installed, rather than force-disabling Xet viaHF_HUB_DISABLE_XET. Symmetric withxet(each marker pins the test to one environment) and doesn't depend on the env-var escape hatch behaving correctly everywhere. Locally (hf_xet installed)no_xettests skip; CI covers them in the non-xet jobs.no_xetcurrently has zero uses: I couldn't statically identify tests that break with Xet enabled. The first "Xet only" runs are the discovery mechanism — each failure there is either a missingno_xetmark or a real Xet-path bug. Expect some triage on this PR's CI.hf_xet.Bugs the old
-kfiltering was hidingTestSkillsMarketplaceCLI(tests/test_cli.py) was@requires("hf_xet")but matched no-kpattern → it never ran in any CI job (only collected where hf_xet was uninstalled → always skipped). Now markedxetand running.test_xet_callback_sums_increments_across_concurrent_commits(tests/test_upload_pipeline.py, fully mocked, no hf_xet needed) was routed to the Xet job purely by its name.-k "test_xet"→ buckets/copy_files tests never ran on Windows at all.Sanity check of the fixture (with hf_xet installed locally):
🤖 Generated with Claude Code
Note
Low Risk
Test and CI infrastructure only; no production library behavior changes. CI may surface previously skipped or mis-routed tests when the expanded Xet job runs more suites.
Overview
Replaces ad-hoc Xet test selection (
pytest -kname patterns and@requires("hf_xet")) withxet/no_xetpytest markers and an autousexet_modefixture intests/conftest.pythat skips or force-enables Xet consistently.CI renames matrix jobs to
no hf_xet/with hf_xet, uninstallshf_xetoutside the Xet job, and selects tests with-m 'not xet'vs-m 'not no_xet'(inference still excluded from the Xet job). The Windows Xet job now runs the same marker set as Ubuntu instead of only-k test_xet.Config & docs:
pyproject.tomlregisters markers and--strict-markers; CONTRIBUTING.md documents the three modes and examplepytest -mcommands.Tests: Xet-dependent modules use
pytestmark = pytest.mark.xet(buckets, copy_files, xet upload/download/utils, one CLI class); per-test@requires("hf_xet")decorators are removed.Reviewed by Cursor Bugbot for commit 58ea86e. Bugbot is set up for automated code reviews on this repo. Configure here.