Skip to content

Stop the deps CLI fixture racing another worker for the requirements tree - #11063

Merged
danielhanchen merged 1 commit into
mainfrom
fix/deps-cli-copytree-race
Sep 16, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
fix/deps-cli-copytree-race

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Repo tests (CPU, studio) failed on #11054, which touches three frontend files and cannot reach an installer test:

shutil.Error: [('/home/runner/work/unsloth/unsloth/studio/backend/requirements/.extras-filtered-_30x7ggm.txt',
  ..., "[Errno 2] No such file or directory")]
FAILED tests/studio/install/test_studio_deps_cli.py::test_malformed_core_metadata_is_a_foreign_conflict
1 failed, 9467 passed

Why

install_python_stack._filter_requirements writes its filtered copy beside the source, on purpose:

# Beside the source so relative -r/-c includes resolve; a read-only tree
# (root-owned install, non-root user) falls back rather than aborting.
tmp = tempfile.NamedTemporaryFile(dir = req.parent, prefix = f".{req.stem}-filtered-", ...)

req.parent is studio/backend/requirements, the real tree. test_studio_deps_cli.py copies that same real tree into every fake venv it builds. Under xdist the two run in different workers against one directory, so the generated file was listed by copytree and deleted by the other worker before it was read.

Nothing about the PR under test, and nothing about the product: the beside-the-source write is documented and test_diffusers_pin.py already depends on it. What is wrong is copying another process's scratch.

The fix

The fixture skips .*-filtered-*.txt. Ignored names are never scheduled for copying, so there is no window to lose, and a tree meant to mirror the shipped requirements no longer picks up a temp file either.

Tests

Two, both failing without the ignore:

  • a generated filter file is not copied into the fake venv, and the destination holds only the real requirement
  • the failure as it actually arrived: the file is deleted between the listing and the read

The second was vacuous when I first wrote it. copytree binds copy2 as a default argument at definition, so patching shutil.copy2 does not reach it and the test passed without exercising anything. It passes copy_function explicitly now, and the mutation run confirms both fail with the ignore removed.

…tree

Repo tests (CPU, studio) failed on an unrelated PR with

  shutil.Error: [Errno 2] No such file or directory:
    studio/backend/requirements/.extras-filtered-_30x7ggm.txt

install_python_stack._filter_requirements writes .{stem}-filtered-XXXX.txt
BESIDE its source, deliberately, so relative -r and -c includes resolve. Its
source is the real requirements directory, which this fixture copies into every
fake venv it builds. Under xdist that is two workers on one directory: the name
was there when copytree listed the tree and gone when it read it.

Skip those by name. They are generated scratch, never a shipped requirement, so
a tree meant to mirror the real one should not carry them either.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 16, 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-09-16T03:19:08.162894Z ebc0a3a 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.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 16, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: ebc0a3ab06

ℹ️ 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".

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 16, 2026
@danielhanchen
danielhanchen merged commit 71d85d5 into main Sep 16, 2026
21 of 23 checks passed
@danielhanchen
danielhanchen deleted the fix/deps-cli-copytree-race branch September 16, 2026 04:10
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
…tree (unslothai#11063)

`Repo tests (CPU, studio)` failed on unslothai#11054, which touches three frontend files and cannot reach an installer test:

```
shutil.Error: [('.../studio/backend/requirements/.extras-filtered-_30x7ggm.txt',
  ..., "[Errno 2] No such file or directory")]
FAILED tests/studio/install/test_studio_deps_cli.py::test_malformed_core_metadata_is_a_foreign_conflict
```

`install_python_stack._filter_requirements` writes its filtered copy beside the source on purpose, so relative -r and -c includes resolve, and its source is the real requirements tree this fixture copies into every fake venv. Under xdist that is two workers on one directory: the name was there when copytree listed the tree and gone when it read it.

The fixture skips `.*-filtered-*.txt`. Ignored names are never scheduled for copying, so there is no window to lose, and a tree meant to mirror the shipped requirements no longer picks up another process's scratch either.

Two tests, both failing without the ignore: the generated file is not copied, and the file vanishing between the listing and the read no longer fails the copy. The second was vacuous as first written, since copytree binds copy2 as a default argument and patching shutil.copy2 does not reach it; it passes copy_function explicitly now.

No product file changes.
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