akhaliq HF Staff commited on
Commit
c367ef8
·
1 Parent(s): 9be4ecd
Files changed (1) hide show
  1. backend_deploy.py +11 -7
backend_deploy.py CHANGED
@@ -1196,25 +1196,29 @@ def duplicate_space_to_user(
1196
  print(f"[Duplicate] Duplicating {from_space_id} to {to_space_id}")
1197
 
1198
  # Prepare duplicate_space parameters
1199
- # Per docs: "The new Space will be created in your account and will be in the same
1200
- # state as the original Space (running or paused)"
1201
- # Don't specify hardware/storage - let HuggingFace duplicate automatically
1202
  duplicate_params = {
1203
  "from_id": from_space_id,
1204
  "to_id": to_space_name, # Just the name, not full ID
1205
  "token": token,
1206
  "exist_ok": True
1207
- # Note: Not setting private, hardware, storage, secrets, variables
1208
- # to ensure TRUE duplication (HF copies everything automatically)
1209
  }
1210
 
 
 
 
 
 
 
 
 
 
1211
  # Only set private if explicitly requested
1212
  if private:
1213
  duplicate_params["private"] = private
1214
 
1215
- # Duplicate the space (HuggingFace automatically copies all settings)
1216
  print(f"[Duplicate] Duplicating {from_space_id} to {username}/{to_space_name}")
1217
- print(f"[Duplicate] Letting HuggingFace handle hardware/storage/secrets automatically")
1218
  duplicated_repo = duplicate_space(**duplicate_params)
1219
 
1220
  # Extract space URL
 
1196
  print(f"[Duplicate] Duplicating {from_space_id} to {to_space_id}")
1197
 
1198
  # Prepare duplicate_space parameters
 
 
 
1199
  duplicate_params = {
1200
  "from_id": from_space_id,
1201
  "to_id": to_space_name, # Just the name, not full ID
1202
  "token": token,
1203
  "exist_ok": True
 
 
1204
  }
1205
 
1206
+ # Add hardware and storage if detected (required for GPU spaces)
1207
+ if original_hardware:
1208
+ duplicate_params["hardware"] = original_hardware
1209
+ print(f"[Duplicate] Adding hardware: {original_hardware}")
1210
+
1211
+ if original_storage and original_storage.get('requested'):
1212
+ duplicate_params["storage"] = original_storage.get('requested')
1213
+ print(f"[Duplicate] Adding storage: {original_storage.get('requested')}")
1214
+
1215
  # Only set private if explicitly requested
1216
  if private:
1217
  duplicate_params["private"] = private
1218
 
1219
+ # Duplicate the space
1220
  print(f"[Duplicate] Duplicating {from_space_id} to {username}/{to_space_name}")
1221
+ print(f"[Duplicate] Parameters: {list(duplicate_params.keys())}")
1222
  duplicated_repo = duplicate_space(**duplicate_params)
1223
 
1224
  # Extract space URL