Skip to content

Alerter

zenml.alerter special

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.

base_alerter

Base class for all ZenML alerters.

BaseAlerter (StackComponent, ABC)

Base class for all ZenML alerters.

Source code in zenml/alerter/base_alerter.py
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: BaseAlerterConfig property readonly

Returns the BaseAlerterConfig config.

Returns:

Type Description
BaseAlerterConfig

The configuration.

ask(self, 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[zenml.alerter.base_alerter.BaseAlerterStepParameters]

Optional parameters of this function.

None

Returns:

Type Description
bool

True if operation succeeded and was approved, else False.

Source code in zenml/alerter/base_alerter.py
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(self, message, params=None)

Post a message to a chat service.

Parameters:

Name Type Description Default
message str

Message to be posted.

required
params Optional[zenml.alerter.base_alerter.BaseAlerterStepParameters]

Optional parameters of this function.

None

Returns:

Type Description
bool

True if operation succeeded, else False.

Source code in zenml/alerter/base_alerter.py
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 (StackComponentConfig)

Base config for alerters.

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

BaseAlerterFlavor (Flavor, ABC)

Base class for all ZenML alerter flavors.

Source code in zenml/alerter/base_alerter.py
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: Type[zenml.alerter.base_alerter.BaseAlerterConfig] property readonly

Returns BaseAlerterConfig class.

Returns:

Type Description
Type[zenml.alerter.base_alerter.BaseAlerterConfig]

The BaseAlerterConfig class.

implementation_class: Type[zenml.alerter.base_alerter.BaseAlerter] property readonly

Implementation class.

Returns:

Type Description
Type[zenml.alerter.base_alerter.BaseAlerter]

The implementation class.

type: StackComponentType property readonly

Returns the flavor type.

Returns:

Type Description
StackComponentType

The flavor type.

BaseAlerterStepParameters (BaseModel)

Step parameters definition for all alerters.

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