-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
src/callbacks/logging/mlflow.jl: Add basic MLFlowBackend.
- Loading branch information
Showing
3 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using MLFlowClient | ||
|
||
""" | ||
MLFlowBackend(tracking_uri, experiment_name[; kwargs...]) | ||
MLFlow backend for logging metrics. Creates a new experiment if it doesn't exist | ||
and starts a new run. | ||
""" | ||
struct MLFlowBackend <: LoggerBackend | ||
mlf::MLFlowClient.MLFlow | ||
experiment::MLFlowClient.MLFlowExperiment | ||
run::MLFlowClient.MLFlowRun | ||
function MLFlowBackend(tracking_uri::String, experiment_name::String; kwargs...) | ||
mlf = MLFlowClient.MLFlow(tracking_uri) | ||
experiment = MLFlowClient.getorcreateexperiment(mlf, experiment_name) | ||
run = MLFlowClient.createrun(mlf, experiment) | ||
return new(mlf, experiment, run) | ||
end | ||
end | ||
|
||
Base.show(io::IO, backend::MLFlowBackend) = print( | ||
io, "MLFlowBackend(", backend.mlf.apiroot, ", ", backend.experiment.name, ")") | ||
|
||
function log_to(backend::MLFlowBackend, value::Loggables.Value, name, step; group = ()) | ||
name = _combinename(name, group) | ||
MLFlowClient.logmetric(backend.mlf, backend.run, name, value.data, step=step) | ||
end |