Skip to content

Studio tests: take the hub source baseline when the first test starts, not at collection - #16430

Merged
danielhanchen merged 1 commit into
mainfrom
hub-source-test-baselines-at-first-test
Nov 1, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
hub-source-test-baselines-at-first-test

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

(Python 3.13, g-r) fails on several unrelated PRs (#16413, #16414, #16415):

test_hub_source_env_reset_between_tests.py::test_the_next_test_starts_on_the_source_it_inherited
E   AssertionError: assert 'huggingface' == None
E    +  where 'huggingface' = get('UNSLOTH_STUDIO_HUB_SOURCE')

The test reads _INHERITED = os.environ.get(SOURCE_ENV) at module import, during collection. Collection goes on after that. Any module collected later that imports the app (for example tests/test_liveness_reports_*.py with a module-level from main import ...) runs apply_hub_settings(), and that always writes UNSLOTH_STUDIO_HUB_SOURCE. The conftest fixture _restore_hub_settings_env then correctly restores the value each test started with (huggingface), but the test compares it against the stale collection-time value (None). The fixture is right. The test's baseline is taken too early, and whether it fails depends on which files share the shard. #16236 made it compare against the inherited source, which made it sensitive to this.

Change

The first test records the source env and the "other" source at the moment it starts. That is exactly what the fixture saves and restores. The second test compares against those, and fails with a clear message if it runs without the first one. Nothing else changes.

Testing

  • Repro of the CI failure: run this file plus a later-collected stand-in module that sets UNSLOTH_STUDIO_HUB_SOURCE=huggingface at import, the way the app import does.
    • main: fails with the same assert 'huggingface' == None;
    • this branch: 3 passed.
  • This file alone: 2 passed. With UNSLOTH_STUDIO_HUB_SOURCE=modelscope in the environment (the case Studio tests: compare the hub source restore against the inherited source #16236 was for): 2 passed.
  • Sabotage: with the conftest restore loop disabled, the second test fails again. The test still catches a missing restore.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 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-01T21:06:25.560036Z c8908a9 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. Swish!

Reviewed commit: c8908a914c

ℹ️ 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 4824fcc into main Nov 1, 2026
@danielhanchen
danielhanchen deleted the hub-source-test-baselines-at-first-test branch November 1, 2026 21:17
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