[Spaces] Add support for mounted volumes#4018
Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
The Volume-to-dict serialization was duplicated in hf_api.py (set_space_volumes) and _jobs_api.py (_create_job_spec). Added a to_dict() method on the Volume dataclass and updated both call sites to use it. Co-authored-by: Lucain <Wauplin@users.noreply.github.com>
hanouticelina
left a comment
There was a problem hiding this comment.
Thanks!
if possible, it would be nice to have tests for set_space_volumes and delete_space_volumes (usually helpful to catch any server-side changes we might miss )
| typer.Option( | ||
| "--storage", | ||
| help="Space persistent storage tier ('small', 'medium', or 'large'). Only for Spaces.", | ||
| help="(Deprecated, use volumes instead) Space persistent storage tier ('small', 'medium', or 'large'). Only for Spaces.", |
There was a problem hiding this comment.
no CLI replacement yet right?
There was a problem hiding this comment.
no not yet (see https://github.com/huggingface-internal/moon-landing/pull/17543). I'll handle it in a separate PR once it's released server-side
well that's the problem usually with the Space API, we can't test it on staging. At some point in the past we had tests on production but it was unreliable and annoying to run on contributed PRs. So we just have to hope the API will stay stable ^^ |

Related to server-side PR (private link) cc @XciD
This PR adds
set_space_volumesanddelete_space_volumesand updates the Spaces guide.I also took the opportunity to deprecate the persistent storage methods.
Tested manually with https://huggingface.co/spaces/Wauplin/test-volumes
Note
Medium Risk
Introduces new Space runtime/mutation API endpoints (
/volumes) and deprecates existing storage methods/options, which can affect client integrations and backwards compatibility if callers rely onspace_storagebehavior.Overview
Adds first-class mounted volumes support for Spaces via new
HfApi.set_space_volumes(PUT) andHfApi.delete_space_volumes(DELETE), plus exposes mounted volumes onSpaceRuntime.volumesusing a sharedVolumedataclass.Deprecates persistent storage configuration and APIs:
space_storageoncreate_repo/duplicate_repoand therequest_space_storage/delete_space_storagemethods now emit deprecation warnings; CLI docs/option help mark--storageas deprecated and the Spaces guide is updated to document volumes instead of persistent storage.Written by Cursor Bugbot for commit c282531. This will update automatically on new commits. Configure here.