Skip to content

Alerter

Alerters allow you to send alerts from within your pipeline.

This is useful to immediately get notified when failures happen, and also for general monitoring / reporting.

BaseAlerter

Bases: StackComponent, ABC

Base class for all ZenML alerters.

Source code in src/zenml/alerter/base_alerter.py
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
class BaseAlerter(StackComponent, ABC):
    """Base class for all ZenML alerters."""

    @property
    def config(self) -> BaseAlerterConfig:
        """Returns the `BaseAlerterConfig` config.

        Returns:
            The configuration.
        """
        return cast(BaseAlerterConfig, self._config)

    def post(
        self, message: str, params: Optional[BaseAlerterStepParameters] = None
    ) -> bool:
        """Post a message to a chat service.

        Args:
            message: Message to be posted.
            params: Optional parameters of this function.

        Returns:
            bool: True if operation succeeded, else False.
        """
        return True

    def ask(
        self, question: str, params: Optional[BaseAlerterStepParameters] = None
    ) -> bool:
        """Post a message to a chat service and wait for approval.

        This can be useful to easily get a human in the loop, e.g., when
        deploying models.

        Args:
            question: Question to ask (message to be posted).
            params: Optional parameters of this function.

        Returns:
            bool: True if operation succeeded and was approved, else False.
        """
        return True

config property

Returns the BaseAlerterConfig config.

Returns:

Type Description
BaseAlerterConfig

The configuration.

ask(question, params=None)

Post a message to a chat service and wait for approval.

This can be useful to easily get a human in the loop, e.g., when deploying models.

Parameters:

Name Type Description Default
question str

Question to ask (message to be posted).

required
params Optional[BaseAlerterStepParameters]

Optional parameters of this function.

None

Returns:

Name Type Description
bool bool

True if operation succeeded and was approved, else False.

Source code in src/zenml/alerter/base_alerter.py
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
def ask(
    self, question: str, params: Optional[BaseAlerterStepParameters] = None
) -> bool:
    """Post a message to a chat service and wait for approval.

    This can be useful to easily get a human in the loop, e.g., when
    deploying models.

    Args:
        question: Question to ask (message to be posted).
        params: Optional parameters of this function.

    Returns:
        bool: True if operation succeeded and was approved, else False.
    """
    return True

post(message, params=None)

Post a message to a chat service.

Parameters:

Name Type Description Default
message str

Message to be posted.

required
params Optional[BaseAlerterStepParameters]

Optional parameters of this function.

None

Returns:

Name Type Description
bool bool

True if operation succeeded, else False.

Source code in src/zenml/alerter/base_alerter.py
46
47
48
49
50
51
52
53
54
55
56
57
58
def post(
    self, message: str, params: Optional[BaseAlerterStepParameters] = None
) -> bool:
    """Post a message to a chat service.

    Args:
        message: Message to be posted.
        params: Optional parameters of this function.

    Returns:
        bool: True if operation succeeded, else False.
    """
    return True

BaseAlerterConfig

Bases: StackComponentConfig

Base config for alerters.

Source code in src/zenml/alerter/base_alerter.py
30
31
class BaseAlerterConfig(StackComponentConfig):
    """Base config for alerters."""

BaseAlerterFlavor

Bases: Flavor, ABC

Base class for all ZenML alerter flavors.

Source code in src/zenml/alerter/base_alerter.py
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
class BaseAlerterFlavor(Flavor, ABC):
    """Base class for all ZenML alerter flavors."""

    @property
    def type(self) -> StackComponentType:
        """Returns the flavor type.

        Returns:
            The flavor type.
        """
        return StackComponentType.ALERTER

    @property
    def config_class(self) -> Type[BaseAlerterConfig]:
        """Returns BaseAlerterConfig class.

        Returns:
            The BaseAlerterConfig class.
        """
        return BaseAlerterConfig

    @property
    def implementation_class(self) -> Type[BaseAlerter]:
        """Implementation class.

        Returns:
            The implementation class.
        """
        return BaseAlerter

config_class property

Returns BaseAlerterConfig class.

Returns:

Type Description
Type[BaseAlerterConfig]

The BaseAlerterConfig class.

implementation_class property

Implementation class.

Returns:

Type Description
Type[BaseAlerter]

The implementation class.

type property

Returns the flavor type.

Returns:

Type Description
StackComponentType

The flavor type.

BaseAlerterStepParameters

Bases: BaseModel

Step parameters definition for all alerters.

Source code in src/zenml/alerter/base_alerter.py
26
27
class BaseAlerterStepParameters(BaseModel):
    """Step parameters definition for all alerters."""