Skip to content

Secret

Initialization of the ZenML Secret module.

A ZenML Secret is a grouping of key-value pairs. These are accessed and administered via the ZenML Secret Store.

BaseSecretSchema

Bases: BaseModel

Base class for all Secret Schemas.

Source code in src/zenml/secret/base_secret.py
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
class BaseSecretSchema(BaseModel):
    """Base class for all Secret Schemas."""

    @classmethod
    def get_schema_keys(cls) -> List[str]:
        """Get all attributes that are part of the schema.

        These schema keys can be used to define all required key-value pairs of
        a secret schema.

        Returns:
            A list of all attribute names that are part of the schema.
        """
        return list(cls.model_fields.keys())

    def get_values(self) -> Dict[str, Any]:
        """Get all values of the secret schema.

        Returns:
            A dictionary of all attribute names and their corresponding values.
        """
        return self.model_dump(exclude_none=True)

    model_config = ConfigDict(
        # validate attribute assignments
        validate_assignment=True,
        # report extra attributes as validation failures
        extra="forbid",
    )

get_schema_keys() classmethod

Get all attributes that are part of the schema.

These schema keys can be used to define all required key-value pairs of a secret schema.

Returns:

Type Description
List[str]

A list of all attribute names that are part of the schema.

Source code in src/zenml/secret/base_secret.py
24
25
26
27
28
29
30
31
32
33
34
@classmethod
def get_schema_keys(cls) -> List[str]:
    """Get all attributes that are part of the schema.

    These schema keys can be used to define all required key-value pairs of
    a secret schema.

    Returns:
        A list of all attribute names that are part of the schema.
    """
    return list(cls.model_fields.keys())

get_values()

Get all values of the secret schema.

Returns:

Type Description
Dict[str, Any]

A dictionary of all attribute names and their corresponding values.

Source code in src/zenml/secret/base_secret.py
36
37
38
39
40
41
42
def get_values(self) -> Dict[str, Any]:
    """Get all values of the secret schema.

    Returns:
        A dictionary of all attribute names and their corresponding values.
    """
    return self.model_dump(exclude_none=True)