You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Address comprehensive PR review feedback from @stefannica
Implements all requested improvements from second round of code review:
1. Use specific HfHubHTTPError exception instead of broad Exception
- Check for 404 status code when space_info fails
- Raise DeploymentProvisionError for other HTTP errors
- Provides better error messages and debugging
2. Fail early on environment variable failures
- Changed from logger.warning to raise DeploymentProvisionError
- Deployment will fail immediately if env vars can't be set
- Prevents deployment from starting without required configuration
3. Fail early on secret failures
- Changed from logger.warning to raise DeploymentProvisionError
- Deployment will fail immediately if secrets can't be set
- Critical since secrets are needed for ZenML server connection
4. Fix RUNNING_BUILDING state mapping
- Moved RUNNING_BUILDING from RUNNING to PENDING status
- Only fully running Spaces return RUNNING status
- Health endpoint not available during RUNNING_BUILDING
5. Store external state in metadata for debugging
- Added runtime.stage to DeploymentOperationalState metadata
- Helps with debugging deployment status issues
- Provides visibility into HF Space's internal state
6. Use correct exception type in deprovision
- Changed from DeploymentNotFoundError to DeploymentDeprovisionError
- Signals backend errors vs successful deletion
- Updated docstring to document both exception types
7. Document API behavior with clarifying comments
- add_space_variable/secret are upsert operations (add or update)
- request_space_hardware/storage replace the current tier
- Clarifies behavior for redeployments
8. Handle space_id mismatch corner case
- Detect when space_id changes (renamed deployment/changed prefix)
- Automatically deprovision old Space before creating new one
- Prevents orphaned Spaces from accumulating
All changes improve error handling, debuggability, and resource cleanup.
0 commit comments