Skip to main content
This tutorial walks you through building a registry automation triggered by artifact metadata: when an artifact in your registry gets a specific alias (for example, production), W&B sends a POST request to your webhook.
For guidance creating a project automation, see Tutorial: Project run-failure alert automation.

Prerequisites

  • A webhook configured in Team Settings.
  • A W&B registry with at least one collection, or reuse an existing registry.

Create a registry automation

Follow these instructions to set up a registry-scoped automation: When an artifact in any collection in that registry gets a specific alias (for example, production), W&B sends a POST request to your webhook.
  1. Open the registry and click the Automations tab, then click Create automation.
  2. Choose the event An artifact alias is added. Enter an Alias regex that matches the alias you care about (for example, production or staging).
  3. Click Next step. Set Action type to Webhooks and select your webhook. If the webhook expects a payload, paste a JSON body and use payload variables such as ${artifact_collection_name} and ${artifact_version_string}.
  4. Click Next step. Give the automation a name and optional description, then click Create automation.
For more detail, see Create a webhook automation (Registry tab).

Test the automation

Add the alias (for example, production) to an artifact version in the registry, using the W&B App or the public API. For example:
import wandb

with wandb.init(project="my-project") as run:
    artifact = wandb.Artifact("my-model", type="model")
    # ... log files or metadata to artifact as needed ...
    run.log_artifact(artifact)
    run.wait()  # Ensure the artifact is logged before proceeding

# Add an alias to the latest version in the collection
api = wandb.Api()
collection = api.artifact_collection(name="my-model", type_name="model")
version = next(collection.versions())  # Get the latest version

version.aliases.append("production")
version.save()
print("Added alias 'production' to", version.name)

Within a short time your webhook endpoint should receive a POST with the payload you configured.

Run the full tutorial in a notebook

Run the Automations tutorial notebook to create and test project-scoped and registry-scoped automations. Download or clone the repo and open the notebook in Jupyter, Google Colab, or your preferred notebook environment.

Go further