[CLI] Add hf spaces duplicate command#4197
Open
davanstrien wants to merge 4 commits intohuggingface:mainfrom
Open
[CLI] Add hf spaces duplicate command#4197davanstrien wants to merge 4 commits intohuggingface:mainfrom
davanstrien wants to merge 4 commits intohuggingface:mainfrom
Conversation
Adds `hf spaces duplicate <from_id> [<to_id>]` so duplicate sits alongside the other `hf spaces` lifecycle/management commands. Wraps `duplicate_repo` with `repo_type` locked to `"space"`; `duplicate_space` is deprecated for v2.0 and not used. Flag set mirrors `hf repos duplicate` minus `--type`. Flag names match `hf spaces settings` (`--hardware`, `--sleep-time`) for namespace consistency. Post-duplicate hints point at `hf spaces info`, `secrets ls`, and `variables ls` so agents can chain through to discover what needs to be set on the new Space. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
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. |
Auto-generated by `python utils/generate_cli_reference.py --update`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- from_id/to_id help text uses lowercase "space" to match other
cli/spaces.py argument conventions.
- exist_ok mirrors `cli/repos.py` wording verbatim ("if repo already
exists").
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Move "Duplicate a Space" from between "Update Space settings" and "Manage Space secrets" to right after "Get Space card". The new order is discovery → create → operate → configure: ls → info → card → duplicate → pause → restart → hardware → settings → secrets → variables. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4197 +/- ##
==========================================
+ Coverage 75.00% 77.14% +2.14%
==========================================
Files 145 170 +25
Lines 13978 19437 +5459
==========================================
+ Hits 10484 14995 +4511
- Misses 3494 4442 +948 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
hf spaces duplicate <from_id> [<to_id>]so duplicate sits alongside the otherhf spaceslifecycle/management commands (pause,restart,settings,secrets,variables,volumes,card,logs,hardware).Design notes
duplicate_repo, notduplicate_space— the latter is@_deprecate_method(version="2.0", ...)athf_api.py:8468.duplicate_repoalready plumbs through all the Space-specific args.hf repos duplicate --type spaceexists? Same rationale ashf spaces card([CLI] Add hf models card and hf datasets card commands #4118): per-type ergonomic wrapper keeps the spaces namespace internally consistent.--hardware,--sleep-timematchhf spaces settings([CLI] Add--hardwareflag tohf spaces settings#4163), not--flavorfromhf repos duplicate. Internal-namespace consistency over cross-namespace mirror.hf repos duplicateminus--type.PublicOpt/ProtectedOptare copy-pasted verbatim fromcli/repos.py:77–91. Could be lifted to_cli_utils.pyfor one source of truth — happy to do that as a small follow-up.Hint chain
After a successful duplicate:
secrets ls/variables lsalready emit hints with theaddsyntax, so an agent chains through without this command pre-fetching anything.Smoke test
Found while testing (separate follow-up)
duplicate_repo(hf_api.py:8466) crashes withKeyError: 'url'whenexist_ok=Truehits a 409 — the swallow path falls through tor.json()["url"]on what's actually an error body. Independent of this PR; will open a separate fix.Note
Medium Risk
Adds a new CLI surface that creates/duplicates Spaces and forwards many runtime/visibility/env options to the Hub API, so mistakes could create misconfigured or incorrectly visible Spaces. Changes are localized to CLI wiring and docs, with no core auth or data-path refactors.
Overview
Adds a new
hf spaces duplicate FROM_ID [TO_ID]command that wrapsHfApi.duplicate_repo(..., repo_type="space"), supporting visibility flags plus Space runtime overrides like--hardware,--sleep-time, deprecated--storage, and optional secrets/vars/volume mounts.Updates the CLI guide and generated CLI reference to document the new command and its flags, and prints post-run hints (including that source secrets/variables are not copied).
Reviewed by Cursor Bugbot for commit 20ba280. Bugbot is set up for automated code reviews on this repo. Configure here.