@@ -49,6 +49,12 @@ def testGetSuccessfulNodeExecutions(self):
49
49
)
50
50
self .assertEqual (_ids (result ), _ids ([e1 , e2 ]))
51
51
52
+ with self .subTest ('With execution limit' ):
53
+ result = store_ext .get_successful_node_executions (
54
+ self .store , pipeline_id = 'my-pipeline' , node_id = 'my-node' , limit = 1
55
+ )
56
+ self .assertEqual (_ids (result ), _ids ([e1 ]))
57
+
52
58
with self .subTest ('Bad pipeline_id' ):
53
59
result = store_ext .get_successful_node_executions (
54
60
self .store , pipeline_id = 'not-exist' , node_id = 'my-node'
@@ -115,8 +121,9 @@ def testGetLiveOutputArtifactsOfNode(self):
115
121
)
116
122
self .assertEqual (_sorted_ids (result ), _sorted_ids ([y2 ]))
117
123
118
- def testGetLiveOutputArtifactsOfNodeByOutputKey (self ):
119
- c = self .put_context ('node' , 'my-pipeline.my-node' )
124
+ def testGetLiveOutputArtifactsOfNodeByOutputKeySync (self ):
125
+ c1 = self .put_context ('pipeline_run' , 'run-20230413' )
126
+ c2 = self .put_context ('node' , 'my-pipeline.my-node' )
120
127
x1 = self .put_artifact ('X' )
121
128
x2 = self .put_artifact ('X' )
122
129
x3 = self .put_artifact ('X' )
@@ -130,24 +137,118 @@ def testGetLiveOutputArtifactsOfNodeByOutputKey(self):
130
137
z3 = self .put_artifact ('Z' , state = 'ABANDONED' )
131
138
132
139
self .put_execution (
133
- 'E' , inputs = {'x' : [x1 ]}, outputs = {'y' : [y1 ], 'z' : [z1 ]}, contexts = [c ]
140
+ 'E' ,
141
+ inputs = {'x' : [x1 ]},
142
+ outputs = {'y' : [y1 ], 'z' : [z1 ]},
143
+ contexts = [c1 , c2 ],
134
144
)
135
145
self .put_execution (
136
146
'E' ,
137
147
inputs = {'x' : [x2 ]},
138
148
outputs = {'y' : [y2 , y3 , y4 ], 'z' : [z2 ]},
139
- contexts = [c ],
149
+ contexts = [c1 , c2 ],
140
150
)
141
151
self .put_execution (
142
- 'E' , inputs = {'x' : [x3 ]}, outputs = {'y' : [y5 ], 'z' : [z3 ]}, contexts = [c ]
152
+ 'E' ,
153
+ inputs = {'x' : [x3 ]},
154
+ outputs = {'y' : [y5 ], 'z' : [z3 ]},
155
+ contexts = [c1 , c2 ],
143
156
)
144
157
145
- result = store_ext .get_live_output_artifacts_of_node_by_output_key (
146
- self .store , pipeline_id = 'my-pipeline' , node_id = 'my-node'
158
+ with self .subTest ('With execution limit=None' ):
159
+ result = store_ext .get_live_output_artifacts_of_node_by_output_key (
160
+ self .store ,
161
+ pipeline_id = 'my-pipeline' ,
162
+ node_id = 'my-node' ,
163
+ pipeline_run_id = 'run-20230413' ,
164
+ )
165
+ self .assertDictEqual (
166
+ result , {'y' : [[y5 ], [y3 , y4 ], [y1 ]], 'z' : [[], [z2 ], [z1 ]]}
167
+ )
168
+ with self .subTest ('With execution limit=2' ):
169
+ result = store_ext .get_live_output_artifacts_of_node_by_output_key (
170
+ self .store ,
171
+ pipeline_id = 'my-pipeline' ,
172
+ node_id = 'my-node' ,
173
+ pipeline_run_id = 'run-20230413' ,
174
+ execution_limit = 2 ,
175
+ )
176
+ self .assertDictEqual (result , {'y' : [[y5 ], [y3 , y4 ]], 'z' : [[], [z2 ]]})
177
+ with self .subTest ('With execution limit=0' ):
178
+ result = store_ext .get_live_output_artifacts_of_node_by_output_key (
179
+ self .store ,
180
+ pipeline_id = 'my-pipeline' ,
181
+ node_id = 'my-node' ,
182
+ pipeline_run_id = 'run-20230413' ,
183
+ execution_limit = 0 ,
184
+ )
185
+ self .assertDictEqual (
186
+ result , {'y' : [[y5 ], [y3 , y4 ], [y1 ]], 'z' : [[], [z2 ], [z1 ]]}
187
+ )
188
+
189
+ def testGetLiveOutputArtifactsOfNodeByOutputKeyAsync (self ):
190
+ c1 = self .put_context ('node' , 'my-pipeline.my-node' )
191
+ x1 = self .put_artifact ('X' )
192
+ x2 = self .put_artifact ('X' )
193
+ x3 = self .put_artifact ('X' )
194
+ y1 = self .put_artifact ('Y' )
195
+ y2 = self .put_artifact ('Y' , state = 'DELETED' )
196
+ y3 = self .put_artifact ('Y' )
197
+ y4 = self .put_artifact ('Y' )
198
+ y5 = self .put_artifact ('Y' )
199
+ z1 = self .put_artifact ('Z' )
200
+ z2 = self .put_artifact ('Z' )
201
+ z3 = self .put_artifact ('Z' , state = 'ABANDONED' )
202
+
203
+ self .put_execution (
204
+ 'E' ,
205
+ inputs = {'x' : [x1 ]},
206
+ outputs = {'y' : [y1 ], 'z' : [z1 ]},
207
+ contexts = [c1 ],
147
208
)
148
- self .assertDictEqual (
149
- result , {'y' : [[y5 ], [y3 , y4 ], [y1 ]], 'z' : [[], [z2 ], [z1 ]]}
209
+ self .put_execution (
210
+ 'E' ,
211
+ inputs = {'x' : [x2 ]},
212
+ outputs = {'y' : [y2 , y3 , y4 ], 'z' : [z2 ]},
213
+ contexts = [c1 ],
150
214
)
215
+ self .put_execution (
216
+ 'E' ,
217
+ inputs = {'x' : [x3 ]},
218
+ outputs = {'y' : [y5 ], 'z' : [z3 ]},
219
+ contexts = [c1 ],
220
+ )
221
+
222
+ with self .subTest ('With execution limit=None' ):
223
+ result = store_ext .get_live_output_artifacts_of_node_by_output_key (
224
+ self .store ,
225
+ pipeline_id = 'my-pipeline' ,
226
+ node_id = 'my-node' ,
227
+ pipeline_run_id = '' ,
228
+ )
229
+ self .assertDictEqual (
230
+ result , {'y' : [[y5 ], [y3 , y4 ], [y1 ]], 'z' : [[], [z2 ], [z1 ]]}
231
+ )
232
+ with self .subTest ('With execution limit=2' ):
233
+ result = store_ext .get_live_output_artifacts_of_node_by_output_key (
234
+ self .store ,
235
+ pipeline_id = 'my-pipeline' ,
236
+ node_id = 'my-node' ,
237
+ pipeline_run_id = '' ,
238
+ execution_limit = 2 ,
239
+ )
240
+ self .assertDictEqual (result , {'y' : [[y5 ], [y3 , y4 ]], 'z' : [[], [z2 ]]})
241
+ with self .subTest ('With execution limit=0' ):
242
+ result = store_ext .get_live_output_artifacts_of_node_by_output_key (
243
+ self .store ,
244
+ pipeline_id = 'my-pipeline' ,
245
+ node_id = 'my-node' ,
246
+ pipeline_run_id = '' ,
247
+ execution_limit = 0 ,
248
+ )
249
+ self .assertDictEqual (
250
+ result , {'y' : [[y5 ], [y3 , y4 ], [y1 ]], 'z' : [[], [z2 ], [z1 ]]}
251
+ )
151
252
152
253
153
254
if __name__ == '__main__' :
0 commit comments