mlflow.tracking¶
-
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.
Parameters: - 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.
-
get_artifact_uri
()¶
-
get_run
()¶
-
log_artifact
(local_path, artifact_path)¶
-
log_artifacts
(local_dir, artifact_path)¶
-
log_metric
(metric)¶
-
log_param
(param)¶
-
set_terminated
(status)¶
-
mlflow.tracking.
active_run
()¶ Returns the currently active Run, or None if no such run exists.
-
mlflow.tracking.
create_experiment
(experiment_name)¶ Creates an experiment with the specified name and returns its ID.
-
mlflow.tracking.
end_run
(status='FINISHED')¶
-
mlflow.tracking.
get_artifact_uri
()¶ 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.
-
mlflow.tracking.
get_tracking_uri
()¶ 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
-
mlflow.tracking.
list_experiments
()¶ 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)
-
mlflow.tracking.
set_tracking_uri
(uri)¶ 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 a run is currently in progress (i.e., start_run has been called without an end_run, or you are running from “mlflow run”), then this function will return the existing run.
Parameters: - 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.
Returns: A
ActiveRun
object that acts as a context manager wrapping the run’s state