Package org.mlflow.tracking
Class ActiveRun
java.lang.Object
org.mlflow.tracking.ActiveRun
Represents an active MLflow run and contains APIs to log data to the run.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
endRun()
Ends the active MLflow run.void
endRun
(Service.RunStatus status) Ends the active MLflow run.Get the absolute URI of the run artifact directory root.getId()
Gets the run id of this run.void
logArtifact
(Path localPath) LikelogArtifact(Path, String)
with the artifactPath set to the root of the artifact directory.void
logArtifact
(Path localPath, String artifactPath) Uploads the given local file to the run's root artifact directory.void
logArtifacts
(Path localPath) LikelogArtifacts(Path, String)
with the artifactPath set to the root of the artifact directory.void
logArtifacts
(Path localPath, String artifactPath) Uploads all files within the given local director an artifactPath within the run's root artifact directory.void
LikelogMetric(String, double, int)
with a default step of 0.void
Logs a metric under this run.void
logMetrics
(Map<String, Double> metrics) LikelogMetrics(Map, int)
with a default step of 0.void
logMetrics
(Map<String, Double> metrics, int step) Log multiple metrics for this run.void
Log a parameter under this run.void
Log multiple params for this run.void
Sets a tag under this run.void
Sets multiple tags for this run.
-
Method Details
-
getId
Gets the run id of this run.- Returns:
- The run id of this run.
-
logParam
Log a parameter under this run.- Parameters:
key
- The name of the parameter.value
- The value of the parameter.
-
setTag
Sets a tag under this run.- Parameters:
key
- The name of the tag.value
- The value of the tag.
-
logMetric
LikelogMetric(String, double, int)
with a default step of 0. -
logMetric
Logs a metric under this run.- Parameters:
key
- The name of the metric.value
- The value of the metric.step
- The metric step.
-
logMetrics
LikelogMetrics(Map, int)
with a default step of 0. -
logMetrics
Log multiple metrics for this run.- Parameters:
metrics
- A map of metric name to value.step
- The metric step.
-
logParams
Log multiple params for this run.- Parameters:
params
- A map of param name to value.
-
setTags
Sets multiple tags for this run.- Parameters:
tags
- A map of tag name to value.
-
logArtifact
LikelogArtifact(Path, String)
with the artifactPath set to the root of the artifact directory.- Parameters:
localPath
- Path of file to upload. Must exist, and must be a simple file (not a directory).
-
logArtifact
Uploads the given local file to the run's root artifact directory. For example,activeRun.logArtifact("/my/localModel", "model") mlflowClient.listArtifacts(activeRun.getId(), "model") // returns "model/localModel"
- Parameters:
localPath
- Path of file to upload. Must exist, and must be a simple file (not a directory).artifactPath
- Artifact path relative to the run's root directory given bygetArtifactUri()
. Should NOT start with a /.
-
logArtifacts
LikelogArtifacts(Path, String)
with the artifactPath set to the root of the artifact directory.- Parameters:
localPath
- Directory to upload. Must exist, and must be a directory (not a simple file).
-
logArtifacts
Uploads all files within the given local director an artifactPath within the run's root artifact directory. For example, if /my/local/dir/ contains two files "file1" and "file2", thenactiveRun.logArtifacts("/my/local/dir", "model") mlflowClient.listArtifacts(activeRun.getId(), "model") // returns "model/file1" and // "model/file2"
(i.e., the contents of the local directory are now available in model/).- Parameters:
localPath
- Directory to upload. Must exist, and must be a directory (not a simple file).artifactPath
- Artifact path relative to the run's root directory given bygetArtifactUri()
. Should NOT start with a /.
-
getArtifactUri
Get the absolute URI of the run artifact directory root.- Returns:
- The absolute URI of the run artifact directory root.
-
endRun
public void endRun()Ends the active MLflow run. -
endRun
Ends the active MLflow run.- Parameters:
status
- The status of the run.
-