From fbd86398dc7057ca6cefc8471274ae3ffa0ca23d Mon Sep 17 00:00:00 2001 From: Jose Esparza <28990958+pebeto@users.noreply.github.com> Date: Thu, 12 Oct 2023 22:21:05 -0500 Subject: [PATCH] Renaming MLFlowLogger to Logger --- README.md | 4 ++-- src/MLJFlow.jl | 3 --- src/base.jl | 8 ++++---- src/service.jl | 4 ++-- src/types.jl | 10 +++++----- test/base.jl | 2 +- test/types.jl | 4 ++-- 7 files changed, 16 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index f1a51f2..14196e9 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ The entire workload is divided into three different repositories: - [x] MLflow cycle automation (create experiment, create run, log metrics, log parameters, log artifacts, etc.) -- [x] Provides a wrapper `MLFlowLogger` for MLFlowClient.jl clients and associated +- [x] Provides a wrapper `Logger` for MLFlowClient.jl clients and associated metadata; instances of this type are valid "loggers", which can be passed to MLJ functions supporting the `logger` keyword argument. @@ -71,7 +71,7 @@ We first define a logger, providing the address of our running MLflow. The exper name and artifact location are optional. ```julia -logger = MLFlowLogger( +logger = MLJFlow.Logger( "http://127.0.0.1:5000"; experiment_name="MLJFlow test", artifact_location="./mlj-test" diff --git a/src/MLJFlow.jl b/src/MLJFlow.jl index a434b6d..7fd9a03 100644 --- a/src/MLJFlow.jl +++ b/src/MLJFlow.jl @@ -12,7 +12,4 @@ include("types.jl") include("base.jl") include("service.jl") -# types.jl -export MLFlowLogger - end diff --git a/src/base.jl b/src/base.jl index 880b595..1d8c77a 100644 --- a/src/base.jl +++ b/src/base.jl @@ -1,4 +1,4 @@ -function log_evaluation(logger::MLFlowLogger, performance_evaluation) +function log_evaluation(logger, performance_evaluation) experiment = getorcreateexperiment(logger.service, logger.experiment_name; artifact_location=logger.artifact_location) run = createrun(logger.service, experiment; @@ -19,12 +19,12 @@ function log_evaluation(logger::MLFlowLogger, performance_evaluation) updaterun(logger.service, run, "FINISHED") end -function save(logger::MLFlowLogger, mach::Machine) +function save(logger, machine:: Machine) io = IOBuffer() - save(io, mach) + save(io, machine) seekstart(io) - model = mach.model + model = machine.model experiment = getorcreateexperiment(logger.service, logger.experiment_name; artifact_location=logger.artifact_location) diff --git a/src/service.jl b/src/service.jl index b9c90f7..f409e38 100644 --- a/src/service.jl +++ b/src/service.jl @@ -75,8 +75,8 @@ function logmachinemeasures(service::MLFlow, run::MLFlowRun, measures, end """ - service(logger::MLFlowLogger) + service(logger) Returns the MLFlow service of a logger. """ -service(logger::MLFlowLogger) = logger.service +service(logger) = logger.service diff --git a/src/types.jl b/src/types.jl index 17c9dc9..ed8bbcc 100644 --- a/src/types.jl +++ b/src/types.jl @@ -1,5 +1,5 @@ """ - MLFlowLogger(baseuri; experiment_name="MLJ experiment", + Logger(baseuri; experiment_name="MLJ experiment", artifact_location=nothing) A wrapper around a MLFlow service, with an experiment name and an artifact @@ -17,24 +17,24 @@ used to store the artifacts of the experiment. If not provided, a default artifact location will be defined by MLFlow. For more information, see [MLFlow documentation](https://www.mlflow.org/docs/latest/tracking.html). -This constructor returns a `MLFlowLogger` object, containing the experiment +This constructor returns a `Logger` object, containing the experiment name and the artifact location specified previously. Also it contains a `MLFlow` service, which is used to communicate with the MLFlow server. For more information, see [MLFlowClient.jl](https://juliaai.github.io/MLFlowClient.jl/dev/reference/#MLFlowClient.MLFlow). """ -struct MLFlowLogger +struct Logger service::MLFlow verbosity::Int experiment_name::String artifact_location::Union{String,Nothing} end -function MLFlowLogger(baseuri; experiment_name="MLJ experiment", +function Logger(baseuri; experiment_name="MLJ experiment", artifact_location=nothing, verbosity=1) service = MLFlow(baseuri) if ~healthcheck(service) error("It seems that the MLFlow server is not running. For more information, see https://mlflow.org/docs/latest/quickstart.html") end - MLFlowLogger(service, verbosity, experiment_name, artifact_location) + Logger(service, verbosity, experiment_name, artifact_location) end diff --git a/test/base.jl b/test/base.jl index 1c1450e..d28c445 100644 --- a/test/base.jl +++ b/test/base.jl @@ -1,5 +1,5 @@ @testset verbose = true "base" begin - logger = MLFlowLogger("http://localhost:5000"; + logger = MLJFlow.Logger("http://localhost:5000"; experiment_name="MLJFlow tests", artifact_location="/tmp/mlj-test") diff --git a/test/types.jl b/test/types.jl index 814a04b..3c09408 100644 --- a/test/types.jl +++ b/test/types.jl @@ -1,6 +1,6 @@ @testset "types" begin - logger = MLFlowLogger("http://localhost:5000") + logger = MLJFlow.Logger("http://localhost:5000") - @test typeof(logger) == MLFlowLogger + @test typeof(logger) == MLJFlow.Logger @test typeof(logger.service) == MLFlow end