Skip to content

Commit 270f8e2

Browse files
committed
Address PR review feedback
Implements three improvements requested in code review: 1. Add UUID suffix to Space names for uniqueness (@stefannica) - Added first 8 chars of deployment UUID as suffix: {prefix}-{name}-{uuid} - Updated docstring to mention UUID suffix for uniqueness - Follows same pattern as GCP and AWS deployers - Ensures Space names are unique at the project level 2. Add documentation link for secret syntax (@strickvl) - Added link to ZenML secret reference syntax documentation - Links to: https://docs.zenml.io/how-to/project-setup-and-management/interact-with-secrets - Helps users understand how to use {{secret.key}} syntax 3. Replace deprecated update_repo_visibility API (@strickvl) - Changed from update_repo_visibility to update_repo_settings - update_repo_visibility was removed in huggingface_hub v1.0.0.rc7 - New API: api.update_repo_settings(repo_id, private, repo_type) - Maintains same functionality with updated API All changes maintain backward compatibility and improve code quality.
1 parent 1d84d2e commit 270f8e2

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

docs/book/component-guide/deployers/huggingface.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ You need a Hugging Face access token with write permissions to deploy pipelines.
5151
You have two options to provide credentials to the Hugging Face deployer:
5252

5353
* Pass the token directly when registering the deployer using the `--token` parameter
54-
* (recommended) Store the token in a ZenML secret and reference it using secret syntax
54+
* (recommended) Store the token in a ZenML secret and reference it using [secret reference syntax](https://docs.zenml.io/how-to/project-setup-and-management/interact-with-secrets)
5555

5656
### Registering the deployer
5757

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ def _get_space_id(self, deployment: DeploymentResponse) -> str:
175175
176176
Returns:
177177
The Space ID in format 'owner/space-name' where owner is either
178-
the username or organization name.
178+
the username or organization name, and space-name includes a
179+
UUID suffix for uniqueness.
179180
180181
Raises:
181182
DeployerError: If the space name exceeds HF's maximum length.
@@ -190,7 +191,10 @@ def _get_space_id(self, deployment: DeploymentResponse) -> str:
190191
# Sanitize deployment name: alphanumeric, hyphens, underscores only
191192
sanitized = re.sub(r"[^a-zA-Z0-9\-_]", "-", deployment.name).lower()
192193
sanitized = sanitized.strip("-") or "deployment"
193-
space_name = f"{self.config.space_prefix}-{sanitized}"
194+
195+
# Add UUID suffix for uniqueness (first 8 chars of deployment ID)
196+
uuid_suffix = str(deployment.id)[:8]
197+
space_name = f"{self.config.space_prefix}-{sanitized}-{uuid_suffix}"
194198

195199
# Validate length (HF has 96 char limit for repo names)
196200
if len(space_name) > HF_SPACE_NAME_MAX_LENGTH:
@@ -311,7 +315,7 @@ def do_provision_deployment(
311315
f"Updating Space visibility: "
312316
f"{'private' if settings.private else 'public'}"
313317
)
314-
api.update_repo_visibility(
318+
api.update_repo_settings(
315319
repo_id=space_id,
316320
private=settings.private,
317321
repo_type="space",

0 commit comments

Comments
 (0)