@@ -112,6 +112,26 @@ def get_running_steps(
112
112
# Does nothing at the moment - this is used for the STOP logic.
113
113
return {"count" : 0 , "steps" : []}, 0
114
114
115
+ def get_status_of_all_step_instances_by_name (
116
+ self , * , running_workflow_id : str , name : str
117
+ ) -> tuple [dict [str , Any ], int ]:
118
+ UnitTestWorkflowAPIAdapter .lock .acquire ()
119
+ with open (_RUNNING_WORKFLOW_STEP_PICKLE_FILE , "rb" ) as pickle_file :
120
+ running_workflow_step = Unpickler (pickle_file ).load ()
121
+ UnitTestWorkflowAPIAdapter .lock .release ()
122
+
123
+ steps : list [dict [str , Any ]] = []
124
+ for rwfs_id , record in running_workflow_step .items ():
125
+ if record ["running_workflow" ]["id" ] != running_workflow_id :
126
+ continue
127
+ if record ["name" ] == name :
128
+ response = record
129
+ response ["id" ] = rwfs_id
130
+ if record ["replica" ] == 0 :
131
+ _ = response .pop ("replica" )
132
+ steps .append (response )
133
+ return {"count" : len (steps ), "status" : steps }, 0
134
+
115
135
def set_running_workflow_done (
116
136
self ,
117
137
* ,
@@ -140,10 +160,11 @@ def create_running_workflow_step(
140
160
running_workflow_id : str ,
141
161
step : str ,
142
162
replica : int = 0 ,
163
+ replicas : int = 1 ,
143
164
prior_running_workflow_step_id : str | None = None ,
144
165
) -> tuple [dict [str , Any ], int ]:
145
- if replica :
146
- assert replica > 0
166
+ assert replica >= 0
167
+ assert replicas > replica
147
168
148
169
UnitTestWorkflowAPIAdapter .lock .acquire ()
149
170
with open (_RUNNING_WORKFLOW_STEP_PICKLE_FILE , "rb" ) as pickle_file :
@@ -158,6 +179,7 @@ def create_running_workflow_step(
158
179
"done" : False ,
159
180
"success" : False ,
160
181
"replica" : replica ,
182
+ "replicas" : replicas ,
161
183
"variables" : {},
162
184
"running_workflow" : {"id" : running_workflow_id },
163
185
}
@@ -249,44 +271,6 @@ def set_running_workflow_step_done(
249
271
Pickler (pickle_file ).dump (running_workflow_step )
250
272
UnitTestWorkflowAPIAdapter .lock .release ()
251
273
252
- def get_workflow_steps_driving_this_step (
253
- self ,
254
- * ,
255
- running_workflow_step_id : str ,
256
- ) -> tuple [dict [str , Any ], int ]:
257
- # To accomplish this we get the running workflow for the step,
258
- # then the workflow, then the steps from that workflow.
259
- # We return a dictionary and an HTTP response code.
260
- UnitTestWorkflowAPIAdapter .lock .acquire ()
261
- with open (_RUNNING_WORKFLOW_STEP_PICKLE_FILE , "rb" ) as pickle_file :
262
- running_workflow_step = Unpickler (pickle_file ).load ()
263
- UnitTestWorkflowAPIAdapter .lock .release ()
264
-
265
- assert running_workflow_step_id in running_workflow_step
266
-
267
- running_workflow_id : str = running_workflow_step [running_workflow_step_id ][
268
- "running_workflow"
269
- ]["id" ]
270
- rwf_response , _ = self .get_running_workflow (
271
- running_workflow_id = running_workflow_id
272
- )
273
- assert rwf_response
274
- workflow_id : str = rwf_response ["workflow" ]["id" ]
275
- wf_response , _ = self .get_workflow (workflow_id = workflow_id )
276
- assert wf_response
277
- # Find the caller's python in the step sequence (-1 if not found)
278
- caller_step_index : int = - 1
279
- index : int = 0
280
- for step in wf_response ["steps" ]:
281
- if step ["name" ] == running_workflow_step [running_workflow_step_id ]["name" ]:
282
- caller_step_index = index
283
- break
284
- index += 1
285
- return {
286
- "caller_step_index" : caller_step_index ,
287
- "steps" : wf_response ["steps" ].copy (),
288
- }, 0
289
-
290
274
def get_instance (self , * , instance_id : str ) -> tuple [dict [str , Any ], int ]:
291
275
UnitTestWorkflowAPIAdapter .lock .acquire ()
292
276
with open (_INSTANCE_PICKLE_FILE , "rb" ) as pickle_file :
0 commit comments