1
1
"""
2
- MLFlow(baseuri; apiversion)
2
+ MLFlow
3
3
4
4
Base type which defines location and version for MLFlow API service.
5
5
6
6
# Fields
7
7
- `baseuri::String`: base MLFlow tracking URI, e.g. `http://localhost:5000`
8
8
- `apiversion`: used API version, e.g. `2.0`
9
9
10
+ # Constructors
11
+
12
+ - `MLFlow(baseuri; apiversion=2.0)`
10
13
# Examples
11
14
``` julia-repl
12
15
julia> mlf = MLFlow("http://localhost:5000")
13
16
MLFlow("http://localhost:5000", 2.0)
14
17
```
18
+
15
19
"""
16
20
struct MLFlow
17
21
baseuri:: String
@@ -30,6 +34,12 @@ Represents an MLFlow experiment.
30
34
- `experiment_id::Integer`: experiment identifier.
31
35
- `tags::Any`: list of tags.
32
36
- `artifact_location::String`: where are experiment artifacts stored.
37
+
38
+ # Constructors
39
+
40
+ - `MLFlowExperiment(name, lifecycle_stage, experiment_id, tags, artifact_location)`
41
+ - `MLFlowExperiment(exp::Dict{String,Any})`
42
+
33
43
"""
34
44
struct MLFlowExperiment
35
45
name:: String
@@ -60,11 +70,14 @@ Represents the status of an MLFlow Run.
60
70
# Fields
61
71
- `status::String`: one of RUNNING/SCHEDULED/FINISHED/FAILED/KILLED
62
72
73
+ # Constructors
74
+
75
+ - `MLFlowRunStatus(status::String)`
63
76
"""
64
77
struct MLFlowRunStatus
65
78
status:: String
66
79
67
- function MLFlowRunStatus (status)
80
+ function MLFlowRunStatus (status:: String )
68
81
acceptable_statuses = [" RUNNING" , " SCHEDULED" , " FINISHED" , " FAILED" , " KILLED" ]
69
82
status ∈ acceptable_statuses || error (" Invalid status $status - choose one of $acceptable_statuses " )
70
83
new (status)
77
90
Represents run metadata.
78
91
79
92
# Fields
80
- - `run_id::String`
81
- - `experiment_id::Integer`
82
- - `status::MLFlowRunStatus`
83
- - `start_time::Union{Int64,Missing}`
84
- - `end_time::Union{Int64,Missing}`
85
- - `artifact_uri::String`
86
- - `lifecycle_stage::String`
93
+ - `run_id::String`: run identifier.
94
+ - `experiment_id::Integer`: experiment identifier.
95
+ - `status::MLFlowRunStatus`: run status.
96
+ - `start_time::Union{Int64,Missing}`: when was the run started, UNIX time in milliseconds.
97
+ - `end_time::Union{Int64,Missing}`: when did the run end, UNIX time in milliseconds.
98
+ - `artifact_uri::String`: where are artifacts from this run stored.
99
+ - `lifecycle_stage::String`: one of `active` or `deleted`.
100
+
101
+ # Constructors
102
+
103
+ - `MLFlowRunInfo(run_id, experiment_id, status, start_time, end_time, artifact_uri, lifecycle_stage)`
104
+ - `MLFlowRunInfo(info::Dict{String,Any})`
87
105
"""
88
106
struct MLFlowRunInfo
89
107
run_id:: String
@@ -127,26 +145,68 @@ struct MLFlowRunInfo
127
145
end
128
146
end
129
147
148
+ """
149
+ MLFlowRunDataMetric
150
+
151
+ Represents a metric.
152
+
153
+ # Fields
154
+ - `key::String`: metric identifier.
155
+ - `value::Float64`: metric value.
156
+ - `step::Int64`: step.
157
+ - `timestamp::Int64`: timestamp in UNIX time in milliseconds.
158
+
159
+ # Constructors
160
+
161
+ - `MLFlowRunDataMetric(d::Dict{String,Any})`
162
+
163
+ """
164
+ struct MLFlowRunDataMetric
165
+ key:: String
166
+ value:: Float64
167
+ step:: Int64
168
+ timestamp:: Int64
169
+ function MLFlowRunDataMetric (d:: Dict{String,Any} )
170
+ key = d[" key" ]
171
+ value = d[" value" ]
172
+ step = parse (Int64, d[" step" ])
173
+ timestamp = parse (Int64, d[" timestamp" ])
174
+ new (key, value, step, timestamp)
175
+ end
176
+ end
177
+
178
+
130
179
"""
131
180
MLFlowRunData
132
181
133
182
Represents run data.
134
183
135
184
# Fields
136
- - `metrics`
137
- - `params`
138
- - `tags`
185
+ - `metrics::Vector{MLFlowRunDataMetric}`: run metrics.
186
+ - `params::Dict{String,String}`: run parameters.
187
+ - `tags`: list of run tags.
139
188
140
- # TODO
141
- Incomplete functionality.
189
+ # Constructors
190
+
191
+ - `MLFlowRunData(data::Dict{String,Any})`
142
192
143
193
"""
144
194
struct MLFlowRunData
145
- metrics
146
- params
195
+ metrics:: Vector{MLFlowRunDataMetric}
196
+ params:: Union{Dict{String,String},Missing}
147
197
tags
148
198
function MLFlowRunData (data:: Dict{String,Any} )
149
- new ([], [], []) # TODO : add functionality
199
+ metrics = haskey (data, " metrics" ) ? MLFlowRunDataMetric .(data[" metrics" ]) : MLFlowRunDataMetric[]
200
+ if haskey (data, " params" )
201
+ params = Dict {String,String} ()
202
+ for p in data[" params" ]
203
+ params[p[" key" ]] = p[" value" ]
204
+ end
205
+ else
206
+ params = Dict {String,String} ()
207
+ end
208
+ tags = haskey (data, " tags" ) ? data[" tags" ] : missing
209
+ new (metrics, params, tags)
150
210
end
151
211
end
152
212
@@ -158,11 +218,23 @@ Represents an MLFlow run.
158
218
# Fields
159
219
- `info::MLFlowRunInfo`: Run metadata.
160
220
- `data::MLFlowRunData`: Run data.
221
+
222
+ # Constructors
223
+
224
+ - `MLFlowRun(rundata::MLFlowRunData)`
225
+ - `MLFlowRun(runinfo::MLFlowRunInfo)`
226
+ - `MLFlowRun(info::Dict{String,Any})`
227
+ - `MLFlowRun(info::Dict{String,Any}, data::Dict{String,Any})`
228
+
161
229
"""
162
230
struct MLFlowRun
163
- info:: MLFlowRunInfo
231
+ info:: Union{ MLFlowRunInfo,Missing}
164
232
data:: Union{MLFlowRunData,Missing}
165
233
234
+ function MLFlowRun (rundata:: MLFlowRunData )
235
+ info = missing
236
+ new (info, rundata)
237
+ end
166
238
function MLFlowRun (runinfo:: MLFlowRunInfo )
167
239
data = missing
168
240
new (runinfo, data)
0 commit comments