Skip to content

Tests: keep five tests off what the host has installed or downloaded - #13395

Merged
danielhanchen merged 1 commit into
mainfrom
tests-hermetic-1012
Oct 12, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
tests-hermetic-1012

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

Five tests pass in CI but fail on a normal development machine, because they read what the host has installed or downloaded instead of only what the test sets up. Each one was reproduced on main in a Python 3.13 environment matching CI's Repo tests job (CPU torch 2.10, transformers 5.17), with HF_HOME set, models in the HF cache, an editable install and TRL 1.13. Each one passes after this change both on that host and with an empty cache.

No product code changes.

The five

test_media_model_index_accounts (2 tests) and test_openai_catalog (2 tests)

  • These fail with ['Qwen/Qwen-Image-2512', 'Tongyi-MAI/Z-Image', ...] == ['owner-flux'].
  • The media model scan walks every known HF cache home.
  • The suite-wide _hf_cache_is_empty fixture pins the hub cache, but not the other two places the scan reads: a host HF_HOME, which is captured in hf_cache_settings._EXPLICIT_CACHE_ENV at import, and the platform default under XDG_CACHE_HOME or ~/.cache.
  • Any downloaded image model therefore shows up next to the test's private models.
  • Both files now drop the HF_HOME snapshot and point XDG_CACHE_HOME at an empty directory.

test_training_gated_upstream::test_pre_detect_reads_the_repo_the_loader_fetches[...bnb-4bit]

  • The expected repo is the 4-bit mirror. _metadata_lookup_name only reads the 4-bit table when _bitsandbytes_allows_4bit() is true, and that is false wherever unsloth imports on a CPU host.
  • The test now pins it to true. test_pre_detect_follows_the_bitsandbytes_fallback already covers the false branch.

test_sandbox_linux (3 editable-root tests)

  • _fake_editable prepends a fake dist-info, but editable_source_roots() also walks every real distribution. A pip install -e in the environment running the suite then gets granted too.
  • _fake_editable now makes its dist-info the only one importlib.metadata.distributions returns.

tests/test_async_grpo_fast_inference.py::test_trl_vllm_client_reads_this_server

  • On TRL 1.13 this fails with 'VLLMClient' object has no attribute 'load_lora_adapter'. TRL 1.13's async GRPO client only syncs full weights, and Unsloth already refuses fast_inference AsyncGRPO below TRL 1.14 (_check_async_grpo_fast_inference).
  • The test now skips when the client has no LoRA adapter calls.

Testing

Check main this branch
The 4 backend files, host env (HF_HOME set, models cached, editable install) 8 failed 276 passed, 1 skipped
Same 2 media files + test_hf_cache_settings.py, empty XDG_CACHE_HOME, no HF_HOME pass 50 passed
tests/test_async_grpo_fast_inference.py on TRL 1.13 1 failed 14 passed, 1 skipped

- test_media_model_index_accounts, test_openai_catalog: the media scan walks
  every known HF cache home, including a host HF_HOME and the platform
  default under XDG_CACHE_HOME, which the suite-wide empty hub cache does not
  cover. Point both at nothing for these tests.
- test_training_gated_upstream: the 4-bit row of the pre-detect test reads
  the 4-bit table only where bitsandbytes is usable. Pin that answer; the
  fallback has its own test.
- test_sandbox_linux: _fake_editable now makes its dist-info the only one
  editable_source_roots sees, so a pip install -e in the running
  environment is not granted too.
- test_async_grpo_fast_inference: skip the TRL client round trip when
  VLLMClient has no LoRA adapter calls (TRL < 1.14).
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 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-10-12T09:34:16.297359Z 49826c8 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. Bravo.

Reviewed commit: 49826c8517

ℹ️ 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 bf10801 into main Oct 12, 2026
@danielhanchen
danielhanchen deleted the tests-hermetic-1012 branch October 12, 2026 10:01
danielhanchen added a commit that referenced this pull request Oct 18, 2026
…solver checks hold on every host (#14116)

Follow-up to #13265, #13395 and #13701. Each one was rechecked on other
hosts and environments, and these four gaps showed up. Each one
reproduces on `main` and is fixed here. No product code changes.

## Studio `--help` test (#13265)

`COLUMNS=200` is not enough. Typer passes an inherited `TERMINAL_WIDTH`
to Rich as an explicit width. `GITHUB_ACTIONS`, `FORCE_COLOR` or
`PY_COLORS` force terminal mode, whose colour codes split every flag
(`--model` no longer appears as a substring). On staging, the test fails
on `ubuntu-latest` and `macos-15` for exactly this reason. The test now
also sets `TERMINAL_WIDTH=200` and `_TYPER_FORCE_DISABLE_TERMINAL=1`
(both present from Typer 0.19, the floor), and it decodes the child's
output as UTF-8 so a CJK Windows code page cannot break the decode.

| Environment | `main` | Here |
| --- | --- | --- |
| none | pass | pass |
| `TERMINAL_WIDTH=80` | fail | pass |
| `GITHUB_ACTIONS=true` | fail | pass |
| `FORCE_COLOR=1` | fail | pass |
| `PY_COLORS=1` | fail | pass |
| `GITHUB_ACTIONS=true TERM=dumb` | fail | pass |

## Media scan tests (#13395)

`test_media_model_index_accounts.py` and `test_openai_catalog.py`
cleared `HF_HOME` and redirected `XDG_CACHE_HOME`. The scan also reads:
- `hf_default_cache_dir()`, which is `Path.home() / ".cache" /
"huggingface" / "hub"` and ignores `XDG_CACHE_HOME`;
- the LM Studio, Hermes, Ollama and oMLX model folders, including the
system-wide Ollama paths;
- `./models` under the working directory.

So the most common developer setup, an image model in the default HF
cache, still added rows. Both fixtures now point those helpers at the
test's temp dir and run from it. Patching the helpers rather than `HOME`
means the fix works the same on Windows (`USERPROFILE`), macOS and
Linux.

Result with a fake image model planted in each location (33 tests in
each case):

| Case | `main` | Here |
| --- | --- | --- |
| clean | 33 passed | 33 passed |
| model in `~/.cache/huggingface/hub`, `~/.lmstudio/models`,
`OLLAMA_MODELS` | 4 failed | 33 passed |
| pytest run from a folder with `models/<x>/model_index.json` | 4 failed
| 33 passed |

## Installer differential comparer (#13265)

The rule that drops a repeated 100% bar (a winget redraw) compared lines
after sizes were normalised. That made two genuinely different events
collapse into one bar and compare equal:
- a second transfer with no header line, where a partial frame sits
between the two full bars;
- two finished downloads of different sizes.

A repeat is now dropped only when no partial frame was seen since the
kept bar and the raw numbers match. Two new tests cover these cases;
they fail on `main` and pass here. The existing redraw test still passes
(94 passed).

## Node harness resolver (#13701)

#13701 lets a `const` bound to an arrow or function expression be lifted
even when some of its references cannot be. Two shapes could now
load-crash a harness:
- an eagerly evaluated const that calls such a helper on load (`const
TABLE = { v: f() }`, directly or through another helper);
- an immediately invoked `const v = function () { ... }();`, which runs
on load.

The first is now dropped like a const that reads the missing reference
itself. A const that only names the helper (`[g]`) is kept. The second
stays eager.

No current frontend source has either shape: a sweep of every top-level
declaration in `studio/frontend/src` found no harness that loads only on
one side. All 278 tests that use the resolver pass, and the two new
tests fail with the old resolver.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
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