@@ -136,8 +136,12 @@ def create_running_workflow_step(
136
136
* ,
137
137
running_workflow_id : str ,
138
138
step : str ,
139
+ replica : int = 0 ,
139
140
prior_running_workflow_step_id : str | None = None ,
140
141
) -> dict [str , Any ]:
142
+ if replica :
143
+ assert replica > 0
144
+
141
145
UnitTestWorkflowAPIAdapter .lock .acquire ()
142
146
with open (_RUNNING_WORKFLOW_STEP_PICKLE_FILE , "rb" ) as pickle_file :
143
147
running_workflow_step = Unpickler (pickle_file ).load ()
@@ -150,6 +154,7 @@ def create_running_workflow_step(
150
154
"name" : step ,
151
155
"done" : False ,
152
156
"success" : False ,
157
+ "replica" : replica ,
153
158
"variables" : {},
154
159
"running_workflow" : {"id" : running_workflow_id },
155
160
}
@@ -177,24 +182,28 @@ def get_running_workflow_step(
177
182
return {}, 0
178
183
response = running_workflow_step [running_workflow_step_id ]
179
184
response ["id" ] = running_workflow_step_id
185
+ if response ["replica" ] == 0 :
186
+ _ = response .pop ("replica" )
180
187
return response , 0
181
188
182
189
def get_running_workflow_step_by_name (
183
- self , * , name : str , running_workflow_id : str
190
+ self , * , name : str , running_workflow_id : str , replica : int = 0
184
191
) -> dict [str , Any ]:
192
+ if replica :
193
+ assert replica > 0
185
194
UnitTestWorkflowAPIAdapter .lock .acquire ()
186
195
with open (_RUNNING_WORKFLOW_STEP_PICKLE_FILE , "rb" ) as pickle_file :
187
196
running_workflow_step = Unpickler (pickle_file ).load ()
188
197
UnitTestWorkflowAPIAdapter .lock .release ()
189
198
190
- print (f"name={ name } running_workflow_id={ running_workflow_id } " )
191
199
for rwfs_id , record in running_workflow_step .items ():
192
- print (f"rwfs_id={ rwfs_id } record={ record } " )
193
200
if record ["running_workflow" ]["id" ] != running_workflow_id :
194
201
continue
195
- if record ["name" ] == name :
202
+ if record ["name" ] == name and record [ "replica" ] == replica :
196
203
response = record
197
204
response ["id" ] = rwfs_id
205
+ if record ["replica" ] == 0 :
206
+ _ = response .pop ("replica" )
198
207
return response , 0
199
208
return {}, 0
200
209
0 commit comments