Repository navigation
Docker Studio: keep unsloth-studio-update --ref from leaving Studio dead - #10826
Conversation
|
Confirmed this hits docker/unsloth_studio_update.sh, where the post-update check only imports studio.backend.main and the supervisorctl exit 3 path reports Studio as unmanaged, so --ref can leave it FATAL. Will get this reviewed. |
…led restart, restore on interrupt and after --with-deps
|
Verified here with the branch's helper in two images: one built from #10829 (where The bug is real. On both main's image and the #10829 image, With this branch, before and after the two commits:
Changes: each step in the build subshell fails explicitly (errexit is ignored inside a One limit: Merge note: this branch and #10829 both touch the failure text near the end of the script and the test that pins it; whichever lands second takes this branch's version of both hunks (the header wording from #10829 is untouched here and survives). |
…e path, pin the CUDA stack under --with-deps, honour the npm lockfile and registry
|
A second pass (d537e03) after three independent reviews of my own changes. All of it is in the same two files; 38 tests now.
Rows re-run on the image built from #10829: |
…and never restore twice or cut the cleanup short
…ne updater at a time - an exclusive flock on <src dir>/.src-update.lock for the whole run; a second updater exits 1 and changes nothing. The name shares the scratch prefix so the home linker never links it, and the startup sweep skips it. - the previous source tree and pins stay until the restarted service answers /api/health. A failed restart or a health timeout restores them, starts the previous install again and exits 1. HEALTH_WAIT=0 commits once the restart command succeeds; --no-restart and an unmanaged Studio commit after the import and frontend checks, as before. - restore reinstalls the recorded package identity with --force-reinstall, since pip takes a same-version editable tree as already satisfying the pin. - the oxc validator runtime follows the frontend's lockfile rule: npm ci when a package-lock.json ships with the ref, npm install otherwise, both with the registry override. - the rollback line for an editable install keeps the file:// URI pip recorded; the bare, percent-encoded path is not a valid editable requirement. Tests: lock refusal, restart failure and health timeout put the previous tree back and start it, wait 0 commits, force-reinstall argv, oxc npm ci with and without a lockfile, the editable URI in the rollback file.
|
Pushed d9fc1da on top of the earlier fixes. What changed in
Verification: the 43 unit tests in |
|
@codex security review |
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. |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
…mmitted, and read the install record from the venv not the cwd
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 64bab1afb5
ℹ️ 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".
| # Persistence: the updated packages live in the image's copy of Studio, so they | ||
| # survive `docker restart` but not `docker rm`; pull a new image for a lasting update. | ||
| # Studio's data (accounts, chats, models) is separate: keep it with | ||
| # -v unsloth-studio:/opt/unsloth-studio, which never pins Studio's code. |
There was a problem hiding this comment.
Correct the Studio-home volume persistence guidance
The documented volume mount does pin Studio's code: docker/Dockerfile.studio places both the venv and editable source beneath /opt/unsloth-studio (notably lines 55 and 68-100), and Docker initializes a new named volume from that directory before the volume hides later images' copies. Consequently updates made here survive docker rm, while pulling a new image with the same volume does not provide the claimed lasting code update and can retain an old venv against a new base image; document that this mount persists code or move persistent data to a separate mount path first.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
This wording describes the layout this PR lands on. #10829 merges before it and moves Studio's code out of the home into /opt/unsloth-studio-app, linked into the home at start, so a volume at /opt/unsloth-studio then carries data only and never pins code; the failure text and its test in this PR already assume that layout. On today's main the volume does pin code, which is exactly what #10829 fixes, and the merge order is set so this comment is true from the moment it exists on main.
…k, and stop when the dependency snapshot fails
…illed run's restore can be finished, and say when a restore did not finish
…d the one marker of an uncommitted update
…us one is back, and say when the recovery finished
# Conflicts: # docker/unsloth_studio_update.sh # tests/python/test_docker_update_helpers.py
|
The update now rolls back and exits 1 when the health wait goes unanswered, where it previously exited 0 with the new tree in place; could you confirm the 180 second default is enough on a slow container so a good update is not undone? |
…ck on the restored install; the test site carries its own package metadata
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 04081f503f
ℹ️ 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".
| SWAPPED=1 | ||
| mv -T "$SRC" "$PREV_SRC" |
There was a problem hiding this comment.
Keep the old source active until the service restart
During every --ref update while Studio is running, this rename replaces the path already stored in the process's sys.path/studio.__path__ before the subsequent editable and zoo installation completes. Any request that lazily imports a Studio module during that interval can therefore load new source against the old or partially-mutated environment; with --no-restart, that mixed-version risk persists until the operator restarts manually. Stop the service before changing its import path, or keep the old path active until the new environment is ready to switch atomically.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
The window is the two renames plus the editable reinstall and the import checks, and it is there by design: the fetch, the frontend build and the zoo install all run before the swap so that what remains after it is short, and the default path restarts Studio as soon as the new tree imports. Stopping the service before the swap would turn every update into an outage for that whole tail, and a request that lazily imports during those seconds loads a module from a complete tree the process is about to restart on: the swap is two renames of whole trees, never a half-mutated one. With --no-restart the operator has chosen to restart at a time of their own, and the script says so in its last lines. Not changing this.
…and the container start runs it before Studio comes up
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
…, and unbreak a file that landed on main
…t path took the plain if
unsloth-studio-update --ref main, the command the helper's own--helpshows, kills Studio in the container it was asked to update. Studio never comes back, not even afterdocker restart, and running the helper again says it cannot help. This makes the command work, and makes every failure put the previous install back instead of leaving a dead container.Why it breaks
--refrunspip install git+https://github.com/unslothai/unsloth@main, which replaces the editable install at/opt/unsloth-studio/srcwith a build insite-packages. Only release wheels carry the built frontend, sounsloth studioexits 1 on start:The helper only checked
import studio.backend.main, which still succeeds, so it restarted Studio into that tree. supervisord retries three times and parks the program inFATAL.Two things then make it worse:
supervisor not managing 'studio' here; restart Studio yourself.supervisorctl statusexits 3 for a program that exists but is not running, and the script read that as "not managed".The fix
--refnow installs the same shape the image was built with instead of a wheel: the ref is fetched into a staging tree next tosrc, its frontend is built there with the bundled Node (npm ci, falling back tonpm install, thennpm run build), theoxc-validatorruntime is installed, and only then is the tree swapped in and installed editable. Nothing is touched until the build succeeds.srcto where it really is (readlink -f), so an image that presents it as a link into its own copy of Studio gets the update in that copy rather than a directory written over the link.import studio.backend.mainand astudio/frontend/dist/index.htmlnext to the imported package. The checks run from/, so astudiodirectory in the caller's working directory cannot answer for the installed one.unslothandunsloth_zooare installed before it starts (fromdirect_url.json: an editable path, a git commit, or a released version), puts the old source tree back, reinstalls exactly those, says so, and exits non-zero without restarting.supervisorctl statusexit 3 now counts as managed, so a Studio leftFATALby an earlier update gets restarted instead of a "not managing" message./api/healthand says whether Studio came back.UNSLOTH_STUDIO_UPDATE_HEALTH_WAITbounds the wait (default 180 seconds, 0 skips it).Before and after
Both sides are
unsloth/unsloth:latest; B carries this branch's helper. Same container recipe, no GPU.--ref mainFATAL,/api/healthunreachableRUNNING, health 200--ref main, Playwright--ref mainsite-packagescopy without a frontend/opt/unsloth-studio/src,inference.pymd55ff793a5to0ad553ae(main)studio/frontend/distandoxc-validator/node_modulesafter the updateFATALFATAL--packages unsloth==2025.1.1)FATALRUNNINGbefore and after a restart--ref no-such-ref-xyzRUNNINGThe
--ref mainrun costs about 80 seconds, most of it the frontend build.Verification
tests/python/test_docker_update_helpers.py: 25 passed. The Studio helper's cases run the real script against a fakestudiopackage, with pip, supervisorctl, git and the bundled npm as recording stubs, so the import check, the dist check and the rollback are exercised rather than asserted from source text. The linked-srccase is covered too: the update must land in the tree the link points at, with no staging directory left in the Studio home.main: the dist check, the rollback, theFATALrestart, the two--refbuild cases and the rollback message. Run them from outside the repository: from the repo root,main'simport studio.backend.mainpicks up the working tree'sstudio/and fails for an unrelated reason.Not in this PR
This is the in-container helper only.
unsloth studio updateand the installer are unchanged.--refneeds the bundled Node and network access for the frontend build. Without$UNSLOTH_STUDIO_HOME/node/bin/npmit refuses, rather than installing a tree Studio cannot serve.A release-wheel update still installs into
site-packages, where the wheel carriesfrontend/distbut nooxc-validator/node_modules, so code validation in Data Recipes degrades there as it does for any wheel install. Pre-existing, and separate from this failure.The update still lives in the container's writable layer, so it survives
docker restartand notdocker rm. Pulling a new image is still the lasting path.