akhaliq HF Staff commited on
Commit
a003073
·
1 Parent(s): c367ef8

fix space hardware

Browse files
Files changed (1) hide show
  1. backend_deploy.py +19 -10
backend_deploy.py CHANGED
@@ -1165,18 +1165,21 @@ def duplicate_space_to_user(
1165
  user_info = api.whoami()
1166
  username = user_info.get("name") or user_info.get("preferred_username") or "user"
1167
 
1168
- # Get original space info to detect hardware
1169
  print(f"[Duplicate] Fetching info for {from_space_id}")
1170
  original_hardware = None
1171
  original_storage = None
 
1172
  try:
1173
  original_space_info = api.space_info(from_space_id)
 
 
1174
  # Get runtime info
1175
  runtime = getattr(original_space_info, 'runtime', None)
1176
  if runtime:
1177
  original_hardware = getattr(runtime, 'hardware', None)
1178
  original_storage = getattr(runtime, 'storage', None)
1179
- print(f"[Duplicate] Original space hardware: {original_hardware}, storage: {original_storage}")
1180
  except Exception as e:
1181
  print(f"[Duplicate] Could not fetch space info: {e}")
1182
 
@@ -1203,14 +1206,20 @@ def duplicate_space_to_user(
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:
 
1165
  user_info = api.whoami()
1166
  username = user_info.get("name") or user_info.get("preferred_username") or "user"
1167
 
1168
+ # Get original space info to detect hardware and SDK
1169
  print(f"[Duplicate] Fetching info for {from_space_id}")
1170
  original_hardware = None
1171
  original_storage = None
1172
+ original_sdk = None
1173
  try:
1174
  original_space_info = api.space_info(from_space_id)
1175
+ # Get SDK type
1176
+ original_sdk = getattr(original_space_info, 'sdk', None)
1177
  # Get runtime info
1178
  runtime = getattr(original_space_info, 'runtime', None)
1179
  if runtime:
1180
  original_hardware = getattr(runtime, 'hardware', None)
1181
  original_storage = getattr(runtime, 'storage', None)
1182
+ print(f"[Duplicate] Original space SDK: {original_sdk}, hardware: {original_hardware}, storage: {original_storage}")
1183
  except Exception as e:
1184
  print(f"[Duplicate] Could not fetch space info: {e}")
1185
 
 
1206
  "exist_ok": True
1207
  }
1208
 
1209
+ # Hardware is only needed for Gradio, Docker, and Streamlit spaces
1210
+ # Static spaces don't have hardware
1211
+ if original_sdk and original_sdk != "static":
1212
+ # For non-static spaces, hardware is required
1213
+ hardware_to_use = original_hardware if original_hardware else "cpu-basic"
1214
+ duplicate_params["hardware"] = hardware_to_use
1215
+ print(f"[Duplicate] Hardware: {hardware_to_use} (SDK: {original_sdk})")
1216
+
1217
+ # Storage is optional
1218
+ if original_storage and original_storage.get('requested'):
1219
+ duplicate_params["storage"] = original_storage.get('requested')
1220
+ print(f"[Duplicate] Storage: {original_storage.get('requested')}")
1221
+ else:
1222
+ print(f"[Duplicate] Static space - no hardware needed (SDK: {original_sdk})")
1223
 
1224
  # Only set private if explicitly requested
1225
  if private: