Skip to content

Commit a244b41

Browse files
committed
add autoad dockerization support
1 parent 756eaa8 commit a244b41

File tree

7 files changed

+36
-79
lines changed

7 files changed

+36
-79
lines changed

DockerizedAutoAD/CondaPkg.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[deps]
22
mlflow = ""
3-
pycaret = ""
3+
pycaret = "3.3.*"
4+
python = "3.11.*"
45
requests = ""

DockerizedAutoAD/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ LABEL MAINTAINER='Paulito Palmes "paulpalmes@ie.ibm.com"'
33
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y locales build-essential git
44

55
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
6-
dpkg-reconfigure --frontend=noninteractive locales && \
7-
update-locale LANG=en_US.UTF-8
6+
dpkg-reconfigure --frontend=noninteractive locales && \
7+
update-locale LANG=en_US.UTF-8
88

99
ENV LANG en_US.UTF-8
1010
ENV LANGUAGE en_US:en
@@ -19,7 +19,7 @@ COPY automl_sysimage.jl /amlp/
1919
COPY automl_precompile.jl /amlp/
2020
ADD https://github.com/IBM/AutoMLPipeline.jl.git /amlp/AutoMLPipeline/
2121
RUN julia --project -e 'using Pkg;\
22-
Pkg.develop(path="./AutoMLPipeline/AutoAI/");\
22+
Pkg.develop(path="./AutoMLPipeline/AutoAD/");\
2323
Pkg.instantiate();\
2424
Pkg.update();\
2525
Pkg.precompile();\

DockerizedAutoAD/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[deps]
22
AMLPipelineBase = "e3c3008a-8869-4d53-9f34-c96f99c8a2b6"
33
ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63"
4-
AutoAI = "78f36755-6713-4987-acdd-2a78ef0fc2e4"
4+
AutoAD = "a90a1e1f-13cb-41ec-be1f-24b06fd2b474"
55
AutoMLPipeline = "08437348-eef5-4817-bc1b-d4e9459680d6"
66
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
77
CondaPkg = "992eb4ea-22a4-4c89-a5bb-47a3300528ab"

DockerizedAutoAD/automl_precompile.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ import AutoMLPipeline
55
include(joinpath(pkgdir(AutoMLPipeline), "test", "runtests.jl"))
66

77
import AutoAI
8-
include(joinpath(pkgdir(AutoAI), "test", "runtests.jl"))
8+
include(joinpath(pkgdir(AutoAD), "test", "runtests.jl"))
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using PackageCompiler
22
create_sysimage(["AMLPipelineBase", "DataFrames", "StatsBase",
33
"ArgParse", "AutoMLPipeline", "CSV", "Dates", "Distributed",
4-
"Random", "ArgParse", "Test", "Distributed", "PythonCall","AutoAI",
4+
"Random", "ArgParse", "Test", "Distributed", "PythonCall","AutoAD",
55
"Statistics", "Serialization", "StatsBase", "Test"],
66
sysimage_path="automl.so", precompile_execution_file="automl_precompile.jl")

DockerizedAutoAD/main.jl

Lines changed: 26 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using AutoAD: AutoMLFlowAnomalyDetections
12
using Distributed
23
using ArgParse
34
using CSV
@@ -14,108 +15,63 @@ function parse_commandline()
1415
arg_type = String
1516
default = "http://localhost:8080"
1617
"--prediction_type", "-t"
17-
help = "classification, regression, anomalydetection"
18+
help = "timeseriesprediction, anomalydetection"
1819
arg_type = String
19-
default = "classification"
20-
#default = "anomalydetection"
21-
#default = "regression"
22-
"--complexity", "-c"
23-
help = "pipeline complexity"
24-
arg_type = String
25-
default = "low"
20+
default = "anomalydetecion"
2621
"--output_file", "-o"
2722
help = "output location"
2823
arg_type = String
2924
default = "NONE"
30-
"--nfolds", "-f"
31-
help = "number of crossvalidation folds"
32-
arg_type = Int64
33-
default = 3
34-
"--nworkers", "-w"
35-
help = "number of workers"
36-
arg_type = Int64
37-
default = 5
3825
"--votepercent", "-v"
3926
help = "votepercent for anomalydetection ensembles"
4027
arg_type = Float64
4128
default = 0.0
42-
"--no_save"
43-
help = "save model"
44-
action = :store_true
45-
"--predict_only"
46-
help = "no training, predict only"
47-
action = :store_true
4829
"--runid"
4930
help = "runid of experiment for trained model"
5031
arg_type = String
5132
default = "NONE"
5233
"csvfile"
5334
help = "input csv file"
5435
required = true
55-
#default = "iris.csv"
56-
#default = "iris_reg.csv"
5736
end
5837
return parse_args(s; as_symbols=true)
5938
end
6039

61-
#const _cliargs = (; parse_commandline()...)
62-
_cliargs = parse_commandline()
63-
#const _workers = _cliargs[:workers]
64-
_workers = _cliargs[:nworkers]
40+
const _cliargs = (; parse_commandline()...)
41+
#_cliargs = parse_commandline()
42+
const _workers = _cliargs[:workers]
43+
#_workers = _cliargs[:nworkers]
6544

6645
nprocs() == 1 && addprocs(_workers; exeflags=["--project=$(Base.active_project())"])
6746

68-
@everywhere using AutoAI
69-
70-
function autoclassmode(args::Dict)
71-
url = args[:url]
72-
complexity = args[:complexity]
73-
nfolds = args[:nfolds]
74-
nworkers = args[:nworkers]
75-
prediction_type = args[:prediction_type]
76-
impl_args = (; complexity, nfolds, nworkers, prediction_type) |> pairs |> Dict
77-
fname = _cliargs[:csvfile]
78-
df = CSV.read(fname, DataFrame)
79-
X = df[:, 1:end-1]
80-
Y = df[:, end] |> collect
81-
autoclass = AutoMLFlowClassification(Dict(:url => url, :impl_args => impl_args))
82-
Yc = fit_transform!(autoclass, X, Y)
83-
println("accuracy = ", mean(Y .== Yc))
84-
end
47+
@everywhere using AutoAD
8548

86-
function autoregmode(args::Dict)
49+
function autoadmode(args::Dict)
8750
url = args[:url]
88-
complexity = args[:complexity]
89-
nfolds = args[:nfolds]
90-
nworkers = args[:nworkers]
9151
prediction_type = args[:prediction_type]
92-
impl_args = (; complexity, nfolds, nworkers, prediction_type) |> pairs |> Dict
93-
fname = _cliargs[:csvfile]
52+
votepercent = args[:votepercent]
53+
dictargs = (; votepercent, prediction_type) |> pairs |> Dict
54+
fname = args[:csvfile]
9455
df = CSV.read(fname, DataFrame)
95-
X = df[:, 1:end-1]
96-
Y = df[:, end] |> collect
97-
autoreg = AutoMLFlowRegression(Dict(:url => url, :impl_args => impl_args))
98-
Yc = fit_transform!(autoreg, X, Y)
99-
println("mse = ", mean((Y - Yc) .^ 2))
56+
X = df[:, 1:1]
57+
autoad = AutoMLFlowAnomalyDetections(Dict(:url => url, dictargs...))
58+
Yc = fit_transform!(autoad, X)
59+
println("output:", Yc |> x -> first(x, 5))
60+
return Yc
10061
end
10162

102-
function autoadmode(args::Dict)
103-
url = args[:url]
104-
votepercent = args[:votepercent]
105-
X = vcat(5 * cos.(-10:10), sin.(-30:30), 3 * cos.(-10:10), 2 * tan.(-10:10), sin.(-30:30)) |> x -> DataFrame([x], :auto)
106-
mlfad = AutoMLFlowAnomalyDetection(Dict(:url => url, :impl_args => Dict(:votepercent => votepercent)))
107-
Yc = fit_transform!(mlfad, X)
108-
println(Yc |> x -> first(x, 5))
63+
function autotsmode(args::Dict)
10964
end
11065

111-
function main()
112-
predtype = _cliargs[:prediction_type]
113-
if predtype == "classification"
114-
autoclassmode(_cliargs)
115-
elseif predtype == "regression"
116-
autoregmode(_cliargs)
66+
function main(args)
67+
predtype = args[:prediction_type]
68+
if predtype == "anomalydetection"
69+
autoadmode(args)
70+
elseif predtype == "timeseriesprediction"
71+
autotsmode(_cliargs)
11772
elseif predtype == "anomalydetection"
11873
autoadmode(_cliargs)
11974
end
12075
end
121-
main()
76+
77+
main(_cliargs)

DockerizedAutoAD/run.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
docker build -t automlai --platform=linux/amd64 .
2-
docker run -it --rm --platform=linux/amd64 automlai
1+
docker build -t automlad --platform=linux/amd64 .
2+
docker run -it --rm --platform=linux/amd64 automlad
33

44
# julia --project -- ./main.jl -c high -t regression -f 3 -w 7 iris_reg.csv
55
# julia --project -- ./main.jl -c low -t classification -f 3 -w 3 iris.csv

0 commit comments

Comments
 (0)