Skip to content

[Spaces] Add support for mounted volumes#4018

Merged
Wauplin merged 5 commits into
mainfrom
spaces-volumes
Apr 1, 2026
Merged

[Spaces] Add support for mounted volumes#4018
Wauplin merged 5 commits into
mainfrom
spaces-volumes

Conversation

@Wauplin
Copy link
Copy Markdown
Contributor

@Wauplin Wauplin commented Apr 1, 2026

Related to server-side PR (private link) cc @XciD

This PR adds set_space_volumes and delete_space_volumes and 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

>>> get_space_runtime("Wauplin/test-volumes").volumes
[Volume(type='bucket', source='Wauplin/test-volumes-storage', mount_path='/data', revision=None, read_only=False, path=None)]

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 on space_storage behavior.

Overview
Adds first-class mounted volumes support for Spaces via new HfApi.set_space_volumes (PUT) and HfApi.delete_space_volumes (DELETE), plus exposes mounted volumes on SpaceRuntime.volumes using a shared Volume dataclass.

Deprecates persistent storage configuration and APIs: space_storage on create_repo/duplicate_repo and the request_space_storage/delete_space_storage methods now emit deprecation warnings; CLI docs/option help mark --storage as 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.

@Wauplin Wauplin requested review from XciD and hanouticelina April 1, 2026 08:39
@Wauplin Wauplin added the highlight PR will be highlighted in the release notes. label Apr 1, 2026
@bot-ci-comment
Copy link
Copy Markdown

bot-ci-comment Bot commented Apr 1, 2026

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.

Comment thread src/huggingface_hub/hf_api.py
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment thread src/huggingface_hub/hf_api.py Outdated
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>
Comment thread src/huggingface_hub/_jobs_api.py Outdated
Copy link
Copy Markdown
Contributor Author

@Wauplin Wauplin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️ (ready for review @hanouticelina)

Copy link
Copy Markdown
Contributor

@hanouticelina hanouticelina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no CLI replacement yet right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread src/huggingface_hub/_space_api.py Outdated
@Wauplin
Copy link
Copy Markdown
Contributor Author

Wauplin commented Apr 1, 2026

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 )

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 ^^

@Wauplin Wauplin requested a review from hanouticelina April 1, 2026 13:52
Copy link
Copy Markdown
Contributor

@hanouticelina hanouticelina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@Wauplin Wauplin merged commit e000c1c into main Apr 1, 2026
22 of 24 checks passed
@Wauplin Wauplin deleted the spaces-volumes branch April 1, 2026 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

highlight PR will be highlighted in the release notes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants