> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coreweave.com/llms.txt
> Use this file to discover all available pages before exploring further.

# run を削除する

> W&B アプリまたは Public API を使用して W&B プロジェクトから run を削除し、削除した run のデータがストレージからどのように削除されるかを確認します。

<h2 id="delete-runs">
  run を削除する
</h2>

W\&B アプリまたは Python API を使用して project から run を削除します。

<Tabs>
  <Tab title="W&B アプリ" value="ui">
    1. 削除する run が含まれる project にアクセスします。
    2. **Runs** タブを選択します。
    3. 削除する run の横にあるチェックボックスを選択します。
    4. 表の上にある **Delete** ボタン (ごみ箱アイコン) を選択します。
    5. 表示されるドロワーで **Delete** を選択します。

    大量の run を含む project では、検索バーで正規表現を使用して削除する run を絞り込むか、フィルターボタンでステータス、タグ、その他のプロパティに基づいて run をフィルターできます。
  </Tab>

  <Tab title="Python" value="python">
    W\&B Public API を使用すると、プログラムで run を削除できます。削除は単一の run に対しても、複数の run に対して一括でも実行できます。

    単一の run を削除するには、[`wandb.Api.Run.delete()`](/ja/products/wandb/ref/python/public-api/run#method-run-delete) を使用します。run パスは `entity/project/runID` の形式で指定します。

    ```python theme={"system"}
    import wandb

    api = wandb.Api()

    run_path = "entity/project/runID"
    run = api.run(path=run_path)
    run.delete()
    ```

    `wandb.Api.runs()` を使用して project から複数の run を取得し、各 run を削除します。次の例では、project 内のすべての run を削除します。

    ```python theme={"system"}
    import wandb

    api = wandb.Api()

    entity = "entity"
    project = "project"

    runs = api.runs(
        path=f"{entity}/{project}")

    for run in runs:
        run.delete()
    ```

    フィルターを使用すると、作成日、タグ、その他のメタデータなど、特定の条件に一致する run のみを削除できます。次の例では、指定した UTC タイムスタンプより前に作成された run をプレビューしてから削除します。

    ```python theme={"system"}
    import wandb

    api = wandb.Api()

    entity = "entity"
    project = "project"
    cutoff = "2024-01-01T00:00:00Z"  # この UTC タイムスタンプより前に作成された run を削除します

    runs = api.runs(
        path=f"{entity}/{project}",
        filters={"createdAt": {"$lt": cutoff}},
        order="+created_at",
    )

    # 最初に dry run を実行します
    runs_to_delete = list(runs)
    print(f"Found {len(runs_to_delete)} runs to delete:")
    for run in runs_to_delete:
        print(run.id, run.name, run.created_at)

    confirm = input("Type DELETE to permanently delete these runs: ")
    if confirm == "DELETE":
        for run in runs_to_delete:
            print(f"Deleting {run.path}")
            run.delete()  # or run.delete(delete_artifacts=True)
    ```

    ログしたメディアなど、run に関連付けられた個々のファイルを削除するには、次の手順を実行します。

    1. [`wandb.Api.Run.files()`](/ja/products/wandb/ref/python/public-api/run#method-run-files) を使用して、対象の file ハンドルを取得します。
    2. [`File.delete()`](/ja/products/wandb/ref/python/public-api/file#method-file-delete) を使用して、個々のファイルを削除します。
  </Tab>
</Tabs>

run ID は、run を削除した後も再利用できません。再利用しようとすると、run はエラーで失敗します。

<Warning>
  run の削除時に関連するアーティファクトも削除することを選択した場合、アーティファクトは完全に削除され、後で run をリストアしても復元できません。Registry にリンクされたアーティファクトも対象となります。
</Warning>

<h2 id="run-deletion-flowchart">
  run 削除のフローチャート
</h2>

次の図は、関連するアーティファクトと Registry リンクの処理を含む、run 削除のプロセス全体を示しています。

```mermaid theme={"system"}
graph TB
    Start([ユーザーが<br/>run の削除を開始します]) --> RunSelect[削除する run を<br/>選択します]
    RunSelect --> DeletePrompt{関連するアーティファクトを<br/>削除しますか?}
    DeletePrompt -->|いいえ| DeleteRunOnly[run のみを削除します<br/><br/>- run のメタデータが削除されます<br/>- アーティファクトは引き続き利用できます<br/>- アーティファクトには引き続きアクセスできます]
    DeletePrompt -->|はい| CheckArtifacts[関連するアーティファクトを<br/>確認します]
    CheckArtifacts --> HasRegistry{アーティファクトはモデルレジストリに<br/>リンクされていますか?}
    HasRegistry -->|はい| RegistryWarning[⚠️ 警告<br/><br/>Registry のモデルが削除されます<br/>本番のエイリアスに影響します]
    HasRegistry -->|いいえ| DirectDelete
    RegistryWarning --> ConfirmRegistry{Registry のモデルの<br/>削除を確定しますか?}
    ConfirmRegistry -->|いいえ| DeleteRunOnly
    ConfirmRegistry -->|はい| DirectDelete[run + アーティファクトを削除します<br/><br/>- run のメタデータが削除されます<br/>- アーティファクトが完全に削除されます<br/>- Registry のリンクが削除されます<br/>- 復元できません]
    DeleteRunOnly --> PartialEnd([run が削除されます<br/>アーティファクトは保持されます])
    DirectDelete --> FullEnd([run + アーティファクトが<br/>完全に削除されます])
    style Start fill:#e1f5fe,stroke:#333,stroke-width:2px,color:#000
    style DeletePrompt fill:#fff3e0,stroke:#333,stroke-width:2px,color:#000
    style RegistryWarning fill:#ffecb3,stroke:#333,stroke-width:2px,color:#000
    style DirectDelete fill:#ffebee,stroke:#333,stroke-width:2px,color:#000
    style DeleteRunOnly fill:#e8f5e9,stroke:#333,stroke-width:2px,color:#000
    style PartialEnd fill:#c8e6c9,stroke:#333,stroke-width:2px,color:#000
    style FullEnd fill:#ffcdd2,stroke:#333,stroke-width:2px,color:#000
```

<h2 id="when-deleted-run-data-is-removed-from-storage">
  削除した run データがストレージから除去されるタイミング
</h2>

[W\&B 専用クラウド](/ja/products/wandb/platform/hosting/hosting-options/dedicated-cloud) と [W\&B Self-Managed](/ja/products/wandb/platform/hosting/hosting-options/self-managed) では、環境変数 `GORILLA_DATA_RETENTION_PERIOD` によって、**削除した run データ**をオブジェクトストレージから完全に除去できるようになるまでの保持期間を制御します。**この設定ではアーティファクトは除去されません**。アーティファクトは、[アーティファクトを削除する](/ja/products/wandb/artifacts/delete-artifacts)で説明されているアーティファクトの削除とガベージコレクションの流れに従います。

`GORILLA_DATA_RETENTION_PERIOD` の設定や変更によって、保持期間を過ぎたデータが削除されると、元に戻すことはできません。保持期間を有効にしたり短縮したりする前に、データベースとバケットをバックアップしてください。リファレンス表と警告については、[環境変数を設定する](/ja/products/wandb/platform/hosting/env-vars)を参照してください。

run やファイルの削除と保持期間に基づく処理が完了した後も、バックグラウンドジョブの処理が追いつくまで、**バケットの使用量への反映が遅れる場合があります**。W\&B は、オブジェクトストレージの容量が即座に解放されることを保証しません。アーティファクトと run データの違い、処理にかかる時間の目安、オペレーターが必要に応じて行える操作の概要については、[バケットのストレージとコストを管理する](/ja/products/wandb/platform/hosting/managing-bucket-storage)を参照してください。

<Note>
  Public API を使用した削除が W\&B アプリに想定どおり反映されない場合は、W\&B Python SDK を最新リリースにアップグレードして再試行してください。
</Note>


## Related topics

- [アーティファクトを削除する](/ja/products/wandb/artifacts/delete-artifacts.md)
