Skip to content

Commit 986cbf4

Browse files
committed
Fix Space stage mapping to use only ZenML standard deployment states
Addresses feedback about using non-standard deployment states. The previous implementation introduced HuggingFace-specific stages (RUNNING_BUILDING, NO_APP_FILE) into ZenML status mapping without properly handling all cases. Changes: - Import and use SpaceStage enum instead of string matching - Map all 10 HuggingFace Space stages to ZenML's 5 standard states: * RUNNING → RUNNING (only when fully provisioned) * BUILDING, RUNNING_BUILDING → PENDING (health endpoint not available) * BUILD_ERROR, RUNTIME_ERROR, CONFIG_ERROR, NO_APP_FILE → ERROR * STOPPED, PAUSED, DELETING → ABSENT (exists but not running) * Unknown stages → UNKNOWN (future-proofing) Key fix: RUNNING_BUILDING now correctly maps to PENDING, not RUNNING, because the health endpoint is not available during this rebuild phase. Follows same pattern as GCP/AWS deployers which map external service states to ZenML's standard deployment lifecycle states.
1 parent d895d03 commit 986cbf4

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

src/zenml/integrations/huggingface/deployers/huggingface_deployer.py

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -495,20 +495,38 @@ def do_get_deployment_state(
495495
api = self._get_hf_api()
496496

497497
try:
498+
from huggingface_hub import SpaceStage
499+
498500
runtime = api.get_space_runtime(repo_id=space_id)
499501

500-
# Map Space stage to deployment status
501-
if runtime.stage == "RUNNING":
502+
# Map HuggingFace Space stages to ZenML standard deployment states
503+
# Only RUNNING means fully provisioned with health endpoint available
504+
if runtime.stage == SpaceStage.RUNNING:
502505
status = DeploymentStatus.RUNNING
506+
# Building/updating states - health endpoint not yet available
503507
elif runtime.stage in [
504-
"BUILDING",
505-
"RUNNING_BUILDING",
506-
"NO_APP_FILE",
508+
SpaceStage.BUILDING,
509+
SpaceStage.RUNNING_BUILDING, # Rebuilding, not fully ready
507510
]:
508511
status = DeploymentStatus.PENDING
509-
else:
510-
# BUILD_ERROR, RUNTIME_ERROR, STOPPED, etc.
512+
# Error states - deployment failed or misconfigured
513+
elif runtime.stage in [
514+
SpaceStage.BUILD_ERROR,
515+
SpaceStage.RUNTIME_ERROR,
516+
SpaceStage.CONFIG_ERROR,
517+
SpaceStage.NO_APP_FILE,
518+
]:
511519
status = DeploymentStatus.ERROR
520+
# Stopped/paused states - deployment exists but not running
521+
elif runtime.stage in [
522+
SpaceStage.STOPPED,
523+
SpaceStage.PAUSED,
524+
SpaceStage.DELETING,
525+
]:
526+
status = DeploymentStatus.ABSENT
527+
else:
528+
# Unknown/future stages
529+
status = DeploymentStatus.UNKNOWN
512530

513531
return DeploymentOperationalState(
514532
status=status,

0 commit comments

Comments
 (0)