Run Objects

class Run(object)


The run object corresponds to a single execution of your script, typically this is an ML experiment. Create a run with wandb.init().

In distributed training, use wandb.init() to create a run for each process, and set the group argument to organize runs into a larger experiment.

Currently there is a parallel Run object in the wandb.Api. Eventually these two objects will be merged.


  • history History - Time series values, created with wandb.log().

    History can contain scalar values, rich media, or even custom plots

    across multiple steps.

  • summary Summary - Single values set for each wandb.log() key. By

    default, summary is set to the last value logged. You can manually

    set summary to the best value, like max accuracy, instead of the

    final value.


| @property
| dir()


str: The directory where all of the files associated with the run are placed.


| @property
| config()


(Config): A config object (similar to a nested dict) of key value pairs associated with the hyperparameters of the run.


| @property
| name()


str: the display name of the run. It does not need to be unique and ideally is descriptive.


| @property
| notes()


str: notes associated with the run. Notes can be a multiline string and can also use markdown and latex equations inside $$ like $\{x}


| @property
| tags() -> Optional[Tuple]


Tuple[str]: tags associated with the run


| @property
| id()


str: the run_id associated with the run


| @property
| sweep_id()


(str, optional): the sweep id associated with the run or None


| @property
| path()


str: the path to the run [entity]/[project]/[run_id]


| @property
| start_time()


int: the unix time stamp in seconds when the run started


| @property
| starting_step()


int: the first step of the run


| @property
| resumed()


bool: whether or not the run was resumed


| @property
| step()


int: step counter

Every time you call wandb.log() it will by default increment the step counter.


| @property
| mode()


For compatibility with 0.9.x and earlier, deprecate eventually.


| @property
| group()


str: name of W&B group associated with run.

Setting a group helps the W&B UI organize runs in a sensible way.

If you are doing a distributed training you should give all of the runs in the training the same group. If you are doing crossvalidation you should give all the crossvalidation folds the same group.


| @property
| project()


str: name of W&B project associated with run.


| get_url()


Returns: (str, optional): URL for the W&B run or None if the run is offline


| get_project_url()


Returns: (str, optional): URL for the W&B project associated with the run or None if the run is offline


| get_sweep_url()


Returns: (str, optional): URL for the sweep associated with the run or None if there is no associated sweep or the run is offline.


| @property
| url()


str: name of W&B URL associated with run.


| @property
| entity()


str: name of W&B entity associated with run. Entity is either a user name or an organization name.


| log(data, step=None, commit=None, sync=None)


Log a dict to the global run's history.

wandb.log can be used to log everything from scalars to histograms, media and matplotlib plots.

The most basic usage is wandb.log({'train-loss': 0.5, 'accuracy': 0.9}). This will save a history row associated with the run with train-loss=0.5 and accuracy=0.9. The history values can be plotted on or on a local server. The history values can also be downloaded through the wandb API.

Logging a value will update the summary values for any metrics logged. The summary values will appear in the run table at or a local server. If a summary value is manually set with for example["accuracy"] = 0.9 wandb.log will no longer automatically update the run's accuracy.

Logging values don't have to be scalars. Logging any wandb object is supported. For example wandb.log({"example": wandb.Image("myimage.jpg")}) will log an example image which will be displayed nicely in the wandb UI. See for all of the different supported types.

Logging nested metrics is encouraged and is supported in the wandb API, so you could log multiple accuracy values with wandb.log({'dataset-1': {'acc': 0.9, 'loss': 0.3} ,'dataset-2': {'acc': 0.8, 'loss': 0.2}}) and the metrics will be organized in the wandb UI.

W&B keeps track of a global step so logging related metrics together is encouraged, so by default each time wandb.log is called a global step is incremented. If it's inconvenient to log related metrics together calling wandb.log({'train-loss': 0.5, commit=False}) and then wandb.log({'accuracy': 0.9}) is equivalent to calling wandb.log({'train-loss': 0.5, 'accuracy': 0.9})

wandb.log is not intended to be called more than a few times per second. If you want to log more frequently than that it's better to aggregate the data on the client side or you may get degraded performance.


  • row dict, optional - A dict of serializable python objects i.e str,

    ints, floats, Tensors, dicts, or wandb.data_types

  • commit boolean, optional - Save the metrics dict to the wandb server

    and increment the step. If false wandb.log just updates the current

    metrics dict with the row argument and metrics won't be saved until

    wandb.log is called with commit=True.

  • step integer, optional - The global step in processing. This persists

    any non-committed earlier steps but defaults to not committing the

    specified step.

  • sync boolean, True - This argument is deprecated and currently doesn't

    change the behaviour of wandb.log


Basic usage

- `wandb.log({'accuracy'` - 0.9, 'epoch': 5})

Incremental logging

- `wandb.log({'loss'` - 0.2}, commit=False)
# Somewhere else when I'm ready to report this step:
- `wandb.log({'accuracy'` - 0.8})


- `wandb.log({"gradients"` - wandb.Histogram(numpy_array_or_sequence)})


- `wandb.log({"examples"` - [wandb.Image(numpy_array_or_pil, caption="Label")]})


- `wandb.log({"video"` - wandb.Video(numpy_array_or_video_path, fps=4,

Matplotlib Plot

- `wandb.log({"chart"` - plt})

PR Curve

- `wandb.log({'pr'` - wandb.plots.precision_recall(y_test, y_probas, labels)})

3D Object


For more examples, see


wandb.Error - if called before wandb.init ValueError - if invalid data is passed


| save(glob_str: Optional[str] = None, base_path: Optional[str] = None, policy: str = "live")


Ensure all files matching glob_str are synced to wandb with the policy specified.


  • glob_str string - a relative or absolute path to a unix glob or

    regular path. If this isn't specified the method is a noop.

  • base_path string - the base path to run the glob relative to

  • policy string - on of "live", "now", or "end"

  • live - upload the file as it changes, overwriting the previous

    version now: upload the file once now

  • end - only upload file when the run ends


| finish(exit_code=None)


Marks a run as finished, and finishes uploading all data. This is used when creating multiple runs in the same process. We automatically call this method when your script exits.


| join(exit_code=None)


Deprecated alias for finish() - please use finish


| plot_table(vega_spec_name, data_table, fields, string_fields=None)


Creates a custom plot on a table.


  • vega_spec_name - the name of the spec for the plot

  • table_key - the key used to log the data table

  • data_table - a wandb.Table object containing the data to

    be used on the visualization

  • fields - a dict mapping from table keys to fields that the custom

    visualization needs

  • string_fields - a dict that provides values for any string constants

    the custom visualization needs


| use_artifact(artifact_or_name, type=None, aliases=None)


Declare an artifact as an input to a run, call download or file on the returned object to get the contents locally.


  • artifact_or_name str or Artifact - An artifact name.

    May be prefixed with entity/project. Valid names

    can be in the following forms:




    You can also pass an Artifact object created by calling wandb.Artifact

  • type str, optional - The type of artifact to use.

  • aliases list, optional - Aliases to apply to this artifact


A Artifact object.


| log_artifact(artifact_or_path, name=None, type=None, aliases=None)


Declare an artifact as output of a run.


  • artifact_or_path str or Artifact - A path to the contents of this artifact,

    can be in the following forms:




    You can also pass an Artifact object created by calling


  • name str, optional - An artifact name. May be prefixed with entity/project.

    Valid names can be in the following forms:




    This will default to the basename of the path prepended with the current

    run id if not specified.

  • type str - The type of artifact to log, examples include "dataset", "model"

  • aliases list, optional - Aliases to apply to this artifact,

    defaults to ["latest"]


A Artifact object.


| alert(title, text, level=None, wait_duration=None)


Launch an alert with the given title and text.


  • title str - The title of the alert, must be less than 64 characters long

  • text str - The text body of the alert

  • level str or wandb.AlertLevel, optional - The alert level to use, either: "INFO", "WARN", or "ERROR"

  • wait_duration int, float, or timedelta, optional - The time to wait (in seconds) before sending another alert

    with this title