class mlflow.tracking.ActiveRun(run_info, store)

Bases: object

Class representing an active run. Has a reference to the store to which state for the run (e.g. run metadata, metrics, parameters, and artifacts) should be persisted.

Contains methods for logging metrics, parameters, etc under the current run.

  • run_info – RunInfo describing the active run. A corresponding Run object is assumed to already be persisted with state “running” in store.
  • store – Backend store to which the current run should persist state updates.
log_artifact(local_path, artifact_path=None)
log_artifacts(local_dir, artifact_path=None)

Returns the currently active Run, or None if no such run exists.


Creates an experiment with the specified name and returns its ID.


Returns the artifact URI of the currently active run. Calls to log_artifact, log_artifacts will write artifact(s) to subdirectories of the returned URI.


Returns the run with the specified run UUID from the current tracking server.


Returns the current tracking URI. Note that this may not correspond to the tracking URI of the currently active run, since the tracking URI may be updated via set_tracking_uri. :return: the tracking URI


Returns a list of all experiments

mlflow.tracking.log_artifact(local_path, artifact_path=None)

Log a local file or directory as an artifact of the currently active run.

mlflow.tracking.log_artifacts(local_dir, artifact_path=None)

Log all the contents of a local directory as artifacts of the run.

mlflow.tracking.log_metric(key, value)

Logs the passed-in metric under the current run, creating a run if necessary. :param key: Metric name (string) :param value: Metric value (float)

mlflow.tracking.log_param(key, value)

Logs the passed-in parameter under the current run, creating a run if necessary. :param key: Parameter name (string) :param value: Parameter value (string)


Sets the tracking server URI to the passed-in value. Note that this does not affect the currently active run (if one exists), but will take effect for any successive runs.

mlflow.tracking.start_run(run_uuid=None, experiment_id=None, source_name=None, source_version=None, entry_point_name=None, source_type=None)

Start a new MLflow run, setting it as the active run under which metrics and params will be logged. The return value can be used as a context manager within a with block; otherwise, end_run() must be called to terminate the current run. Note that if run_uuid is passed or the MLFLOW_RUN_ID environment variable is set, start_run will attempt to resume a run with the specified run ID (with run_uuid taking precedence over MLFLOW_RUN_ID), and other parameters will be ignored.

  • run_uuid – If specified, gets the run with the specified UUID and logs metrics and params under that run. The run’s end time will be unset and its status will be set to running, but the run’s other attributes will remain unchanged (the run’s source_version, source_type, etc will not be changed).
  • experiment_id – Only used when run_uuid is unspecified. ID of the experiment under which to create the current run. If unspecified, the run will be created under a new experiment with a randomly-generated name
  • source_name – Name of the source file or URI of the project to be associated with the run. Defaults to the current file if none provided.
  • source_version – Optional Git commit hash to associate with the run.
  • entry_point_name – Optional name of the entry point for to the current run.
  • source_type – Integer enum value describing the type of the run (“local”, “project”, etc). Defaults to mlflow.entities.source_type.SourceType.LOCAL.

A ActiveRun object that acts as a context manager wrapping the run’s state