Skip to content

Commit ce126f8

Browse files
committed
add temporary location of saving artifacts
1 parent e29ff3f commit ce126f8

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

AutoAI/src/automlflowclassification.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,11 @@ function fit!(mlfcl::AutoMLFlowClassification, X::DataFrame, Y::Vector)
100100
MLF.log_metric("bestperformance", autoclass.model[:performance].mean[1])
101101
# save model in mlflow
102102
artifact_name = mlfcl.model[:artifact_name]
103-
serialize(artifact_name, autoclass)
104-
MLF.log_artifact(artifact_name)
103+
# use temporary directory
104+
tmpdir = tempdir()
105+
artifact_location = joinpath(tmpdir, artifact_name)
106+
serialize(artifact_location, autoclass)
107+
MLF.log_artifact(artifact_location)
105108
# save model in memory
106109
mlfcl.model[:autoclass] = autoclass
107110
bestmodel_uri = MLF.get_artifact_uri(artifact_path=artifact_name)
@@ -124,6 +127,7 @@ function transform!(mlfcl::AutoMLFlowClassification, X::DataFrame)
124127

125128
try
126129
model_artifacts = MLF.artifacts.list_artifacts(run_id=run_id)
130+
@assert model_artifacts[0].path |> string == "autoclass.bin"
127131
catch e
128132
@info e
129133
throw("Artifact $artifact_name does not exist in run_id = $run_id")

AutoAI/src/automlflowregression.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,11 @@ function fit!(mlfreg::AutoMLFlowRegression, X::DataFrame, Y::Vector)
101101
MLF.log_metric("bestperformance", autoreg.model[:performance].mean[1])
102102
# save model in mlflow
103103
artifact_name = mlfreg.model[:artifact_name]
104-
serialize(artifact_name, autoreg)
105-
MLF.log_artifact(artifact_name)
104+
# use temporary directory
105+
tmpdir = tempdir()
106+
artifact_location = joinpath(tmpdir, artifact_name)
107+
serialize(artifact_location, autoreg)
108+
MLF.log_artifact(artifact_location)
106109
# save model in memory
107110
mlfreg.model[:autoreg] = autoreg
108111
bestmodel_uri = MLF.get_artifact_uri(artifact_path=artifact_name)
@@ -125,6 +128,7 @@ function transform!(mlfreg::AutoMLFlowRegression, X::DataFrame)
125128

126129
try
127130
model_artifacts = MLF.artifacts.list_artifacts(run_id=run_id)
131+
@assert model_artifacts[0].path |> string == "autoreg.bin"
128132
catch e
129133
@info e
130134
throw("Artifact $artifact_name does not exist in run_id = $run_id")
@@ -151,8 +155,9 @@ function mlfregdriver()
151155
Yc = fit_transform!(mlfreg, X, Y)
152156
println("mse = ", mean((Y - Yc) .^ 2))
153157

154-
### test prediction using exisiting trained model from artifacts
158+
## test prediction using exisiting trained model from artifacts
155159
run_id = mlfreg.model[:run_id]
160+
#run_id = "d7ea4d0582bb4519a96b36efbe1eda6a"
156161
newmfreg = AutoMLFlowRegression(Dict(:run_id => run_id))
157162
newmfreg = AutoMLFlowRegression()
158163
newmfreg(; run_id=run_id)

0 commit comments

Comments
 (0)