Skip to content

[CLI] Add hf spaces volumes commands#4109

Merged
Wauplin merged 8 commits intomainfrom
cli-spaces-volumes
Apr 15, 2026
Merged

[CLI] Add hf spaces volumes commands#4109
Wauplin merged 8 commits intomainfrom
cli-spaces-volumes

Conversation

@Wauplin
Copy link
Copy Markdown
Contributor

@Wauplin Wauplin commented Apr 15, 2026

Mentioned by @davanstrien in huggingface/hub-docs#2381 (comment).

Summary

Adds hf spaces volumes ls/set/delete to manage Space volumes from the CLI. Reuses the existing -v/--volume syntax from hf repos create and hf jobs run.

Examples

$ hf spaces volumes ls Wauplin/test-volumes
TYPE    SOURCE                MOUNT_PATH READ_ONLY
------- --------------------- ---------- ---------
model   gpt2                  /data      ✔        
dataset badlogicgames/pi-mono /data2     ✔        
Hint: Use `hf spaces volumes set Wauplin/test-volumes -v hf://<repo_type>/<repo_id>:/<mount_path>` to set volumes for a Space.

$ hf spaces volumes set Wauplin/test-volumes -v hf://models/gpt2:/data-new
✓ Volumes set
  space_id: Wauplin/test-volumes
  volumes: ['hf://models/gpt2:/data-new']
Hint: Use `hf spaces volumes ls Wauplin/test-volumes` to list volumes for a Space.

$ hf spaces volumes ls Wauplin/test-volumes                               
TYPE  SOURCE MOUNT_PATH READ_ONLY
----- ------ ---------- ---------
model gpt2   /data-new  ✔        
Hint: Use `hf spaces volumes set Wauplin/test-volumes -v hf://<repo_type>/<repo_id>:/<mount_path>` to set volumes for a Space.

$ hf spaces volumes delete Wauplin/test-volumes
You are about to remove all volumes from Space 'Wauplin/test-volumes'. Proceed? [y/N]: 
Aborted!

$ hf spaces volumes delete Wauplin/test-volumes --yes
✓ Volumes deleted
  space_id: Wauplin/test-volumes
Hint: Use `hf spaces volumes set Wauplin/test-volumes -v hf://<repo_type>/<repo_id>:/<mount_path>` to set volumes for a Space.

$ hf spaces volumes ls Wauplin/test-volumes                               
No results found.
Hint: Use `hf spaces volumes set Wauplin/test-volumes -v hf://<repo_type>/<repo_id>:/<mount_path>` to set volumes for a Space.

🤖 Generated with Claude Code


Next I think we should also add commands for environment variables, secrets, sleep time and to request new hardware. If we agree on the syntax in this PR, adding the next ones should be straightforward.


Note

Medium Risk
Adds new CLI paths that can modify a Space’s mounted volumes (including destructive replace/delete), so mistakes could impact running Spaces but the change is largely additive and gated behind explicit user actions.

Overview
Adds a new hf spaces volumes CLI group with ls, set, and delete commands to manage Space volume mounts via space_info, set_space_volumes, and delete_space_volumes, including confirmation prompting for deletes.

Introduces Volume.to_hf_handle() to round-trip volumes back into the CLI hf://... syntax for output, and updates docs (manage-spaces.md and generated cli.md) to document the new commands and examples.

Reviewed by Cursor Bugbot for commit 8f2137d. Bugbot is set up for automated code reviews on this repo. Configure here.

Adds a `volumes` subcommand group under `hf spaces` to manage
Space volumes from the CLI, wrapping `set_space_volumes` and
`delete_space_volumes` API methods.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@Wauplin Wauplin added the highlight PR will be highlighted in the release notes. label Apr 15, 2026
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.

Reviewed by Cursor Bugbot for commit b46aa7b. Configure here.

Comment thread src/huggingface_hub/_space_api.py Outdated
@bot-ci-comment
Copy link
Copy Markdown

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.

"hf spaces volumes ls username/my-space",
],
)
def volumes_ls(
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.

this is not the exact equivalent of an API method but it feels necessary / good to have for the CLI

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.

only a small suggestion to re-write the to_hf_handle helper, otherwise looks good to me!

Comment thread src/huggingface_hub/_space_api.py Outdated
@Wauplin Wauplin merged commit 6cace2b into main Apr 15, 2026
20 of 21 checks passed
@Wauplin Wauplin deleted the cli-spaces-volumes branch April 15, 2026 14:35
Copy link
Copy Markdown
Member

@davanstrien davanstrien left a comment

Choose a reason for hiding this comment

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

Thanks!

One small suggestion for a follow-up, the VolumesOpt help text in _cli_utils.py says "Mount a volume", which makes it less clear that you can pass multiple -v flags. Changing to "Mount one or more volumes" could make it obvious to humans and agents?

@davanstrien
Copy link
Copy Markdown
Member

davanstrien commented Apr 15, 2026

Thanks!

One small suggestion for a follow-up, the VolumesOpt help text in _cli_utils.py says "Mount a volume", which makes it less clear that you can pass multiple -v flags. Changing to "Mount one or more volumes" could make it obvious to humans and agents?

#4113

@huggingface-hub-bot
Copy link
Copy Markdown
Contributor

This PR has been shipped as part of the v1.11.0 release.

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