update
Browse files512 unmodified lines513514515516517518519520521522523524525526527528529530531532533534535536537538512 unmodified linesprint(f"[Deploy] Template duplication result: {duplicated_repo} (type: {type(duplicated_repo)})")except Exception as e:print(f"[Deploy] Exception during duplicate_space: {type(e).__name__}: {str(e)}")import tracebacktraceback.print_exc()# Handle potential RepoUrl object errorserror_msg = str(e)if "'url'" in error_msg or "RepoUrl" in error_msg:# For RepoUrl object issues, check if the space was actually created successfullyprint(f"[Deploy] RepoUrl error detected, checking if space was created: {error_msg}")try:# Check if space exists by trying to access itspace_info = api.space_info(repo_id)if space_info:print(f"[Deploy] Space exists despite RepoUrl error, continuing with deployment")else:return False, f"Failed to create transformers.js space: {str(e)}", Noneexcept Exception as check_error:return False, f"Failed to create transformers.js space: {str(e)}", Noneelse:# Other errors - report themreturn False, f"Failed to create transformers.js space: {str(e)}", Noneelse:# For updates, verify we can access the existing spacetry:512 unmodified lines513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545512 unmodified linesprint(f"[Deploy] Template duplication result: {duplicated_repo} (type: {type(duplicated_repo)})")except Exception as e:print(f"[Deploy] Exception during duplicate_space: {type(e).__name__}: {str(e)}")# Check if space actually exists (success despite error)space_exists = Falsetry:if api.space_info(repo_id):space_exists = Trueexcept:pass# Handle RepoUrl object "errors"error_msg = str(e)if ("'url'" in error_msg or "RepoUrl" in error_msg) and space_exists:print(f"[Deploy] Space exists despite RepoUrl error, continuing with deployment")else:# Fallback to regular create_repoprint(f"[Deploy] Template duplication failed, attempting fallback to create_repo: {e}")try:api.create_repo(repo_id=repo_id,repo_type="space",space_sdk="static",private=private,exist_ok=True)print(f"[Deploy] Fallback create_repo successful")except Exception as e2:return False, f"Failed to create transformers.js space (both duplication and fallback failed): {str(e2)}", Noneelse:# For updates, verify we can access the existing spacetry:
backend_deploy.py+24-17