Package org.mlflow.tracking
Class ActiveRun
- java.lang.Object
- 
- org.mlflow.tracking.ActiveRun
 
- 
 public class ActiveRun extends java.lang.ObjectRepresents an active MLflow run and contains APIs to log data to the run.
- 
- 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidendRun()Ends the active MLflow run.voidendRun(Service.RunStatus status)Ends the active MLflow run.java.lang.StringgetArtifactUri()Get the absolute URI of the run artifact directory root.java.lang.StringgetId()Gets the run id of this run.voidlogArtifact(java.nio.file.Path localPath)LikelogArtifact(Path, String)with the artifactPath set to the root of the artifact directory.voidlogArtifact(java.nio.file.Path localPath, java.lang.String artifactPath)Uploads the given local file to the run's root artifact directory.voidlogArtifacts(java.nio.file.Path localPath)LikelogArtifacts(Path, String)with the artifactPath set to the root of the artifact directory.voidlogArtifacts(java.nio.file.Path localPath, java.lang.String artifactPath)Uploads all files within the given local director an artifactPath within the run's root artifact directory.voidlogMetric(java.lang.String key, double value)LikelogMetric(String, double, int)with a default step of 0.voidlogMetric(java.lang.String key, double value, int step)Logs a metric under this run.voidlogMetrics(java.util.Map<java.lang.String,java.lang.Double> metrics)LikelogMetrics(Map, int)with a default step of 0.voidlogMetrics(java.util.Map<java.lang.String,java.lang.Double> metrics, int step)Log multiple metrics for this run.voidlogParam(java.lang.String key, java.lang.String value)Log a parameter under this run.voidlogParams(java.util.Map<java.lang.String,java.lang.String> params)Log multiple params for this run.voidsetTag(java.lang.String key, java.lang.String value)Sets a tag under this run.voidsetTags(java.util.Map<java.lang.String,java.lang.String> tags)Sets multiple tags for this run.
 
- 
- 
- 
Method Detail- 
getIdpublic java.lang.String getId() Gets the run id of this run.- Returns:
- The run id of this run.
 
 - 
logParampublic void logParam(java.lang.String key, java.lang.String value)Log a parameter under this run.- Parameters:
- key- The name of the parameter.
- value- The value of the parameter.
 
 - 
setTagpublic void setTag(java.lang.String key, java.lang.String value)Sets a tag under this run.- Parameters:
- key- The name of the tag.
- value- The value of the tag.
 
 - 
logMetricpublic void logMetric(java.lang.String key, double value)LikelogMetric(String, double, int)with a default step of 0.
 - 
logMetricpublic void logMetric(java.lang.String key, double value, int step)Logs a metric under this run.- Parameters:
- key- The name of the metric.
- value- The value of the metric.
- step- The metric step.
 
 - 
logMetricspublic void logMetrics(java.util.Map<java.lang.String,java.lang.Double> metrics) LikelogMetrics(Map, int)with a default step of 0.
 - 
logMetricspublic void logMetrics(java.util.Map<java.lang.String,java.lang.Double> metrics, int step)Log multiple metrics for this run.- Parameters:
- metrics- A map of metric name to value.
- step- The metric step.
 
 - 
logParamspublic void logParams(java.util.Map<java.lang.String,java.lang.String> params) Log multiple params for this run.- Parameters:
- params- A map of param name to value.
 
 - 
setTagspublic void setTags(java.util.Map<java.lang.String,java.lang.String> tags) Sets multiple tags for this run.- Parameters:
- tags- A map of tag name to value.
 
 - 
logArtifactpublic void logArtifact(java.nio.file.Path localPath) 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).
 
 - 
logArtifactpublic void logArtifact(java.nio.file.Path localPath, java.lang.String artifactPath)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 by- getArtifactUri(). Should NOT start with a /.
 
 - 
logArtifactspublic void logArtifacts(java.nio.file.Path localPath) 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).
 
 - 
logArtifactspublic void logArtifacts(java.nio.file.Path localPath, java.lang.String artifactPath)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 by- getArtifactUri(). Should NOT start with a /.
 
 - 
getArtifactUripublic java.lang.String getArtifactUri() Get the absolute URI of the run artifact directory root.- Returns:
- The absolute URI of the run artifact directory root.
 
 - 
endRunpublic void endRun() Ends the active MLflow run.
 - 
endRunpublic void endRun(Service.RunStatus status) Ends the active MLflow run.- Parameters:
- status- The status of the run.
 
 
- 
 
-