> ## 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 がアクティブな状態で、または Public API のみを使用して既存のアーティファクトを更新します。

# アーティファクトを更新する

`description`、`metadata`、および `alias` を更新するための希望する値を渡します。W\&B Public API を使用して、以前に W\&B にログされた run を ([`wandb.Api`](/ja/products/wandb/ref/python/public-api/api)) で更新します。初めて初期化され、まだアクティブな状態のときにアーティファクトを更新するには `wandb.Run.save()` を使用します。

<Note>
  **wandb.Artifact.save() または wandb.Run.log\_artifact() を使用するタイミング**

  * 新しい run を開始せずに既存のアーティファクトを更新するには `Artifact.save()` を使用します。
  * 新しいアーティファクトを作成して特定の run に関連付けるには `wandb.Run.log_artifact()` を使用します。
</Note>

W\&B Public API ([`wandb.Api`](/ja/products/wandb/ref/python/public-api/api)) を使用してアーティファクトを更新します。run がアクティブな状態のときは wandb.Artifact ([`wandb.Artifact`](/ja/products/wandb/ref/python/experiments/artifact)) クラスを使用します。

<Warning>
  モデルレジストリ内のモデルにリンクされたアーティファクトのエイリアスは更新できません。
</Warning>

<Tabs>
  <Tab title="run の実行中">
    次のコード例は、[`wandb.Artifact`](/ja/products/wandb/ref/python/experiments/artifact) API を使用してアーティファクトの説明を更新する方法を示しています。

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

    with wandb.init(project="<example>") as run:
        artifact = run.use_artifact("<artifact-name>:<alias>")
        artifact.description = "<description>"
        artifact.save()
    ```
  </Tab>

  <Tab title="W&B Public API">
    次の例は、[`wandb.Api`](/ja/products/wandb/ref/python/public-api/api) を使用してアーティファクトを更新します。

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

    api = wandb.Api()

    artifact = api.artifact("entity/project/artifact:alias")

    # Update the description
    artifact.description = "My new description"

    # Selectively update metadata keys
    artifact.metadata["oldKey"] = "new value"

    # Replace the metadata entirely
    artifact.metadata = {"newKey": "new value"}

    # Add an alias
    artifact.aliases.append("best")

    # Remove an alias
    artifact.aliases.remove("latest")

    # Completely replace the aliases
    artifact.aliases = ["replaced"]

    # Persist all artifact modifications
    artifact.save()
    ```

    詳細については、Weights and Biases の [Artifact API](/ja/products/wandb/ref/python/experiments/artifact) を参照してください。
  </Tab>

  <Tab title="コレクションを使用する場合">
    単一のアーティファクトと同様に、Artifact コレクションも更新できます。

    ```python theme={"system"}
    import wandb
    with wandb.init(project="<example>") as run:
        api = wandb.Api()
        artifact = api.artifact_collection(type="<type-name>", collection="<collection-name>")
        artifact.name = "<new-collection-name>"
        artifact.description = "<This is where you'd describe the purpose of your collection.>"
        artifact.save()
    ```

    詳細については、[Artifacts Collection](/ja/products/wandb/ref/python/public-api/api) リファレンスを参照してください。
  </Tab>
</Tabs>


## Related topics

- [アーティファクトを作成する](/ja/products/wandb/artifacts/construct-an-artifact.md)
