Skip to content
Draft
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
50 changes: 50 additions & 0 deletions models/runs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,53 @@ Notes that you add to a specific run appear on the run page in the **Overview**
3. Select the run you want to add a note to from the run selector
4. Choose the **Overview** tab
5. Select the pencil icon next to the **Description** field and add your notes */}


## Run attributes


Internally, W&B stores run attributes as JSON files for three different objects: `run.config`, `run.summary`, and `run.history`.

Continuing from the previous example, the following JSON object shows the attributes of run's configuration (`run.config`):

```json
{
"_wandb": {
"value": {
"cli_version": "0.25.0",
"m": [],
"python_version": "3.10.0",
"t": {
"3": [
16
],
"4": "3.10.0",
"5": "0.25.0",
"12": "0.25.0",
"13": "darwin-arm64"
}
}
},
"epochs": {
"value": 100
},
"learning_rate": {
"value": 0.01
}
}
```

Summary metrics are the most recent logged values for a run.

```json
{
"_runtime": 0,
"_step": 99,
"_timestamp": 1773696666.303637,
"_wandb.runtime": 0,
"accuracy": 0.9448340173699504,
"loss": 0.0524316074042725
}
```

You can view the run's [configuration](/models/track/config) and [summary metrics](/models/track/log/log-summary#log-summary-metrics) in the W&B App UI. Prograammatically access the run's configuration and summary metrics with the `wandb.Run.config` and `wandb.Run.summary` properties, respectively. You can also use the W&B Public API to access a run's configuration and summary metrics with the `wandb.Api.Run.config` and `wandb.Api.Run.summary` properties, respectively.
14 changes: 14 additions & 0 deletions models/runs/filter-runs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,20 @@ Filter runs based on their tags:
<img src="/images/app_ui/filter_runs.gif" alt="Filter runs by tags" />
</Frame>

### Example: Filter runs with a timestamp

You can filter by using the MongoDB Query Language.

The following example filters runs created between two timestamps using the W&B Public API:

```python
runs = api.runs(
"<entity>/<project>",
{"$and": [{"created_at": {"$lt": "YYYY-MM-DDT##", "$gt": "YYYY-MM-DDT##"}}]},
)
```

See the [API guide](/models/ref/python/public-api/api#method-api-runs) for more examples of filtering runs with the API.

## Default filters

Expand Down
10 changes: 10 additions & 0 deletions models/runs/run-identifiers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ with wandb.init(entity="<project>", project="<project>", name="<run-name>") as r
# Your code here
```

### Find the run path

The run path consists of the entity, project, and run ID in this format: `<entity>/<project>/<run_id>`.

1. Navigate to your W&B project.
2. Select the **Workspace** or **Runs** tab.
3. Search or scroll to the run you want to find the run path for.
4. Click on the run to open the run's **Overview** page.
5. Copy and paste the run path from the **Run path** field.

### Rename a run

Rename a run after initializing it programmatically with the Python SDK or interactively in the W&B App.
Expand Down
88 changes: 3 additions & 85 deletions models/track/public-api-guide.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -159,18 +159,6 @@ Use the Public API to export or update data that you have saved to W&B. Before u

See the [Generated Reference Docs](/models/ref/python/public-api/) for details on available functions.

### Create an API key

An API key authenticates your machine to W&B.

<ApiKeyCreate/>

<ApiKeySecurity/>


### Find the run path

To use the Public API, you'll often need the run path which is `<entity>/<project>/<run_id>`. In the app UI, open a run page and click the [Overview tab ](/models/track/public-api-guide/#overview-tab)to get the run path.


### Export run data
Expand All @@ -194,48 +182,7 @@ The most commonly used attributes of a run object are:

You can also modify or update the data of past runs. By default a single instance of an api object will cache all network requests. If your use case requires real time information in a running script, call `api.flush()` to get updated values.

### Understanding different run attributes

The following code snippet shows how to create a run, log some data, and then access the run's attributes:

```python
import wandb
import random

with wandb.init(project="public-api-example") as run:
n_epochs = 5
config = {"n_epochs": n_epochs}
run.config.update(config)
for n in range(run.config.get("n_epochs")):
run.log(
{"val": random.randint(0, 1000), "loss": (random.randint(0, 1000) / 1000.00)}
)
```

The following sections describe the different outputs for the above run object attributes

##### `run.config`

```python
{"n_epochs": 5}
```

#### `run.summary`

```python
{
"_runtime": 4,
"_step": 4,
"_timestamp": 1644345412,
"_wandb": {"runtime": 3},
"loss": 0.041,
"val": 525,
}
```

### Sampling

The default history method samples the metrics to a fixed number of samples (the default is 500, you can change this with the `samples` __ argument). If you want to export all of the data on a large run, you can use the `run.scan_history()` method. For more details see the [API Reference](/models/ref/python/public-api).

### Querying multiple runs

Expand Down Expand Up @@ -296,30 +243,13 @@ Calling `api.runs` returns a `Runs` object that is iterable and acts like a list

If errors occur while talking to W&B servers a `wandb.CommError` will be raised. The original exception can be introspected via the `exc` attribute.

### Get the latest git commit through the API

In the UI, click on a run and then click the Overview tab on the run page to see the latest git commit. It's also in the file `wandb-metadata.json` . Using the public API, you can get the git hash with `run.commit`.

### Get a run's name and ID during a run

After calling `wandb.init()` you can access the random run ID or the human readable run name from your script like this:

- Unique run ID (8 character hash): `run.id`
- Random run name (human readable): `run.name`
{/* ### Get the latest git commit through the API

If you're thinking about ways to set useful identifiers for your runs, here's what we recommend:
In the UI, click on a run and then click the Overview tab on the run page to see the latest git commit. It's also in the file `wandb-metadata.json` . Using the public API, you can get the git hash with `run.commit`. */}

- **Run ID**: leave it as the generated hash. This needs to be unique across runs in your project.
- **Run name**: This should be something short, readable, and preferably unique so that you can tell the difference between different lines on your charts.
- **Run notes**: This is a great place to put a quick description of what you're doing in your run. You can set this with `wandb.init(notes="your notes here")`
- **Run tags**: Track things dynamically in run tags, and use filters in the UI to filter your table down to just the runs you care about. You can set tags from your script and then edit them in the UI, both in the runs table and the overview tab of the run page. See the detailed instructions [here](/models/runs/tags/).

## Public API Examples

### Export data to visualize in matplotlib or seaborn

Check out our [API examples](/models/ref/python/public-api/) for some common export patterns. You can also click the download button on a custom plot or on the expanded runs table to download a CSV from your browser.

### Read metrics from a run

This example outputs timestamp and accuracy saved with `run.log({"accuracy": acc})` for a run saved to `"<entity>/<project>/<run_id>"`.
Expand All @@ -335,18 +265,7 @@ if run.state == "finished":
print(row["_timestamp"], row["accuracy"])
```

### Filter runs

You can filter by using the MongoDB Query Language.

#### Date

```python
runs = api.runs(
"<entity>/<project>",
{"$and": [{"created_at": {"$lt": "YYYY-MM-DDT##", "$gt": "YYYY-MM-DDT##"}}]},
)
```

### Read specific metrics from a run

Expand Down Expand Up @@ -395,7 +314,7 @@ optimizer rmsprop adam

### Update metrics for a run, after the run has finished

This example sets the accuracy of a previous run to `0.9`. It also modifies the accuracy histogram of a previous run to be the histogram of `numpy_array`.
This example sets the accuracy of a previous run to `0.9`

```python
import wandb
Expand All @@ -404,7 +323,6 @@ api = wandb.Api()

run = api.run("<entity>/<project>/<run_id>")
run.summary["accuracy"] = 0.9
run.summary["accuracy_histogram"] = wandb.Histogram(numpy_array)
run.summary.update()
```

Expand Down
Loading