> ## Documentation Index
> Fetch the complete documentation index at: https://wb-21fd5541-dependabot-npm-and-yarn-scripts-css-minify-npm.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Automations の概要

> W&B Automations API を使用して、ML パイプライン内の自動ワークフローを作成・管理します

W\&B Automations API を使用すると、ML パイプライン内のイベントに応じて動作する自動ワークフローをプログラムで作成・管理できます。モデル性能のしきい値やアーティファクトの作成など、特定の条件が満たされたときにトリガーされるアクションを設定します。

<h3 id="core-classes">
  主要なクラス
</h3>

| クラス | 説明 |
| - | - |
| [`Automation`](/ja/models/ref/python/automations/automation/) | 設定を持つ、保存済みのAutomationインスタンスを表します。 |
| [`NewAutomation`](/ja/models/ref/python/automations/newautomation/) | 新しいAutomationを作成するためのビルダークラスです。 |

<h3 id="events-triggers">
  イベント (トリガー)
</h3>

| イベント | 説明 |
| - | - |
| [`OnRunMetric`](/ja/models/ref/python/automations/onrunmetric/) | run のメトリクスが、定義された条件 (しきい値、変化など) を満たしたときにトリガーされます。 |
| [`OnCreateArtifact`](/ja/models/ref/python/automations/oncreateartifact/) | コレクション内に新しいアーティファクトが作成されたときにトリガーされます。 |
| [`OnLinkArtifact`](/ja/models/ref/python/automations/onlinkartifact/) | アーティファクトがレジストリにリンクされたときにトリガーされます。 |
| [`OnAddArtifactAlias`](/ja/models/ref/python/automations/onaddartifactalias/) | アーティファクトにエイリアスが追加されたときにトリガーされます。 |

<h3 id="actions">
  アクション
</h3>

| アクション | 説明 |
| - | - |
| [`SendNotification`](/ja/models/ref/python/automations/sendnotification/) | Slack またはその他の統合されたチャネルを介して通知を送信します。 |
| [`SendWebhook`](/ja/models/ref/python/automations/sendwebhook/) | 外部サービスに HTTP webhook リクエストを送信します。 |
| [`DoNothing`](/ja/models/ref/python/automations/donothing/) | automation の設定をテストするためのプレースホルダーアクションです。 |

<h3 id="filters">
  フィルター
</h3>

| フィルター | 説明 |
| - | - |
| [`MetricThresholdFilter`](/ja/models/ref/python/automations/metricthresholdfilter/) | メトリクス値をしきい値と比較して run をフィルタリングします。 |
| [`MetricChangeFilter`](/ja/models/ref/python/automations/metricchangefilter/) | 時間の経過に伴うメトリクス値の変化に基づいて run をフィルタリングします。 |

<h2 id="common-use-cases">
  一般的なユースケース
</h2>

<h3 id="model-performance-monitoring">
  モデル性能の監視
</h3>

* モデルの精度がしきい値を下回った場合にアラートを送信する
* トレーニング損失が横ばいになった場合にチームへ通知する
* パフォーマンスメトリクスに基づいて再トレーニングのパイプラインをトリガーする

<h3 id="artifact-management">
  Artifacts の管理
</h3>

* 新しいモデルバージョンが作成されたときに通知する
* Artifacts にタグが付いたときにデプロイワークフローを起動する
* データセットが更新されたときに後続処理を自動化する

<h3 id="experiment-tracking">
  実験管理
</h3>

* 失敗したrunやcrashedしたrunのアラートを受け取る
* 長時間実行される実験の完了時に通知を受け取る
* 実験メトリクスの日次サマリーを送信する

<h3 id="integration-workflows">
  インテグレーションのワークフロー
</h3>

* webhook を使って外部トラッキングシステムを更新
* モデルレジストリをデプロイプラットフォームと Sync
* W\&B イベントに応じて CI/CD パイプラインを起動

<h2 id="example-usage">
  使用例
</h2>

次の例では、`custom-metric` というメトリクスが 10 を超えるたびに Slack に通知を送信する automation を作成します。`custom-metric` は、トレーニング中に `wandb.Run.log({"custom-metric": value })` を使ってログすることを想定しています。

```python theme={null}
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メッセージを送信する",
)
```

Automations API の使用方法の詳細については、[Automations Guide](/ja/models/automations/) をご覧ください。
