Skip to content

Backend tests: importorskip the unsloth submodule a test uses, not the stubbable package - #16898

Merged
danielhanchen merged 1 commit into
mainfrom
ci-mapper-test-stubbed-unsloth
Nov 6, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
ci-mapper-test-stubbed-unsloth

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

Since #16793 (90e1e733c4), Backend CI (Python 3.13, g-r) fails on unrelated PRs. The last hour's staging runs for #16887, #16886 and #16882 all show the same two tests:

tests/test_load_download_repos_mapper.py:11: in test_unmapped_lora_base_skips_the_remote_mapper
    from unsloth.models import loader_utils
E   ModuleNotFoundError: No module named 'unsloth.models'; 'unsloth' is not a package

What #16793 tests (skipping the remote mapper for unknown LoRA bases) is fine. The two new tests guard with pytest.importorskip("unsloth") and then from unsloth.models import .... In the backend job, several test files stub unsloth at import time as a plain module (_stub_if_missing in test_audio_type_inconclusive.py and others) when the real package cannot be loaded. If one of those runs earlier in the same xdist worker, importorskip("unsloth") returns the stub instead of skipping, and the submodule import fails. Run alone, or in a worker where nothing stubbed it, the tests pass. That is why it depends on how the shard is laid out.

Change

  • studio/backend/tests/test_load_download_repos_mapper.py: importorskip the submodules the tests use (unsloth.models.loader_utils, unsloth.models.loader). With a stub in place they now skip, the same as with no unsloth at all. With the real package they run unchanged.
  • studio/backend/tests/test_backend_tests_stub_heavy_imports.py: test_no_test_importorskips_bare_unsloth fails if any backend test calls pytest.importorskip("unsloth") on the bare package, and pins its own detector both ways. No other backend test does this today. The rule is narrowed to unsloth, since the trl stubs carry the attributes their tests read.

Testing

On studio/backend, with a one-line test file that stubs sys.modules["unsloth"] as a plain module run first (what the shard does):

main this branch
stub first, then test_load_download_repos_mapper.py 2 failed (the error above) 2 skipped
test_load_download_repos_mapper.py alone, real unsloth 2 passed 2 passed
test_backend_tests_stub_heavy_imports.py 6 passed 7 passed

Putting back the original importorskip("unsloth") makes the new guard fail and name test_load_download_repos_mapper.py.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-06T10:41:55.363482Z 2d9723f Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 2d9723fb82

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen
danielhanchen merged commit 2bfb197 into main Nov 6, 2026
@danielhanchen
danielhanchen deleted the ci-mapper-test-stubbed-unsloth branch November 6, 2026 10:46
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.

1 participant