mlrun.common.schemas.notification#
- class mlrun.common.schemas.notification.Notification(*, kind: NotificationKind, name: str, message: str | None = None, severity: NotificationSeverity | None = None, when: list[str] | None = None, condition: str | None = None, params: dict[str, Any] | None = None, status: NotificationStatus | None = None, sent_time: str | datetime | None = None, secret_params: dict[str, Any] | None = None, reason: str | None = None)[source]#
Bases:
BaseModel
Notification object schema
- Parameters:
kind -- notification implementation kind - slack, webhook, etc.
name -- for logging and identification
message -- message content in the notification
severity -- severity to display in the notification
when -- list of statuses to trigger the notification: 'running', 'completed', 'error'
condition -- optional condition to trigger the notification, a jinja2 expression that can use run data to evaluate if the notification should be sent in addition to the 'when' statuses. e.g.: '{{ run["status"]["results"]["accuracy"] < 0.9}}'
params -- Implementation specific parameters for the notification implementation (e.g. slack webhook url, git repository details, etc.)
secret_params -- secret parameters for the notification implementation, same as params but will be stored in a k8s secret and passed as a secret reference to the implementation.
status -- notification status - pending, sent, error
sent_time -- time the notification was sent
reason -- failure reason if the notification failed to send
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
- condition: str | None#
- kind: NotificationKind#
- message: str | None#
- name: str#
- params: dict[str, Any] | None#
- reason: str | None#
- secret_params: dict[str, Any] | None#
- sent_time: str | datetime | None#
- severity: NotificationSeverity | None#
- status: NotificationStatus | None#
- when: list[str] | None#
- class mlrun.common.schemas.notification.NotificationKind(value)[source]#
Bases:
StrEnum
Currently, the supported notification kinds and their params are as follows:
- console: str = 'console'#
no params, local only
- git: str = 'git'#
token - The git token to use for the git notification.
repo - The git repo to which to send the notification.
issue - The git issue to which to send the notification.
- merge_request -
In GitLab (as opposed to GitHub), merge requests and issues are separate entities. If using merge request, the issue will be ignored, and vice versa.
server - The git server to which to send the notification.
gitlab - (bool) Whether the git server is GitLab or not.
- ipython: str = 'ipython'#
no params, local only
- slack: str = 'slack'#
webhook - The slack webhook to which to send the notification.
- webhook: str = 'webhook'#
url - The webhook url to which to send the notification.
method - The http method to use when sending the notification (GET, POST, PUT, etc…).
headers - (dict) The http headers to send with the notification.
- override_body -
(dict) The body to send with the notification. If not specified, the default body will be a dictionary containing name, message, severity, and a runs list of the completed runs. You can also add the run's details.
Example:
"override_body": {"message":"Run Completed {{ runs }}" # Results would look like: "message": "Run Completed [{'project': 'my-project', 'name': 'my-function', 'host': <run-host>, 'status': {'state': 'completed', 'results': <run-results>}}]"
- verify_ssl -
(bool) Whether SSL certificates are validated during HTTP requests or not. The default is set to True.
- class mlrun.common.schemas.notification.NotificationLimits(value)[source]#
Bases:
Enum
An enumeration.
- max_params_size = 921600#
- class mlrun.common.schemas.notification.NotificationSeverity(value)[source]#
Bases:
StrEnum
An enumeration.
- DEBUG = 'debug'#
- ERROR = 'error'#
- INFO = 'info'#
- VERBOSE = 'verbose'#
- WARNING = 'warning'#
- class mlrun.common.schemas.notification.NotificationStatus(value)[source]#
Bases:
StrEnum
An enumeration.
- ERROR = 'error'#
- PENDING = 'pending'#
- SENT = 'sent'#
- class mlrun.common.schemas.notification.SetNotificationRequest(*, notifications: list[mlrun.common.schemas.notification.Notification] = None)[source]#
Bases:
BaseModel
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
- notifications: list[mlrun.common.schemas.notification.Notification]#