Skip to content

[Tests] Add inference pytest marker to filter inference tests#4338

Merged
Wauplin merged 3 commits into
mainfrom
inference-marker
Jun 11, 2026
Merged

[Tests] Add inference pytest marker to filter inference tests#4338
Wauplin merged 3 commits into
mainfrom
inference-marker

Conversation

@Wauplin

@Wauplin Wauplin commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

Same treatment as #4336 (xet/no_xet markers), applied to inference tests.

  • Adds a pytest.mark.inference marker (registered in pyproject.toml, enforced by --strict-markers).
  • Tags the inference test modules with pytestmark = pytest.mark.inference.
  • CI now selects them via markers instead of test-name matching:
    • "Inference only" job: -m inference (was -k 'test_inference')
    • "no hf_xet" job: -m 'not xet and not inference' (was -m 'not xet' -k 'not test_inference')
    • "with hf_xet" job: -m 'not no_xet and not inference' (was -m 'not no_xet' -k 'not test_inference')
    • Windows "with hf_xet": -m 'not no_xet and not inference' (was -k 'not test_inference')
  • Documents the marker in CONTRIBUTING.md.

Intentional scope changes vs the old -k 'test_inference'

The old name-based selection matched a few tests that aren't really inference tests. These are now unmarked and run in the regular jobs instead of "Inference only":

  • test_inference_endpoints.py — mocked InferenceEndpoint logic, not an inference (client/providers) test, so it's deliberately left unmarked.
  • test_hf_api.py::...::test_inference_provider_mapping_model_info / ..._list_models — Hub API tests, only matched by name coincidence.
  • test_cli.py::...::test_inference_endpoints_alias — mocked CLI unit test, only matched by name coincidence.

The inference marker therefore tags the 5 real inference modules (client, async client, providers, text generation, types):

$ pytest tests -m inference --collect-only        # 376 tests, the 5 inference modules
$ pytest tests -m "not inference" --collect-only  # everything else, incl. endpoints + the strays above

🤖 Generated with Claude Code


Note

Low Risk
Test orchestration and documentation only; no library or production behavior changes.

Overview
Introduces a registered inference pytest marker (alongside the existing Xet markers) so the Inference suite is selected explicitly instead of by filename.

Five inference modules (test_inference_client, async client, providers, text generation, types) are tagged with pytestmark = pytest.mark.inference. CI switches from -k 'test_inference' / -k 'not test_inference' to -m inference for the dedicated job and not inference on the Xet matrix jobs (Ubuntu and Windows with hf_xet). CONTRIBUTING.md documents how to run inference-only vs non-inference locally.

Compared to the old name filter, test_inference_endpoints.py and a few Hub API / CLI tests that only matched test_inference in the name stay unmarked and run in the regular jobs.

Reviewed by Cursor Bugbot for commit 90c3a4c. Bugbot is set up for automated code reviews on this repo. Configure here.

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>
@bot-ci-comment

Copy link
Copy Markdown

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.

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>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 0f9cfee. Configure here.

"Inference only")
# Run inference tests concurrently
PYTEST="$PYTEST ../tests -k 'test_inference' -n 4"
PYTEST="$PYTEST ../tests -m 'inference' -n 4"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Endpoints module missing inference marker

Medium Severity

The Inference-only CI job now selects tests with -m inference, but test_inference_endpoints.py never got pytestmark = pytest.mark.inference unlike the other five test_inference_*.py modules. Those endpoint tests used to match -k test_inference via the filename and no longer run in the dedicated Inference job.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 0f9cfee. Configure here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on purpose

@Wauplin Wauplin requested a review from hanouticelina June 11, 2026 08:04
@Wauplin Wauplin marked this pull request as ready for review June 11, 2026 08:04

@hanouticelina hanouticelina left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Wauplin Wauplin merged commit 0fb3c93 into main Jun 11, 2026
23 of 26 checks passed
@Wauplin Wauplin deleted the inference-marker branch June 11, 2026 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants