@@ -109,16 +109,18 @@ Searches for runs in an experiment based on filter.
109
109
- `run_view_type::String`: ...
110
110
- `max_results::Integer`: ...
111
111
- `order_by::String`: ...
112
+ - `page_token::String`: paging functionality, handled automatically. Not meant to be passed by the user.
112
113
113
114
# Returns
114
- - a vector of runs that were found
115
+ - vector of [`MLFlowRun`](@ref) runs that were found in the list of experiments.
115
116
116
117
"""
117
118
function searchruns (mlf:: MLFlow , experiment_ids:: AbstractVector{<:Integer} ;
118
119
filter:: String = " " ,
119
120
run_view_type:: String = " ACTIVE_ONLY" ,
120
121
max_results:: Int64 = 50000 ,
121
- order_by:: AbstractVector{<:String} = [" " ]
122
+ order_by:: AbstractVector{<:String} = [" attribute.start_time" ],
123
+ page_token:: String = " "
122
124
)
123
125
endpoint = " runs/search"
124
126
run_view_type ∈ [" ACTIVE_ONLY" , " DELETED_ONLY" , " ALL" ] || error (" Unsupported run_view_type = $run_view_type " )
@@ -127,15 +129,31 @@ function searchruns(mlf::MLFlow, experiment_ids::AbstractVector{<:Integer};
127
129
filter= filter,
128
130
run_view_type= run_view_type,
129
131
max_results= max_results,
132
+ order_by= order_by
130
133
)
131
- if order_by != [ " " ]
132
- kwargs. order_by = order_by
134
+ if ! isempty (page_token)
135
+ kwargs = (; kwargs ... , page_token = page_token)
133
136
end
134
137
135
138
result = mlfpost (mlf, endpoint; kwargs... )
136
- haskey (result, " runs" ) || error (" Malformed result from MLFow" )
139
+ haskey (result, " runs" ) || return MLFlowRun[]
140
+
141
+ runs = map (x -> MLFlowRun (x[" info" ], x[" data" ]), result[" runs" ])
142
+
143
+ # paging functionality
144
+ if haskey (result, " next_page_token" ) && ! isempty (result[" next_page_token" ])
145
+ kwargs = (
146
+ filter= filter,
147
+ run_view_type= run_view_type,
148
+ max_results= max_results,
149
+ order_by= order_by,
150
+ page_token= result[" next_page_token" ]
151
+ )
152
+ nextruns = searchruns (mlf, experiment_ids; kwargs... )
153
+ return vcat (runs, nextruns)
154
+ end
137
155
138
- map (x -> MLFlowRun (x[ " info " ], x[ " data " ]), result[ " runs" ])
156
+ runs
139
157
end
140
158
function searchruns (mlf:: MLFlow , experiment_id:: Integer ; kwargs... )
141
159
searchruns (mlf, [experiment_id]; kwargs... )
0 commit comments