Skip to content

Commit 5b2141e

Browse files
committed
Setting ./mlruns as the default artifact_location
1 parent c0d7723 commit 5b2141e

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

.github/workflows/CI.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@ concurrency:
1212
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
1313
jobs:
1414
test:
15-
1615
services:
1716
mlflow:
1817
image: adacotechjp/mlflow:2.3.1
1918
ports:
2019
- 5000:5000
21-
2220
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
2321
runs-on: ${{ matrix.os }}
2422
strategy:
@@ -48,6 +46,10 @@ jobs:
4846
${{ runner.os }}-test-
4947
${{ runner.os }}-
5048
- uses: julia-actions/julia-buildpkg@v1
49+
- name: Creating a dummy file to test logartifacts
50+
run: |
51+
touch ./test/mlflowclient-tempfile.txt
52+
realpath ./test/mlflowclient-tempfile.txt
5153
- uses: julia-actions/julia-runtest@v1
5254
env:
5355
MLFLOW_TRACKING_URI: "http://localhost:5000/api"

src/experiments.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@ Creates an MLFlow experiment.
66
# Arguments
77
- `mlf`: [`MLFlow`](@ref) configuration.
88
- `name`: experiment name. If not specified, MLFlow sets it.
9-
- `artifact_location`: directory where artifacts of this experiment will be stored. If not specified, MLFlow uses its default configuration.
9+
- `artifact_location`: directory where artifacts of this experiment will be
10+
stored. If not specified, `./mlruns` will be used (it will take the directory
11+
where you are running `mlflow` as the root one).
1012
- `tags`: a Dictionary of key-values which tag the experiment.
1113
1214
# Returns
1315
An object of type [`MLFlowExperiment`](@ref).
1416
1517
"""
16-
function createexperiment(mlf::MLFlow; name=missing, artifact_location=missing, tags=missing)
18+
function createexperiment(mlf::MLFlow; name=missing, artifact_location="./mlruns", tags=missing)
1719
endpoint = "experiments/create"
1820

1921
if ismissing(name)
@@ -103,7 +105,7 @@ Gets an experiment if one alrady exists, or creates a new one.
103105
An instance of type [`MLFlowExperiment`](@ref)
104106
105107
"""
106-
function getorcreateexperiment(mlf::MLFlow, experiment_name::String; artifact_location=missing, tags=missing)
108+
function getorcreateexperiment(mlf::MLFlow, experiment_name::String; artifact_location="./mlruns", tags=missing)
107109
experiment = getexperiment(mlf, experiment_name)
108110

109111
if ismissing(experiment)

test/test_loggers.jl

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ end
120120
end
121121

122122
@testset "logartifact_error" begin
123-
@test_broken logartifact(mlf, r, "/etc/shadow")
123+
@test_broken logartifact(mlf, r, "/etc/misina")
124124
end
125125

126126
deleteexperiment(mlf, e)
@@ -167,20 +167,29 @@ end
167167
runname = "run-$(UUIDs.uuid4())"
168168
r = createrun(mlf, e.experiment_id)
169169

170+
tempfilename = "./mlflowclient-tempfile.txt"
171+
172+
open(tempfilename, "w") do file
173+
write(file, "Hello, world!\n")
174+
end
175+
176+
logartifact(mlf, r, tempfilename)
177+
170178
@testset "listartifacts_by_run_id" begin
171179
artifacts = listartifacts(mlf, r.info.run_id)
172-
@test length(artifacts) == 0
180+
@test length(artifacts) == 1
173181
end
174182

175183
@testset "listartifacts_by_run" begin
176184
artifacts = listartifacts(mlf, r)
177-
@test length(artifacts) == 0
185+
@test length(artifacts) == 1
178186
end
179187

180188
@testset "listartifacts_by_run_info" begin
181189
artifacts = listartifacts(mlf, r.info)
182-
@test length(artifacts) == 0
190+
@test length(artifacts) == 1
183191
end
184192

193+
rm(tempfilename)
185194
deleteexperiment(mlf, e)
186195
end

0 commit comments

Comments
 (0)