Skip to content

Commit d3541fb

Browse files
committed
need to copy staged so it isn't mutated for with items
1 parent 0f58986 commit d3541fb

File tree

3 files changed

+8
-15
lines changed

3 files changed

+8
-15
lines changed

orquesta/conducting.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def deserialize(cls, data):
6868
instance.contexts = data.get("contexts", list())
6969
instance.routes = data.get("routes", list())
7070
instance.sequence = data.get("sequence", list())
71-
instance.staged = data.get("staged", list())
71+
instance.staged = json_util.deepcopy(data.get("staged", list()))
7272
instance.status = data.get("status", statuses.UNSET)
7373
instance.tasks = data.get("tasks", dict())
7474
instance.reruns = data.get("reruns", list())
@@ -481,8 +481,7 @@ def get_workflow_terminal_context(self):
481481
for idx, task in other_term_tasks:
482482
# Remove the initial context since the first task processed above already
483483
# inclulded that and we only want to apply the differences.
484-
in_ctx_idxs = [i for index, i in enumerate(task["ctxs"]["in"]) if
485-
index != 0]
484+
in_ctx_idxs = [i for index, i in enumerate(task["ctxs"]["in"]) if index != 0]
486485

487486
wf_term_ctx = dict_util.merge_dicts(
488487
wf_term_ctx, self.get_task_context(in_ctx_idxs), overwrite=True

orquesta/machines.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -527,8 +527,11 @@ def add_context_to_task_item_event(cls, workflow_state, task_id, task_route, ac_
527527
# Make a copy of the items and remove current item under evaluation.
528528
staged_task = workflow_state.get_staged_task(task_id, task_route)
529529
items = staged_task["items"]
530-
items_status = [item.get("status", statuses.UNSET) for index, item in
531-
enumerate(items) if index != ac_ex_event.item_id]
530+
items_status = [
531+
item.get("status", statuses.UNSET)
532+
for index, item in enumerate(items)
533+
if index != ac_ex_event.item_id
534+
]
532535

533536
# Assess various situations.
534537
# todo(aj) loop over list one time and add to each list

orquesta/tests/unit/base.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -209,20 +209,11 @@ def assert_task_list(self, conductor, actual, expected):
209209
expected_copy = copy.deepcopy(expected)
210210

211211
for task in actual_copy:
212-
for staged_task in task["ctx"]["__state"]["staged"]:
213-
if "items" in staged_task:
214-
del staged_task["items"]
215-
216212
task["spec"] = task["spec"].serialize()
217213

218214
for task in expected_copy:
219215
task["ctx"]["__current_task"] = {"id": task["id"], "route": task["route"]}
220-
task["ctx"]["__state"] = copy.deepcopy(conductor.workflow_state.serialize())
221-
222-
for staged_task in task["ctx"]["__state"]["staged"]:
223-
if "items" in staged_task:
224-
del staged_task["items"]
225-
216+
task["ctx"]["__state"] = conductor.workflow_state.serialize()
226217
task["spec"] = task["spec"].serialize()
227218

228219
self.assertListEqual(actual_copy, expected_copy)

0 commit comments

Comments
 (0)