import wandb
from wandb.automations import OnRunMetric, RunEvent, SendNotification
api = wandb.Api()
project = api.project("<my-project>", entity="<my-team>")
# チームの最初のSlackインテグレーションを使用する
slack_hook = next(api.slack_integrations(entity="<my-team>"))
# トリガーイベントを作成する
event = OnRunMetric(
scope=project,
filter=RunEvent.metric("custom-metric") > 10,
)
# イベントに応答するアクションを作成する
action = SendNotification.from_integration(slack_hook)
# automationを作成する
automation = api.create_automation(
event >> action,
name="my-automation",
description="'custom-metric' が10を超えるたびにSlackメッセージを送信する",
)