Search code examples
pythonmetadatawandb

WANDB Getting a run id based on tag


Context

Hi!

In wandb I can download a model based on a tag (prod for example), but I would like to also get all metrics associated to that run by using tags.

The problem is that I don't know how to a get specific run ID based a tag.

Example

Using the code bellow we can extract a run summary metrics, but setting run IDs is setting me back.

So if I can get run IDs based on tag or just explicitly download metrics with another API call, like with a special sintax in api.run, that would be great! In the code example bellow I would like to use the what_i_want_to_use string to call the API instead of what_i_use.

import wandb
from ast import literal_eval
api = wandb.Api()

what_i_use = "team_name/project_name/runID_h3h3h4h4h4h4"
# what_i_want_to_use = "team_name/project_name/artifact_name/prod_tag"

# run is specified by <entity>/<project>/<run_id>
run = api.run(what_i_use)


# save the metrics for the run to a csv file
metrics_dataframe = run.summary
print(metrics_dataframe['a_summary_metric'])

By running through the docs I didn't find any solution so far. Any ideias?

wandb public api run details

Thanks for reading!


Solution

  • It is possible to filter runs by tags as well. You can read more about it here:

    You can filter by config.*, summary_metrics.*, tags, state, entity, createdAt, etc.