Skip to content

Commit

Permalink
Setting ./mlruns as the default artifact_location
Browse files Browse the repository at this point in the history
  • Loading branch information
pebeto committed May 28, 2024
1 parent c0d7723 commit 8df955f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
8 changes: 5 additions & 3 deletions src/experiments.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
15 changes: 12 additions & 3 deletions test/test_loggers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 8df955f

Please sign in to comment.