Repository navigation
Give the in-venv CLI tests a writable STUDIO_HOME - #9993
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Pushed a second commit. Fixing the pytest step let That file lifts the real if [ -n "$STAGE_ROOT" ]; then
_NODE_PARENT="$RUNTIME_ROOT"
elif [ "$_STUDIO_HOME_IS_CUSTOM" = true ]; thenwhich demoted the anchored line to an
The staging branch had no coverage, which is why nothing caught this when it landed, so it gets two checks. 7 checks pass; deleting the staging branch from |
Eleven tests in unsloth_cli/tests have been failing on main, taking Repo tests (CPU) down with them on every pull request: Error: could not coordinate the Unsloth launch: [Errno 13] Permission denied: '/fake' These tests pin STUDIO_HOME to /fake/studio so sys.prefix.startswith() picks the in-venv branch. /fake was fine while nothing on the path touched the disk. #9890 put _studio_runtime_launch_guard in front of the launch, and studio_runtime_launch_guard does studio_home.mkdir(parents = True) and then locks a file inside it, so an unwritable home now aborts the run before run_server is ever reached. Every one of these failures is the same shape underneath: an empty captured dict, because the flag under test never got as far as being forwarded. The guard is right to create the directory it locks in, and right to refuse the launch when it cannot. What was wrong was a fixture using an unwritable sentinel path for somewhere that is now genuinely written to, so the tests move to tmp_path. The tree keeps its shape, so sys.prefix still sits under STUDIO_HOME and the in-venv branch is still the one exercised: removing the sys.prefix pin still fails these tests. unsloth_cli/tests: 1113 passed, 6 skipped.
Second failure in the same job, from the same pull request, and it only became
visible once the pytest step above stopped failing first.
tests/sh/test_studio_home_node_dir.sh lifts the real STUDIO_HOME and NODE_DIR
logic out of studio/setup.sh by content anchor and runs it against a fake HOME.
Block B started grabbing at:
^if \[ "\$_STUDIO_HOME_IS_CUSTOM" = true \]; then
#9890 added a staging branch above that one:
if [ -n "$STAGE_ROOT" ]; then
_NODE_PARENT="$RUNTIME_ROOT"
elif [ "$_STUDIO_HOME_IS_CUSTOM" = true ]; then
which demoted the anchored line to an elif. The anchor then matched nothing,
block B came out empty, and the file's own extraction guard fired:
FAIL: blockB extraction broke
setup.sh is right here. A background update has to put its Node under the
staging root, not into the home the running Studio is serving from. The anchor
was the problem: it pinned one branch's text in a conditional that was always
going to grow branches.
Block B is now anchored on the NODE_DIR assignment, the line that actually
matters, and walks back to the top-level `if` feeding it. Branches can be added,
reordered or removed without touching this file. Walking back could in principle
land on an unrelated `if`, so the extraction guard now also requires both
_STUDIO_HOME_IS_CUSTOM and STAGE_ROOT to appear in what it captured.
The staging branch was untested, which is why nothing caught this at the time,
so it gets two checks: a stage root sends Node under it, and it outranks a
custom studio home. Both drive UNSLOTH_STUDIO_STAGE_ROOT, the public knob, since
block A derives STAGE_ROOT and RUNTIME_ROOT from it.
7 checks, all passing. Deleting the staging branch from setup.sh fails the file.
Third failure in Repo tests (CPU), and it now runs before the other two, so it is what the job reports on main today while the eleven unsloth_cli failures and the setup.sh anchor wait behind it. test_a_hostile_dtype_field_cannot_reach_an_eval, added by #9777, spawns a fresh interpreter that imports unsloth. On a host with no torch accelerator that dies inside unsloth_zoo: File "unsloth_zoo/device_type.py", line 389, in get_device_type raise NotImplementedError("Unsloth cannot find any torch accelerator? You need a GPU.") so the child never reaches the module under test and the returncode assertion fires. The FutureWarning about HF_HUB_ENABLE_HF_TRANSFER that heads the failure message is unrelated noise from the same stderr. UNSLOTH_ALLOW_CPU=1 is the documented way to import on such a host, and the test was getting it by accident: studio/backend/tests/conftest.py sets it with setdefault at import, so whether the child inherited it depended on whether that conftest had been loaded, which depends on what else the run collected. In this job it had not been. The test copies os.environ and now pins the variable in the copy. It is a test about the dtype field, and it should read the same on a runner with a card and on one without. With no accelerator visible and the variable unset in the parent: 1 failed, 11 passed before, 12 passed after. Unchanged with a card present.
45b227d to
4a2dec4
Compare
|
Third commit, and a third failure in the same job.
so the child never reaches the module under test and the returncode assertion fires. The
With no accelerator visible and the variable unset in the parent: 1 failed, 11 passed before, 12 passed after. Unchanged with a card present. Confirmed failing on main tip |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4a2dec4c29
ℹ️ 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".
| # the run. It was not, in Repo tests (CPU), and the child died before reaching | ||
| # the module under test. Pin it: this test is about the dtype field, and it | ||
| # should read the same on a runner with a card and on one without. | ||
| environment.setdefault("UNSLOTH_ALLOW_CPU", "1") |
There was a problem hiding this comment.
Force the CPU override instead of preserving ambient values
On a driverless runner where UNSLOTH_ALLOW_CPU is already defined as 0, an empty string, or another non-enabled value, setdefault preserves that value and the child still fails during unsloth import before exercising the dtype sanitization. This leaves the test dependent on the invoking environment despite the stated goal of pinning CPU behavior; assign "1" unconditionally in the child environment instead.
Useful? React with 👍 / 👎.
Eleven tests in
unsloth_cli/testsare failing on main right now, which takesRepo tests (CPU)down on every pull request that runs it. They all fail the same way:and then
AssertionError: {}, because the captured kwargs dict is empty: the flag under test never got as far as being forwarded.What is happening
These tests pin
STUDIO_HOMEto/fake/studioand setsys.prefixunderneath it, so thatsys.prefix.startswith(...)picks the in-venv branch of the launch path./fakewas fine for as long as nothing on that path touched the disk.#9890 put
_studio_runtime_launch_guardin front of the launch.unsloth_cli/_studio_runtime_gate.py:219doesstudio_home.mkdir(parents = True, exist_ok = True)and then takes a lock on a file inside it, so an unwritable home now aborts the run beforerun_serveris ever reached.What is fixed
The guard is right to create the directory it locks in, and right to refuse the launch when it cannot. What was wrong was a fixture using an unwritable sentinel path for a location that is now genuinely written to, so the six sites that pin
STUDIO_HOMEmove totmp_path. The three reexec sites that were already passing are untouched.The directory tree keeps its shape, so
sys.prefixstill sits underSTUDIO_HOMEand the in-venv branch is still the one exercised.Checks
unsloth_cli/tests: 1113 passed, 6 skipped.10119c3a6before the change, so this is not specific to any open pull request.sys.prefixpin still fails these tests, so they are not passing vacuously against the out-of-venv branch.