Skip to content
Merged
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
29 changes: 29 additions & 0 deletions weave/guides/tools/weave-in-workspaces.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,35 @@ To navigate to a workspace from the UI:

For more information about workspaces, see [View experiments results](https://docs.wandb.ai/models/track/workspaces).

## Associate traces with a specific W&B run

By default, Weave automatically detects and associates traces with the active `wandb.run`. If you need to associate traces with a specific run that is not the global `wandb.run`, use `set_wandb_run_context`. You can associate traces with a specific run and run step by defining values for the method's `run_id` and `step` arguments:

```python lines highlight={6}
import weave

client = weave.init("<your-team-name>/<your-project-name>")

# Associate all subsequent traces with a specific run.
client.set_wandb_run_context(run_id="<your-run-ID>", step=<integer>)

@weave.op
def my_function(x):
return x * 2

my_function(10) # This trace is linked to "my-run-id" at step 5.
```

The `run_id` is the run's short ID (for example, `38m4t5ja`), not the full `entity/project/run_id` path. You can find a run's short ID in the run URL (`https://wandb.ai/team/project/runs/<run_id>`) or by [accessing `wandb.run.id` in code](/models/runs/run-identifiers#find-and-customize-a-runs-id-or-name).

To stop the override and fall back to the global `wandb.run`, call `clear_wandb_run_context`:

```python lines
client.clear_wandb_run_context()

my_function(20) # This trace uses the global wandb.run (if any).
```

## Reference W&B artifacts in a Weave trace

You can reference [W&B artifacts](/models/artifacts) (such as models, datasets, and checkpoints) in your Weave traces. This creates a clickable link in the Weave UI that navigates directly to the artifact's details page, helping you track which artifact versions were used during specific operations.
Expand Down
Loading