Repository navigation
Conversation
A model in the Hugging Face cache is a tree of symlinks into blobs/, which survives neither a copy to an external drive nor a move to another computer, so every reinstall meant downloading again (unslothai#8798). POST /api/hub/export-model copies the newest cached snapshot of a model (or one GGUF variant of it) into <destination>/<org--name> as ordinary files, dereferencing every symlink, with a small unsloth-export.json naming the model, revision and files. POST /api/hub/import-model reads that manifest and writes the files back the way huggingface_hub does: content under blobs/<sha256>, a symlink from snapshots/<revision>/, and a plain copy where symlinks are refused, plus refs/main when the repo is new. The inventory scan then lists the model as downloaded and a load needs no network. A destination inside the cache, a folder without the manifest, an incomplete export, and any manifest entry that would leave its folder are refused with a message that says so. The frontend API client gains the two matching calls; the buttons in the model list are the next commit. Tests cover the dereferenced copy and manifest, the GGUF variant filter, the in-cache refusal, the round trip into a fresh cache (seen by _discover_hf_cache, idempotent on repeat), the missing-manifest refusal and three traversal spellings: 9 passed. ruff and kwarg spacing clean. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_012DRiTpjxAymRtv9p8Xr2kd
Both routes answer the folder they touched, so an API-key caller now gets that path redacted like every other hub inventory route, and the refusal text goes through the same redaction. The routes also never imported asyncio, so every call 500'd; the new route-level test catches both. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_012DRiTpjxAymRtv9p8Xr2kd
|
Live round trip against a real
So the import writes a layout the hub's own tooling reads back as the original download, not just one the Studio inventory accepts. |
|
Second live round trip, this time the GGUF variant path, ending in inference from the imported cache.
So a variant export carries only the quant the picker named, and what the import writes is a cache a real inference server reads without any further step. |
|
Two-machine round trip through the routes on this head (941a778), with two Studio backends on separate homes and separate Machine A ( Machine B (empty cache): Refusals checked: a destination inside the models cache ("pick a folder outside it"), and a source folder without the manifest ("not an Unsloth export"). One fixture note for anyone repeating this: |
Closes #8798.
What
A downloaded model lives in the Hugging Face cache as a tree of symlinks into
blobs/, which survives neither a copy to an external drive nor a move to another machine, so a reinstall or a second computer means downloading everything again. Two routes and their frontend client calls:POST /api/hub/export-model{repo_id, destination, variant?}: copies the newest cached snapshot (or one GGUF variant of it) into<destination>/<org--name>as ordinary files, every symlink dereferenced, beside a smallunsloth-export.jsonnaming the model, revision and files. A single-file GGUF exports as that file.POST /api/hub/import-model{source}: reads that manifest and writes the files back the wayhuggingface_hubdoes, content underblobs/<sha256>, a symlink fromsnapshots/<revision>/, a plain copy where symlinks are refused (Windows without the privilege), andrefs/mainwhen the repo is new. The inventory scan lists the model as downloaded and a load needs no network. Importing the same folder twice is a no-op.Refused with a message that says why: a destination inside the models cache, a folder without the manifest, an export missing a listed file, and any manifest entry that would leave its folder (
../, absolute,a/../..).Deliberately not in this cut: a
.unslotharchive format (a folder is what every other tool already reads; a bundle can wrap the same copy later), and the mmproj/sidecar pairing for a GGUF variant beyond name matching. The buttons in the model list are the next commit on this PR; the API is the contract.Verification
studio/backend/tests/test_portable_model_export.py, against a real cache layout (blobs + snapshot symlinks +refs/main): the dereferenced copy and manifest, the GGUF variant filter, the in-cache refusal, the round trip into a fresh cache (visible to_discover_hf_cache, idempotent on repeat), the missing-manifest refusal, and three traversal spellings: 9 passed. ruff + kwarg spacing clean. Frontend typecheck reports one error intests/desktop-app-menus.test.ts, a file this branch does not touch (it is red on main since e05cdd9);api.tsitself type-checks.🤖 Generated with Claude Code
https://claude.ai/code/session_012DRiTpjxAymRtv9p8Xr2kd