Repository navigation
Conversation
Signed-off-by: Jyotirmoy Roy <[email protected]>
|
This PR is backend only for #10872. Libraries, default selection, per-download library_id, free space on the API, scan coverage, and move between libraries are in . UI is not in this PR (settings manager, download destination picker, move in the UI). Happy to do that as a follow-up once this is reviewed. |
Signed-off-by: Jyotirmoy Roy <[email protected]>
Signed-off-by: Jyotirmoy Roy <[email protected]>
|
Owning the model-library side of the inventory for a bit (#8798 export/import is next, then #4660), so I'll build the per-type folder ask from #8568 as the UI follow-up on top of this once it lands rather than in parallel. Two things that would help it along: the seven red legs are mostly the zoo/Core families and the studio pin that were red on main itself around Sep 18–25, so a rebase onto current main should clear most of them and show what is really yours; and a line in the description on how the default library interacts with an existing Custom Folder pointing at the same drive (does discovery dedupe, or does the model list show it twice) is the first question a reviewer here will ask. |
|
Thanks for the PR - we won't be adding this at this time |
What does this PR do?
Multi-drive model libraries for Unsloth Studio: register cache-home folders on any drive, keep one default (always the active HF cache), pick a download destination per job, and move a cached model between libraries without re-downloading.
This PR is backend-only for #10872. Studio UI (settings manager, download “Download to” picker, move in the UI) is a follow-up.
Linked issue
Backend for #10872 (UI follow-up).
Summary
Backend changes
Libraries storage (
hub/storage/model_libraries.py)studio.db(model_librariestable, additive DDL)._validate_cache_home: rejects drive roots, denied system paths, credential/config folders, uncreatable parents; reports free/writable status per volume. Windows-onlyCOLLATE NOCASEdedupe mirrorsscan_folders. Removing the default is refused.is_defaultis derived (path == active cache home), never stored, so exactly one default always exists and promotion is justset_hf_cache_home.Scan unification (
utils/hf_cache_settings.py)known_hf_cache_homes()now includesmodel_library_homes(), so inventory scans, the model list, delete scoping, the folder browser and tool confinement span every library with no further wiring.Downloads (
hub/schemas/downloads.py,hub/services/models/downloads.py)library_idonDownloadModelRequest("default"| row id).library_id= active cache = current behavior.Move (
hub/services/models/libraries.py)POST /api/hub/libraries/moverelocates the cached hub/ repo dir across libraries (blobs + snapshots travel with it; no re-download).variantis rejected with 400.noteexplaining that.Routes (
hub/routes/inventory.py)GET/POST /api/hub/librariesDELETE /api/hub/libraries/{library_id}POST /api/hub/libraries/{library_id}/defaultPOST /api/hub/libraries/moveMigration: none — the default library is the existing Models folder; no backfill.
Behavior changes
library_idis omitted.Security
Testing
hub/tests/test_model_libraries.py: validate/register/dedupe, Windows NOCASE, default derivation + dedupe, refuse-remove-default, promote, scan unification,library_cache_paths+ 404s, move success / no-op / missing model, variant reject (400), XET left in place +note, failed-move cleanup, 409 while download/load active, non-default library env + manifest scoping, library probe log, HTTP mappings.test_hf_cache_settings,test_download_lifecycle,test_download_manifest_scoping,test_model_services(pre-existing failures onmainonly — Windows symlink-privilege andntpathdecode). Refactor guard: inventory, golden outputs and patch targets match.already_in_libraryno-op.Test plan
pytest hub/tests/test_model_libraries.pypytest tests/test_hf_cache_settings.py hub/tests/test_download_lifecycle.pypython tests/tools/refactor_guard.pyRollout
Docker / packaging checks