Notification API#

Notifications#

Example Use Inside of an Adapter Action

from artificial.client.notificationapi.v1.notification_api import Severity

@action()
async def send_notifications(self, actx: ActionExecutionContext) -> None:
    # This example will surface an error to Artificial LabOps System Monitor
    await self.artificial_api.notification_api_v1.raise_notification(actx=actx, message='Info Message', severity=Severity.INFO)
    await self.artificial_api.notification_api_v1.raise_notification(actx=actx, message='Warning Message', severity=Severity.WARNING)
    await self.artificial_api.notification_api_v1.raise_notification(actx=actx, message='Error Message', severity=Severity.ERROR)
class NotificationApi(connections: Connections)#

Provides the ability to raise notifications in the Artificial platform.

async raise_notification(
*,
actx: ActionContext,
message: str,
severity: Severity,
error_code: int = 0,
workflow_id: str = '',
category: str = 'Adapter',
timestamp: datetime = datetime.now(),
) None#
async raise_notification(
*,
action_id: str,
lab_id: str,
job_id: str,
message: str,
severity: Severity,
error_code: int = 0,
workflow_id: str = '',
category: str = 'Adapter',
timestamp: datetime = datetime.now(),
) None

Raises a notification in the Artificial platform.

Parameters:
  • message – The message to be displayed in the notification.

  • severity – The severity of the notification. Error, Warning, or Info.

  • error_code – An error code for the notification, defaults to 0

  • workflow_id – The workflow id, can be found in the @workflow parameter of your workflow, defaults to ‘’

  • category – The category of notification, defaults to ‘Adapter’

  • timestamp – The timestamp of the notification, defaults to datetime.now()

class Severity(value)#

An Enum specifying the Severity of the notification.

Parameters:
  • INFO – Informational notification.

  • WARNING – Warning notification.

  • ERROR – Error notification.

  • UNKNOWN – Unknown severity.