|
15 | 15 |
|
16 | 16 | from typing import TYPE_CHECKING, Optional, Type |
17 | 17 |
|
| 18 | +from pydantic import Field |
| 19 | + |
18 | 20 | from zenml.deployers.base_deployer import ( |
19 | 21 | BaseDeployerConfig, |
20 | 22 | BaseDeployerFlavor, |
|
28 | 30 |
|
29 | 31 |
|
30 | 32 | class HuggingFaceDeployerConfig(BaseDeployerConfig): |
31 | | - """Configuration for the Hugging Face deployer. |
32 | | -
|
33 | | - Attributes: |
34 | | - token: Hugging Face API token for authentication. Can be a direct token |
35 | | - value or a reference to a ZenML secret using {{secret_name.key}} |
36 | | - organization: HF organization to deploy to (uses username if not set) |
37 | | - space_hardware: Hardware tier (e.g., 'cpu-basic', 't4-small') |
38 | | - space_storage: Persistent storage tier (e.g., 'small', 'medium', 'large') |
39 | | - space_prefix: Prefix for Space names to organize deployments |
40 | | - """ |
41 | | - |
42 | | - token: Optional[str] = SecretField(default=None) |
43 | | - organization: Optional[str] = None |
44 | | - space_hardware: Optional[str] = None |
45 | | - space_storage: Optional[str] = None |
46 | | - space_prefix: str = "zenml" |
| 33 | + """Configuration for the Hugging Face deployer.""" |
| 34 | + |
| 35 | + token: Optional[str] = SecretField( |
| 36 | + default=None, |
| 37 | + description="Hugging Face API token for authentication with write permissions. " |
| 38 | + "Can reference a ZenML secret using {{secret_name.key}} syntax or provide " |
| 39 | + "the token directly. Create tokens at https://huggingface.co/settings/tokens " |
| 40 | + "with 'write' access enabled. Example: '{{hf_token.token}}' references the " |
| 41 | + "'token' key in the 'hf_token' secret", |
| 42 | + ) |
| 43 | + organization: Optional[str] = Field( |
| 44 | + default=None, |
| 45 | + description="Hugging Face organization name to deploy Spaces under. If not " |
| 46 | + "specified, Spaces are created under the authenticated user's account. " |
| 47 | + "Example: 'zenml' deploys to https://huggingface.co/spaces/zenml/. " |
| 48 | + "Requires organization membership with appropriate permissions", |
| 49 | + ) |
| 50 | + space_hardware: Optional[str] = Field( |
| 51 | + default=None, |
| 52 | + description="Hardware tier for Space execution. Controls compute resources " |
| 53 | + "available to the deployed pipeline. Options: 'cpu-basic' (2 vCPU, 16GB RAM), " |
| 54 | + "'cpu-upgrade' (8 vCPU, 32GB RAM), 't4-small' (4 vCPU, 15GB RAM, NVIDIA T4), " |
| 55 | + "'t4-medium' (8 vCPU, 30GB RAM, NVIDIA T4). See " |
| 56 | + "https://huggingface.co/docs/hub/spaces-gpus for full list. Defaults to " |
| 57 | + "cpu-basic if not specified", |
| 58 | + ) |
| 59 | + space_storage: Optional[str] = Field( |
| 60 | + default=None, |
| 61 | + description="Persistent storage tier for Space data. Determines available disk " |
| 62 | + "space for artifacts and logs. Options: 'small' (20GB), 'medium' (150GB), " |
| 63 | + "'large' (1TB). Storage persists across Space restarts. If not specified, " |
| 64 | + "uses ephemeral storage that resets on restart", |
| 65 | + ) |
| 66 | + space_prefix: str = Field( |
| 67 | + default="zenml", |
| 68 | + description="Prefix for Space names to organize deployments and avoid naming " |
| 69 | + "conflicts. Combined with deployment name to form the full Space ID. " |
| 70 | + "Example: prefix 'zenml' with deployment 'my-pipeline' creates Space " |
| 71 | + "'zenml-my-pipeline'. Maximum combined length is 96 characters", |
| 72 | + ) |
47 | 73 |
|
48 | 74 |
|
49 | 75 | class HuggingFaceDeployerFlavor(BaseDeployerFlavor): |
|
0 commit comments