[CLI] Add spaces lifecycle commands: pause, restart, sleep (#4155)
* [CLI] Add spaces lifecycle commands: pause, restart, sleep
Wraps existing HfApi methods (pause_space, restart_space,
set_space_sleep_time) so they're reachable from the CLI. Includes
--factory-reboot on restart and --seconds on sleep. Bundled as one PR
per Slack discussion (Apr 16/20).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* [CLI] Add Volumes persistence tip to spaces pause/restart
Adds a second `out.hint()` after pause and restart pointing users at
`hf spaces volumes set` for persisting data across container teardown,
plus a matching tip callout in the cli.md guide.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* [CLI] Trim spaces lifecycle tests to match mutation-test pattern
Drop output substring assertions (CLI tests should verify args
plumbing, not output formatting — pause_space/restart_space/
set_space_sleep_time are already tested in the HfApi suite). Add
api_cls.assert_called_once_with(token=None) to match the parity
established by TestRepoDeleteCommand and TestInferenceEndpointsCommands.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* Update src/huggingface_hub/cli/spaces.py
Co-authored-by: célina <hanouticelina@gmail.com>
* Update src/huggingface_hub/cli/spaces.py
Co-authored-by: célina <hanouticelina@gmail.com>
* [CLI] Fix spaces sleep indent + stabilize test
The accepted suggestion landed `return` at 7 spaces, breaking import
of `huggingface_hub.cli.spaces`. Re-indent to 8 and stub the mocked
`sleep_time` in `test_sleep` so it exercises the success path instead
of the new warning branch.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* [CLI] Drop spaces lifecycle mocked tests
These tests only verified that the CLI delegates to the corresponding
HfApi method - effectively typer-wiring coverage with no behavior under
test. Per review feedback, drop them as too verbose for the value.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* [CLI] Drop spaces sleep post-hoc guard
Per follow-up review feedback: empirical testing showed that the server
returns 400 for static, cpu-basic, and zero-a10g spaces, so
hf_raise_for_status throws before the runtime.sleep_time != seconds
check ever runs. The user already gets a clear server-side message;
keeping the post-hoc guard adds no value.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* [CLI] Drop confirmation prompts on spaces pause/restart
Per Wauplin: Space runtime is ephemeral, so pause/restart don't
warrant a confirmation prompt. Drop out.confirm + --yes plumbing
on both commands and remove the corresponding examples from the
guide. Mount-a-Volume hints stay so users know how to persist
data across restarts.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* [CLI] Rename spaces sleep to spaces settings --sleep-time
Per Wauplin: 'hf spaces sleep <id>' reads as a transition action
(== pause), but the underlying API call is a configuration mutation.
Rename to 'hf spaces settings <id> --sleep-time N', mirroring the
existing 'hf repos settings' shape and opening a clean namespace
for future settings flags (--hardware, etc.) without proliferating
top-level verbs.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: célina <hanouticelina@gmail.com>