* tests/studio/install: parallel UNSLOTH_STUDIO_HOME smoke test
Adds tests/studio/install/smoke_test_parallel_studio_home.py to lock in
the install-time and runtime isolation guarantees added by #5190.
The runner spawns N concurrent install.sh --local --no-torch jobs, each
with its own UNSLOTH_STUDIO_HOME and a redirected HOME, then launches N
backends on dynamically allocated ports and cross-checks every install
against its running process. Asserts:
install-time
- all N installs exit 0
- per-install bin / share / llama.cpp / unsloth_studio venv tree
- shim symlink resolves into its own venv, no cross-resolution
- share/studio_install_id is unique across the N installs
- share/studio.conf exports UNSLOTH_EXE / UNSLOTH_STUDIO_HOME /
UNSLOTH_LLAMA_CPP_PATH all pointing inside the install
- share/launch-studio.sh has @@DATA_DIR@@ substituted to its own
share/ at install time
- the redirected HOME stays clean: no rc-file append, no
.desktop file, no Studio.app stub, no shared marker
runtime
- /api/health returns 200 with status healthy and chat_only true
- /api/health.studio_root_id matches share/studio_install_id
(runtime resolver agrees with install-time write)
- studio_root_id values are pairwise distinct
- GET / and GET /api/chat return 200 on each backend
- /proc/PID/exe is the install's own venv python
Standalone smoke runner, not pytest collected. Default --n 4 finishes
in about 60 seconds on a warm uv cache; artifacts are removed on PASS
unless --keep is passed and kept on FAIL or ERROR for inspection.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* tests/studio/install: portability + log fd cleanup in parallel smoke
Two cleanups on the parallel UNSLOTH_STUDIO_HOME smoke runner:
- Skip the /proc/PID/exe runtime cross-resolution check on platforms
without /proc (macOS, BSD, Windows). install.sh supports macOS, so
the smoke should not hard-error there. The install-time symlink,
studio.conf and launch-studio.sh assertions already pin the venv
python target statically; the proc check stays as a Linux-only
redundant cross-resolution catch and now returns None cleanly on
other platforms instead of raising.
- Wrap the per-backend log file in a with-statement so its parent fd
is released deterministically at function return. The child still
holds its own dup'd fd via Popen, so logging continues unchanged.
The prior code relied on local-scope GC and was fine in CPython,
but the with form makes the intent explicit.
Smoke still passes locally: 4 parallel installs in 42s, 4 backends
healthy in 5s, all install + runtime invariants hold.
* tests/studio/install: pin UNSLOTH_STUDIO_HOME on backend launch
The launch step copied os.environ unchanged except for HOME. If the
parent shell already exports UNSLOTH_STUDIO_HOME or STUDIO_HOME (for
example, when the developer is sourcing studio.conf from an existing
install), every backend inherits it and the Studio resolver prioritises
those env vars over the per-label sys.prefix inference. The runtime
invariant block then reports the caller's install_id on every port
instead of the per-label one, and the test fails spuriously rather
than testing the right roots.
Pin UNSLOTH_STUDIO_HOME to the per-label studio_home and pop the
STUDIO_HOME alias for each launch, mirroring what _run_one_install
already does for the install step.
Verified by running the smoke with UNSLOTH_STUDIO_HOME=/nonexistent
and STUDIO_HOME=/also-bogus exported in the parent env: PASS, all four
backends report their own install_id rather than the parent value.
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>