Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion content/en/ref/cli/_index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
title: Command Line Interface
weight: 2
---

**Usage**
Expand Down
2 changes: 1 addition & 1 deletion content/en/ref/cli/wandb-beta/wandb-beta-sync.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: wandb beta sync

**Usage**

`wandb beta sync [OPTIONS] WANDB_DIR`
`wandb beta sync [OPTIONS] [PATHS]...`

**Summary**

Expand Down
8 changes: 8 additions & 0 deletions content/en/ref/python/.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title:
---

<!-- Insert buttons and diff -->


{{< cta-button githubLink=https://www.github.com/wandb/wandb/tree/v0.22.1/wandb/**init**.py >}}
58 changes: 35 additions & 23 deletions content/en/ref/python/_index.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,49 @@
---
title: Python SDK 0.22.0
module:
weight: 1
title: Python Library
---
The W&B Python SDK, accessible at `wandb`, enables you to train and fine-tune models, and manage models from experimentation to production.

> After performing your training and fine-tuning operations with this SDK, you can use [the Public API]({{< relref "/ref/python/public-api" >}}) to query and analyze the data that was logged, and [the Reports and Workspaces API]({{< relref "/ref/wandb_workspaces" >}}) to generate a web-publishable [report]({{< relref "/guides/core/reports" >}}) summarizing your work.
<!-- Insert buttons and diff -->

## Installation and setup

### Sign up and create an API key

To authenticate your machine with W&B, you must first generate an API key at https://wandb.ai/authorize.
Use wandb to track machine learning work.

### Install and import packages
Train and fine-tune models, manage models from experimentation to production.

Install the W&B library.
For guides and examples, see https://docs.wandb.ai.

```
pip install wandb
```
For scripts and interactive notebooks, see https://github.com/wandb/examples.

### Import W&B Python SDK:
For reference documentation, see https://docs.wandb.com/ref/python.

```python
import wandb
## Classes

# Specify your team entity
entity = "<team_entity>"
[`class Artifact`](./artifact.md): Flexible and lightweight building block for dataset and model versioning.

# Project that the run is recorded to
project = "my-awesome-project"
[`class Run`](./run.md): A unit of computation logged by W&B. Typically, this is an ML experiment.

with wandb.init(entity=entity, project=project) as run:
run.log({"accuracy": 0.9, "loss": 0.1})
````
## Functions

[`agent(...)`](./agent.md): Start one or more sweep agents.

[`controller(...)`](./controller.md): Public sweep controller constructor.

[`finish(...)`](./finish.md): Finish a run and upload any remaining data.

[`init(...)`](./init.md): Start a new run to track and log to W&B.

[`log(...)`](./log.md): Upload run data.

[`login(...)`](./login.md): Set up W&B login credentials.

[`save(...)`](./save.md): Sync one or more files to W&B.

[`sweep(...)`](./sweep.md): Initialize a hyperparameter sweep.

[`watch(...)`](./watch.md): Hook into given PyTorch model to monitor gradients and the model's computational graph.

| Other Members | |
| :--- | :--- |
| `__version__`<a id="__version__"></a> | `'0.22.1'` |
| `config`<a id="config"></a> | |
| `summary`<a id="summary"></a> | |
29 changes: 29 additions & 0 deletions content/en/ref/python/agent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
title: agent
---

{{< cta-button githubLink=https://www.github.com/wandb/wandb/tree/v0.22.1/wandb/wandb_agent.py#L560-L604 >}}

Start one or more sweep agents.

```python
agent(
sweep_id: str,
function: Optional[Callable] = None,
entity: Optional[str] = None,
project: Optional[str] = None,
count: Optional[int] = None
) -> None
```

The sweep agent uses the `sweep_id` to know which sweep it
is a part of, what function to execute, and (optionally) how
many agents to run.

| Args | |
| :--- | :--- |
| `sweep_id` | The unique identifier for a sweep. A sweep ID is generated by W&B CLI or Python SDK. |
| `function` | A function to call instead of the "program" specified in the sweep config. |
| `entity` | The username or team name where you want to send W&B runs created by the sweep to. Ensure that the entity you specify already exists. If you don't specify an entity, the run will be sent to your default entity, which is usually your username. |
| `project` | The name of the project where W&B runs created from the sweep are sent to. If the project is not specified, the run is sent to a project labeled "Uncategorized". |
| `count` | The number of sweep config trials to try. |
734 changes: 734 additions & 0 deletions content/en/ref/python/artifact.md

Large diffs are not rendered by default.

93 changes: 14 additions & 79 deletions content/en/ref/python/automations/_index.md
Original file line number Diff line number Diff line change
@@ -1,96 +1,31 @@
---
title: Automations
module: wandb.automations
weight: 4
no_list: true
title: automations
---

The W&B Automations API enables programmatic creation and management of automated workflows that respond to events in your ML pipeline. Configure actions to trigger when specific conditions are met, such as model performance thresholds or artifact creation.
<!-- Insert buttons and diff -->


### Core Classes

| Class | Description |
|-------|-------------|
| [`Automation`](./automation/) | Represents a saved automation instance with its configuration. |
| [`NewAutomation`](./newautomation/) | Builder class for creating new automations. |
## Classes

### Events (Triggers)
[`class Automation`](./automation.md): A local instance of a saved W&B automation.

| Event | Description |
|-------|-------------|
| [`OnRunMetric`](./onrunmetric/) | Trigger when a run metric satisfies a defined condition (threshold, change, etc.). |
| [`OnCreateArtifact`](./oncreateartifact/) | Trigger when a new artifact is created in a collection. |
| [`OnLinkArtifact`](./onlinkartifact/) | Trigger when an artifact is linked to a registry. |
| [`OnAddArtifactAlias`](./onaddartifactalias/) | Trigger when an alias is added to an artifact. |
[`class DoNothing`](./donothing.md): Defines an automation action that intentionally does nothing.

### Actions
[`class MetricChangeFilter`](./metricchangefilter.md): Defines a filter that compares a change in a run metric against a user-defined threshold.

| Action | Description |
|--------|-------------|
| [`SendNotification`](./sendnotification/) | Send notifications via Slack or other integrated channels. |
| [`SendWebhook`](./sendwebhook/) | Send HTTP webhook requests to external services. |
| [`DoNothing`](./donothing/) | Placeholder action for testing automation configurations. |
[`class MetricThresholdFilter`](./metricthresholdfilter.md): Defines a filter that compares a run metric against a user-defined threshold value.

### Filters
[`class NewAutomation`](./newautomation.md): A new automation to be created.

| Filter | Description |
|--------|-------------|
| [`MetricThresholdFilter`](./metricthresholdfilter/) | Filter runs based on metric value comparisons against thresholds. |
| [`MetricChangeFilter`](./metricchangefilter/) | Filter runs based on metric value changes over time. |
[`class OnAddArtifactAlias`](./onaddartifactalias.md): A new alias is assigned to an artifact.

## Common Use Cases
[`class OnCreateArtifact`](./oncreateartifact.md): A new artifact is created.

### Model Performance Monitoring
- Alert when model accuracy drops below a threshold
- Notify team when training loss plateaus
- Trigger retraining pipelines based on performance metrics
[`class OnLinkArtifact`](./onlinkartifact.md): A new artifact is linked to a collection.

### Artifact Management
- Send notifications when new model versions are created
- Trigger deployment workflows when artifacts are tagged
- Automate downstream processing when datasets are updated
[`class OnRunMetric`](./onrunmetric.md): A run metric satisfies a user-defined condition.

### Experiment Tracking
- Alert on failed or crashed runs
- Notify when long-running experiments complete
- Send daily summaries of experiment metrics
[`class SendNotification`](./sendnotification.md): Defines an automation action that sends a (Slack) notification.

### Integration Workflows
- Update external tracking systems via webhooks
- Sync model registry with deployment platforms
- Trigger CI/CD pipelines based on W&B events

## Example Usage

The following example creates an automation that sends a Slack notification whenever a metric called `custom-metric` exceeds 10. `custom-metric` is expected to be logged during training using `wandb.Run.log({"custom-metric": value })`.

```python
import wandb
from wandb.automations import OnRunMetric, RunEvent, SendNotification

api = wandb.Api()

project = api.project("<my-project>", entity="<my-team>")

# Use the first Slack integration for the team
slack_hook = next(api.slack_integrations(entity="<my-team>"))

# Create a trigger event
event = OnRunMetric(
scope=project,
filter=RunEvent.metric("custom-metric") > 10,
)

# Create an action that responds to the event
action = SendNotification.from_integration(slack_hook)

# Create the automation
automation = api.create_automation(
event >> action,
name="my-automation",
description="Send a Slack message whenever 'custom-metric' exceeds 10.",
)
```

For more information about using the Automations API, see the [Automations Guide]({{< relref "/guides/core/automations" >}}).
[`class SendWebhook`](./sendwebhook.md): Defines an automation action that sends a webhook request.
48 changes: 9 additions & 39 deletions content/en/ref/python/automations/automation.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,16 @@
---
title: Automation
namespace: automations_namespace
python_object_type: class
---

{{< cta-button githubLink=https://github.com/wandb/wandb/blob/main/wandb/automations/automations.py >}}
{{< cta-button githubLink=https://www.github.com/wandb/wandb/tree/v0.22.1/wandb/automations/automations.py#L19-L48 >}}



## <kbd>class</kbd> `Automation`
A local instance of a saved W&B automation.


### <kbd>method</kbd> `Automation.__init__`

```python
__init__(
typename__: 'Literal['Trigger']' = 'Trigger',
id: 'str',
created_at: 'datetime',
updated_at: 'datetime | None' = None,
name: 'str',
description: 'str | None',
enabled: 'bool',
scope: '_ArtifactSequenceScope | _ArtifactPortfolioScope | ProjectScope',
event: 'SavedEvent',
action: 'SavedLaunchJobAction | SavedNotificationAction | SavedWebhookAction | SavedNoOpAction'
) → None
```

**Args:**

- `typename__` (Literal['Trigger']):
- `id` (str):
- `created_at` (datetime): The date and time when this automation was created.
- `updated_at` (Optional[datetime]): The date and time when this automation was last updated, if applicable.
- `name` (str): The name of this automation.
- `description` (Optional[str]): An optional description of this automation.
- `enabled` (bool): Whether this automation is enabled. Only enabled automations will trigger.
- `scope` (Union[_ArtifactSequenceScope, _ArtifactPortfolioScope, ProjectScope]): The scope in which the triggering event must occur.
- `event` (SavedEvent): The event that will trigger this automation.
- `action` (Union[SavedLaunchJobAction, SavedNotificationAction, SavedWebhookAction, SavedNoOpAction]): The action that will execute when this automation is triggered.

**Returns:**
An `Automation` object.
| Attributes | |
| :--- | :--- |
| `name` | The name of this automation. |
| `description` | An optional description of this automation. |
| `enabled` | Whether this automation is enabled. Only enabled automations will trigger. |
| `scope` | The scope in which the triggering event must occur. |
| `event` | The event that will trigger this automation. |
| `action` | The action that will execute when this automation is triggered. |
29 changes: 5 additions & 24 deletions content/en/ref/python/automations/donothing.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,12 @@
---
title: DoNothing
namespace: automations_namespace
python_object_type: class
---

{{< cta-button githubLink=https://github.com/wandb/wandb/blob/main/wandb/automations/actions.py >}}
{{< cta-button githubLink=https://www.github.com/wandb/wandb/tree/v0.22.1/wandb/automations/actions.py#L192-L201 >}}



## <kbd>class</kbd> `DoNothing`
Defines an automation action that intentionally does nothing.


### <kbd>method</kbd> `DoNothing.__init__`

```python
__init__(
no_op: 'bool' = True,
action_type: 'Literal[NO_OP]' = NO_OP
) → None
```

**Args:**

- `no_op` (bool): Placeholder field which exists only to satisfy backend schema requirements.
There should never be a need to set this field explicitly, as its value is ignored.
- `action_type` (Literal[NO_OP]):

**Returns:**
An `DoNothing` object.
| Attributes | |
| :--- | :--- |
| `no_op` | Placeholder field which exists only to satisfy backend schema requirements. There should never be a need to set this field explicitly, as its value is ignored. |
| `action_type` | The kind of action to be triggered. |
44 changes: 8 additions & 36 deletions content/en/ref/python/automations/metricchangefilter.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,18 @@
---
title: MetricChangeFilter
namespace: automations_namespace
python_object_type: class
---

{{< cta-button githubLink=https://github.com/wandb/wandb/blob/main/wandb/automations/_filters/run_metrics.py >}}
{{< cta-button githubLink=https://www.github.com/wandb/wandb/tree/v0.22.1/wandb/automations/_filters/run_metrics.py#L142-L188 >}}



## <kbd>class</kbd> `MetricChangeFilter`
Defines a filter that compares a change in a run metric against a user-defined threshold.

The change is calculated over "tumbling" windows, i.e. the difference
between the current window and the non-overlapping prior window.


### <kbd>method</kbd> `MetricChangeFilter.__init__`

```python
__init__(
name: 'str',
agg: 'Agg | None' = None,
window: 'int' = 1,
cmp: 'None' = None,
threshold: 'Annotated | Annotated',
prior_window: 'int' = None,
change_type: 'ChangeType',
change_dir: 'ChangeDir'
) → None
```

**Args:**

- `name` (str):
- `agg` (Optional[Agg]):
- `window` (int):
- `cmp` (None): Ignored.
- `threshold` (Union[Annotated, Annotated]):
- `prior_window` (int): Size of the prior window over which the metric is aggregated (ignored if `agg is None`).
If omitted, defaults to the size of the current window.
- `change_type` (ChangeType):
- `change_dir` (ChangeDir):

**Returns:**
An `MetricChangeFilter` object.
| Attributes | |
| :--- | :--- |
| `prior_window` | Size of the prior window over which the metric is aggregated (ignored if `agg is None`). If omitted, defaults to the size of the current window. |
| `name` | Name of the observed metric. |
| `agg` | Aggregate operation, if any, to apply over the window size. |
| `window` | Size of the window over which the metric is aggregated (ignored if `agg is None`). |
| `threshold` | Threshold value to compare against. |
Loading