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 = api.create_automation(
event >> action,
name="my-automation",
description="'custom-metric'이 10을 초과할 때마다 Slack 메시지 전송.",
)