diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index a3acf34..1f2a762 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -12,13 +12,11 @@ concurrency: cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} jobs: test: - services: mlflow: image: adacotechjp/mlflow:2.3.1 ports: - 5000:5000 - name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} runs-on: ${{ matrix.os }} strategy: @@ -48,6 +46,10 @@ jobs: ${{ runner.os }}-test- ${{ runner.os }}- - uses: julia-actions/julia-buildpkg@v1 + - name: Creating a dummy file to test logartifacts + run: | + touch ./test/mlflowclient-tempfile.txt + realpath ./test/mlflowclient-tempfile.txt - uses: julia-actions/julia-runtest@v1 env: MLFLOW_TRACKING_URI: "http://localhost:5000/api" diff --git a/src/experiments.jl b/src/experiments.jl index 520b05f..c9bfc2b 100644 --- a/src/experiments.jl +++ b/src/experiments.jl @@ -6,14 +6,16 @@ Creates an MLFlow experiment. # Arguments - `mlf`: [`MLFlow`](@ref) configuration. - `name`: experiment name. If not specified, MLFlow sets it. -- `artifact_location`: directory where artifacts of this experiment will be stored. If not specified, MLFlow uses its default configuration. +- `artifact_location`: directory where artifacts of this experiment will be +stored. If not specified, `./mlruns` will be used (it will take the directory +where you are running `mlflow` as the root one). - `tags`: a Dictionary of key-values which tag the experiment. # Returns An object of type [`MLFlowExperiment`](@ref). """ -function createexperiment(mlf::MLFlow; name=missing, artifact_location=missing, tags=missing) +function createexperiment(mlf::MLFlow; name=missing, artifact_location="./mlruns", tags=missing) endpoint = "experiments/create" if ismissing(name) @@ -103,7 +105,7 @@ Gets an experiment if one alrady exists, or creates a new one. An instance of type [`MLFlowExperiment`](@ref) """ -function getorcreateexperiment(mlf::MLFlow, experiment_name::String; artifact_location=missing, tags=missing) +function getorcreateexperiment(mlf::MLFlow, experiment_name::String; artifact_location="./mlruns", tags=missing) experiment = getexperiment(mlf, experiment_name) if ismissing(experiment) diff --git a/test/test_loggers.jl b/test/test_loggers.jl index d9871b6..79d6f91 100644 --- a/test/test_loggers.jl +++ b/test/test_loggers.jl @@ -120,7 +120,7 @@ end end @testset "logartifact_error" begin - @test_broken logartifact(mlf, r, "/etc/shadow") + @test_broken logartifact(mlf, r, "/etc/misina") end deleteexperiment(mlf, e) @@ -167,20 +167,29 @@ end runname = "run-$(UUIDs.uuid4())" r = createrun(mlf, e.experiment_id) + tempfilename = "./mlflowclient-tempfile.txt" + + open(tempfilename, "w") do file + write(file, "Hello, world!\n") + end + + logartifact(mlf, r, tempfilename) + @testset "listartifacts_by_run_id" begin artifacts = listartifacts(mlf, r.info.run_id) - @test length(artifacts) == 0 + @test length(artifacts) == 1 end @testset "listartifacts_by_run" begin artifacts = listartifacts(mlf, r) - @test length(artifacts) == 0 + @test length(artifacts) == 1 end @testset "listartifacts_by_run_info" begin artifacts = listartifacts(mlf, r.info) - @test length(artifacts) == 0 + @test length(artifacts) == 1 end + rm(tempfilename) deleteexperiment(mlf, e) end