public class MlflowClient extends Object
Constructor and Description |
---|
MlflowClient()
Return a default client based on the MLFLOW_TRACKING_URI environment variable.
|
MlflowClient(MlflowHostCredsProvider hostCredsProvider)
Create a new MlflowClient; users should prefer constructing ApiClients via
MlflowClient() or MlflowClient(String) if possible. |
MlflowClient(String trackingUri)
Instantiate a new client using the provided tracking uri.
|
Modifier and Type | Method and Description |
---|---|
String |
createExperiment(String experimentName)
Create a new experiment using the default artifact location provided by the server.
|
Service.RunInfo |
createRun()
Create a new run under the default experiment with no application name.
|
Service.RunInfo |
createRun(Service.CreateRun request)
Create a new run.
|
Service.RunInfo |
createRun(String experimentId)
Create a new run under the given experiment.
|
void |
deleteExperiment(String experimentId)
Mark an experiment and associated runs, params, metrics, etc.
|
void |
deleteRun(String runId)
Delete a run with the given ID.
|
File |
downloadArtifacts(String runId)
Return a local directory containing *all* artifacts within the run's artifact directory.
|
File |
downloadArtifacts(String runId,
String artifactPath)
Return a local file or directory containing all artifacts within the given artifactPath
within the run's root artifactDirectory.
|
Service.GetExperiment.Response |
getExperiment(String experimentId) |
Optional<Service.Experiment> |
getExperimentByName(String experimentName) |
List<Service.Metric> |
getMetricHistory(String runId,
String key) |
Service.Run |
getRun(String runId)
Get metadata, params, tags, and metrics for a run.
|
List<Service.FileInfo> |
listArtifacts(String runId)
List the artifacts immediately under the run's root artifact directory.
|
List<Service.FileInfo> |
listArtifacts(String runId,
String artifactPath)
List the artifacts immediately under the given artifactPath within the run's root artifact
directory.
|
List<Service.Experiment> |
listExperiments() |
List<Service.RunInfo> |
listRunInfos(String experimentId) |
void |
logArtifact(String runId,
File localFile)
Upload the given local file to the run's root artifact directory.
|
void |
logArtifact(String runId,
File localFile,
String artifactPath)
Upload the given local file to an artifactPath within the run's root directory.
|
void |
logArtifacts(String runId,
File localDir)
Upload all files within the given local directory the run's root artifact directory.
|
void |
logArtifacts(String runId,
File localDir,
String artifactPath)
Upload all files within the given local director an artifactPath within the run's root
artifact directory.
|
void |
logBatch(String runId,
Iterable<Service.Metric> metrics,
Iterable<Service.Param> params,
Iterable<Service.RunTag> tags)
Log multiple metrics, params, and/or tags against a given run (argument runId).
|
void |
logMetric(String runId,
String key,
double value)
Log a new metric against the given run, as a key-value pair.
|
void |
logMetric(String runId,
String key,
double value,
long timestamp,
long step)
Log a new metric against the given run, as a key-value pair.
|
void |
logParam(String runId,
String key,
String value)
Log a parameter against the given run, as a key-value pair.
|
void |
renameExperiment(String experimentId,
String newName)
Update an experiment's name.
|
void |
restoreExperiment(String experimentId)
Restore an experiment marked for deletion.
|
void |
restoreRun(String runId)
Restore a deleted run with the given ID.
|
List<Service.RunInfo> |
searchRuns(List<String> experimentIds,
String searchFilter)
Return runs from provided list of experiments that satisfy the search query.
|
List<Service.RunInfo> |
searchRuns(List<String> experimentIds,
String searchFilter,
Service.ViewType runViewType)
Return runs from provided list of experiments that satisfy the search query.
|
String |
sendGet(String path)
:: Experimental ::
This API may change or be removed in a future release without warning.
|
String |
sendPost(String path,
String json)
:: Experimental ::
This API may change or be removed in a future release without warning.
|
void |
setTag(String runId,
String key,
String value)
Log a new tag against the given run, as a key-value pair.
|
void |
setTerminated(String runId)
Set the status of a run to be FINISHED at the current time.
|
void |
setTerminated(String runId,
Service.RunStatus status)
Set the status of a run to be completed at the current time.
|
void |
setTerminated(String runId,
Service.RunStatus status,
long endTime)
Set the status of a run to be completed at the given endTime.
|
public MlflowClient()
public MlflowClient(String trackingUri)
public MlflowClient(MlflowHostCredsProvider hostCredsProvider)
MlflowClient()
or MlflowClient(String)
if possible.public Service.Run getRun(String runId)
public List<Service.Metric> getMetricHistory(String runId, String key)
public Service.RunInfo createRun()
public Service.RunInfo createRun(String experimentId)
public Service.RunInfo createRun(Service.CreateRun request)
import org.mlflow.api.proto.Service.CreateRun; CreateRun.Builder request = CreateRun.newBuilder(); request.setExperimentId(experimentId); request.setSourceVersion("my-version"); createRun(request.build());
public List<Service.RunInfo> listRunInfos(String experimentId)
public List<Service.RunInfo> searchRuns(List<String> experimentIds, String searchFilter)
experimentIds
- List of experiment IDs.searchFilter
- SQL compatible search query string. Format of this query string is
similar to that specified on MLflow UI.
Example : "params.model = 'LogisticRegression' and metrics.acc = 0.9"public List<Service.RunInfo> searchRuns(List<String> experimentIds, String searchFilter, Service.ViewType runViewType)
experimentIds
- List of experiment IDs.searchFilter
- SQL compatible search query string. Format of this query string is
similar to that specified on MLflow UI.
Example : "params.model = 'LogisticRegression' and metrics.acc != 0.9"runViewType
- ViewType for expected runs. One of (ACTIVE_ONLY, DELETED_ONLY, ALL)
Defaults to ACTIVE_ONLY.public List<Service.Experiment> listExperiments()
public Service.GetExperiment.Response getExperiment(String experimentId)
public Optional<Service.Experiment> getExperimentByName(String experimentName)
public String createExperiment(String experimentName)
experimentName
- Name of the experiment. This must be unique across all experiments.public void deleteExperiment(String experimentId)
public void restoreExperiment(String experimentId)
public void renameExperiment(String experimentId, String newName)
public void deleteRun(String runId)
public void restoreRun(String runId)
public void logParam(String runId, String key, String value)
public void logMetric(String runId, String key, double value)
runId
- The ID of the run in which to record the metric.key
- The key identifying the metric for which to record the specified value.value
- The value of the metric.public void logMetric(String runId, String key, double value, long timestamp, long step)
runId
- The ID of the run in which to record the metric.key
- The key identifying the metric for which to record the specified value.value
- The value of the metric.timestamp
- The timestamp at which to record the metric value.step
- The step at which to record the metric value.public void setTag(String runId, String key, String value)
public void logBatch(String runId, Iterable<Service.Metric> metrics, Iterable<Service.Param> params, Iterable<Service.RunTag> tags)
public void setTerminated(String runId)
public void setTerminated(String runId, Service.RunStatus status)
public void setTerminated(String runId, Service.RunStatus status, long endTime)
public String sendGet(String path)
public String sendPost(String path, String json)
public void logArtifact(String runId, File localFile)
logArtifact(runId, "/my/localModel") listArtifacts(runId) // returns "localModel"
runId
- Run ID of an existing MLflow run.localFile
- File to upload. Must exist, and must be a simple file (not a directory).public void logArtifact(String runId, File localFile, String artifactPath)
logArtifact(runId, "/my/localModel", "model") listArtifacts(runId, "model") // returns "model/localModel"(i.e., the localModel file is now available in model/localModel).
runId
- Run ID of an existing MLflow run.localFile
- File to upload. Must exist, and must be a simple file (not a directory).artifactPath
- Artifact path relative to the run's root directory. Should NOT
start with a /.public void logArtifacts(String runId, File localDir)
logArtifacts(runId, "/my/local/dir") listArtifacts(runId) // returns "file1" and "file2"
runId
- Run ID of an existing MLflow run.localDir
- Directory to upload. Must exist, and must be a directory (not a simple file).public void logArtifacts(String runId, File localDir, String artifactPath)
logArtifacts(runId, "/my/local/dir", "model") listArtifacts(runId, "model") // returns "model/file1" and "model/file2"(i.e., the contents of the local directory are now available in model/).
runId
- Run ID of an existing MLflow run.localDir
- Directory to upload. Must exist, and must be a directory (not a simple file).artifactPath
- Artifact path relative to the run's root directory. Should NOT
start with a /.public List<Service.FileInfo> listArtifacts(String runId)
runId
- Run ID of an existing MLflow run.public List<Service.FileInfo> listArtifacts(String runId, String artifactPath)
runId
- Run ID of an existing MLflow run.artifactPath
- Artifact path relative to the run's root directory. Should NOT
start with a /.public File downloadArtifacts(String runId)
runId
- Run ID of an existing MLflow run.public File downloadArtifacts(String runId, String artifactPath)
downloadArtifacts(runId, "model") // returns a local directory containing "file1" and "file2" downloadArtifacts(runId, "model/file1") // returns a local *file* with the contents of file1.Note that this will download the entire subdirectory path, and so may be expensive if the subdirectory has a lot of data.
runId
- Run ID of an existing MLflow run.artifactPath
- Artifact path relative to the run's root directory. Should NOT
start with a /.Copyright © 2019. All rights reserved.