public class MlflowClient extends Object
Constructor and Description |
---|
MlflowClient()
Returns a default client based on the MLFLOW_TRACKING_URI environment variable.
|
MlflowClient(MlflowHostCredsProvider hostCredsProvider)
Creates a new MlflowClient; users should prefer constructing ApiClients via
MlflowClient() or MlflowClient(String) if possible. |
MlflowClient(String trackingUri)
Instantiates a new client using the provided tracking uri.
|
Modifier and Type | Method and Description |
---|---|
String |
createExperiment(String experimentName)
Creates a new experiment using the default artifact location provided by the server.
|
Service.RunInfo |
createRun()
Creates a new run under the default experiment with no application name.
|
Service.RunInfo |
createRun(Service.CreateRun request)
Creates a new run.
|
Service.RunInfo |
createRun(String experimentId)
Creates a new run under the given experiment with no application name.
|
Service.RunInfo |
createRun(String experimentId,
String appName)
Creates a new run under the given experiment with the given application name.
|
void |
deleteExperiment(String experimentId)
Mark an experiment and associated runs, params, metrics, etc for deletion.
|
void |
deleteRun(String runId)
Deletes a run with the given ID.
|
File |
downloadArtifacts(String runId)
Returns a local directory containing *all* artifacts within the run's artifact directory.
|
File |
downloadArtifacts(String runId,
String artifactPath)
Returns 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) |
Service.Run |
getRun(String runUuid)
Gets metadata, params, tags, and metrics for a run.
|
List<Service.FileInfo> |
listArtifacts(String runId)
Lists the artifacts immediately under the run's root artifact directory.
|
List<Service.FileInfo> |
listArtifacts(String runId,
String artifactPath)
Lists 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)
Uploads the given local file to the run's root artifact directory.
|
void |
logArtifact(String runId,
File localFile,
String artifactPath)
Uploads the given local file to an artifactPath within the run's root directory.
|
void |
logArtifacts(String runId,
File localDir)
Uploads all files within the given local directory the run's root artifact directory.
|
void |
logArtifacts(String runId,
File localDir,
String artifactPath)
Uploads all files within the given local director an artifactPath within the run's root
artifact directory.
|
void |
logBatch(String runUuid,
Iterable<Service.Metric> metrics,
Iterable<Service.Param> params,
Iterable<Service.RunTag> tags)
Log multiple metrics, params, and/or tags against a given run (argument runUuid).
|
void |
logMetric(String runUuid,
String key,
double value)
Logs a new metric against the given run, as a key-value pair.
|
void |
logParam(String runUuid,
String key,
String value)
Logs 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)
Restores a deleted run with the given ID.
|
List<Service.RunInfo> |
searchRuns(List<String> experimentIds,
String searchFilter)
Returns runs from provided list of experiments, that satisfy the search query.
|
List<Service.RunInfo> |
searchRuns(List<String> experimentIds,
String searchFilter,
Service.ViewType runViewType)
Returns runs from provided list of experiments, that satisfy the search query.
|
String |
sendGet(String path)
Send a GET to the following path, including query parameters.
|
String |
sendPost(String path,
String json)
Send a POST to the following path, with a String-encoded JSON body.
|
void |
setTag(String runUuid,
String key,
String value)
Logs a new tag against the given run, as a key-value pair.
|
void |
setTerminated(String runUuid)
Sets the status of a run to be FINISHED at the current time.
|
void |
setTerminated(String runUuid,
Service.RunStatus status)
Sets the status of a run to be completed at the current time.
|
void |
setTerminated(String runUuid,
Service.RunStatus status,
long endTime)
Sets 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 runUuid)
public Service.RunInfo createRun()
public Service.RunInfo createRun(String experimentId)
public Service.RunInfo createRun(String experimentId, String appName)
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 IDssearchFilter
- 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 IDssearchFilter
- 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 runUuid, String key, String value)
public void logMetric(String runUuid, String key, double value)
public void setTag(String runUuid, String key, String value)
public void logBatch(String runUuid, Iterable<Service.Metric> metrics, Iterable<Service.Param> params, Iterable<Service.RunTag> tags)
public void setTerminated(String runUuid)
public void setTerminated(String runUuid, Service.RunStatus status)
public void setTerminated(String runUuid, 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.