From 15851b54cd4438f6f58be2b1b9bc3543cb25fac5 Mon Sep 17 00:00:00 2001 From: ChanHyeok Shin <46867834+P1naCol4da@users.noreply.github.com> Date: Fri, 6 Nov 2026 15:39:18 +0900 Subject: [PATCH 1/5] Fix transitive rerun traversal and request collapsing --- orquesta/conducting.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/orquesta/conducting.py b/orquesta/conducting.py index 6fd97ec8..17f8f873 100644 --- a/orquesta/conducting.py +++ b/orquesta/conducting.py @@ -109,6 +109,7 @@ def get_tasks_by_status(self, statuses, last_occurrence=True): def get_task_sequence(self, task_id, route): idx = self.tasks[constants.TASK_STATE_ROUTE_FORMAT % (task_id, str(route))] seq = [(idx, self.sequence[idx])] + visited = {idx} q = queue.Queue() q.put((task_id, route)) @@ -119,10 +120,10 @@ def get_task_sequence(self, task_id, route): for i, t in enumerate(self.sequence): for k, v in t["prev"].items(): p = self.sequence[v] - if p["id"] == task_id and p["route"] == route: + if p["id"] == task_id and p["route"] == route and i not in visited: + visited.add(i) seq.append((i, t)) - if (i, t) not in seq: - q.put((t["id"], t["route"])) + q.put((t["id"], t["route"])) return seq @@ -1232,10 +1233,15 @@ def _collapse_task_rerun_requests(self, tasks=None): # task rerun requests. If they are not collapsed/consolidated, then the rerun # will result in multiple branches of executions. if len(tasks) > 1: - # The for loops below identify task requests that have subsequent task sequences - # not in other task requests. + # Keep a requested task only when no other requested task contains all + # of the task-state entries in its execution sequence. result = { - k: i for k, i in result.items() for j in result.values() if len(set(i) - set(j)) > 0 + k: indices + for k, indices in result.items() + if not any( + other_k != k and set(indices) < set(other_indices) + for other_k, other_indices in result.items() + ) } return result From c6f6af72e692d5ba8e73f397b9c305156b42b590 Mon Sep 17 00:00:00 2001 From: ChanHyeok Shin <46867834+P1naCol4da@users.noreply.github.com> Date: Fri, 6 Nov 2026 15:39:33 +0900 Subject: [PATCH 2/5] Add regression coverage for transitive rerun requests --- .../conducting/test_rerun_dedup_transitive.py | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 orquesta/tests/unit/conducting/test_rerun_dedup_transitive.py diff --git a/orquesta/tests/unit/conducting/test_rerun_dedup_transitive.py b/orquesta/tests/unit/conducting/test_rerun_dedup_transitive.py new file mode 100644 index 00000000..34bdc6ee --- /dev/null +++ b/orquesta/tests/unit/conducting/test_rerun_dedup_transitive.py @@ -0,0 +1,95 @@ +"""Regression tests for transitive task rerun request deduplication.""" + +import pytest +import yaml + +from orquesta import conducting +from orquesta import events +from orquesta import requests +from orquesta import statuses +from orquesta.specs import native as native_specs + + +SHAPES = { + "chain3": ( + ("task1", "task2", "task3"), + (("task1", "task2"), ("task2", "task3")), + ), + "chain4": ( + ("task1", "task2", "task3", "task4"), + (("task1", "task2"), ("task2", "task3"), ("task3", "task4")), + ), + "fork3": ( + ("task1", "task2", "task3"), + (("task1", "task2"), ("task1", "task3")), + ), +} + + +def _completed_conductor(shape): + """Run a small real-conductor workflow to succeeded with synthetic events.""" + nodes, edges = SHAPES[shape] + graph = {node: [] for node in nodes} + for predecessor, successor in edges: + graph[predecessor].append(successor) + + tasks = {} + for node in nodes: + task = {"action": "core.noop"} + if graph[node]: + task["next"] = [ + {"when": "<% succeeded() %>", "do": next_task} + for next_task in graph[node] + ] + tasks[node] = task + + workflow_yaml = yaml.safe_dump( + {"version": 1.0, "tasks": tasks}, sort_keys=False + ) + spec = native_specs.WorkflowSpec(workflow_yaml) + assert spec.inspect() == {} + + conductor = conducting.WorkflowConductor(spec) + conductor.request_workflow_status(statuses.RUNNING) + seen = set() + for _ in range(len(nodes) + 2): + next_tasks = conductor.get_next_tasks() + if not next_tasks: + break + for task in next_tasks: + task_id, route = task["id"], task["route"] + assert task_id not in seen, "Unexpected duplicate initial execution" + seen.add(task_id) + conductor.update_task_state( + task_id, route, events.ActionExecutionEvent(statuses.RUNNING) + ) + conductor.update_task_state( + task_id, route, events.ActionExecutionEvent(statuses.SUCCEEDED) + ) + + assert seen == set(nodes) + assert conductor.get_workflow_status() == statuses.SUCCEEDED + return conductor + + +@pytest.mark.parametrize( + "shape,requested,expected", + [ + ("chain3", ("task1", "task3"), ("task1",)), + ("chain3", ("task1", "task2", "task3"), ("task1",)), + ("chain4", ("task1", "task4"), ("task1",)), + ("fork3", ("task1", "task2", "task3"), ("task1",)), + ("fork3", ("task2", "task3"), ("task2", "task3")), + ("chain3", ("task3",), ("task3",)), + ], +) +def test_rerun_request_collapses_transitive_descendants(shape, requested, expected): + conductor = _completed_conductor(shape) + conductor.request_workflow_rerun( + task_requests=[requests.TaskRerunRequest.new(node, route=0) for node in requested] + ) + assert conductor.get_workflow_status() == statuses.RESUMING + assert sorted(t["id"] for t in conductor.workflow_state.get_staged_tasks()) == sorted( + expected + ) + assert sorted(t["id"] for t in conductor.get_next_tasks()) == sorted(expected) From 4da41ffefb684b73cb82c2200e718bad8ee2e231 Mon Sep 17 00:00:00 2001 From: ChanHyeok Shin <46867834+P1naCol4da@users.noreply.github.com> Date: Fri, 6 Nov 2026 15:49:33 +0900 Subject: [PATCH 3/5] Fix test license header and import order for CI --- .../conducting/test_rerun_dedup_transitive.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/orquesta/tests/unit/conducting/test_rerun_dedup_transitive.py b/orquesta/tests/unit/conducting/test_rerun_dedup_transitive.py index 34bdc6ee..3c03914e 100644 --- a/orquesta/tests/unit/conducting/test_rerun_dedup_transitive.py +++ b/orquesta/tests/unit/conducting/test_rerun_dedup_transitive.py @@ -1,3 +1,17 @@ +# Copyright 2026 P1naCol4da. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Regression tests for transitive task rerun request deduplication.""" import pytest @@ -6,8 +20,8 @@ from orquesta import conducting from orquesta import events from orquesta import requests -from orquesta import statuses from orquesta.specs import native as native_specs +from orquesta import statuses SHAPES = { From 1d1ec7e160cbe92adf8f4a204c5757b29275e1ef Mon Sep 17 00:00:00 2001 From: ChanHyeok Shin <46867834+P1naCol4da@users.noreply.github.com> Date: Fri, 6 Nov 2026 15:52:55 +0900 Subject: [PATCH 4/5] Format rerun regression tests with project Black line length --- .../tests/unit/conducting/test_rerun_dedup_transitive.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/orquesta/tests/unit/conducting/test_rerun_dedup_transitive.py b/orquesta/tests/unit/conducting/test_rerun_dedup_transitive.py index 3c03914e..e0245845 100644 --- a/orquesta/tests/unit/conducting/test_rerun_dedup_transitive.py +++ b/orquesta/tests/unit/conducting/test_rerun_dedup_transitive.py @@ -57,9 +57,7 @@ def _completed_conductor(shape): ] tasks[node] = task - workflow_yaml = yaml.safe_dump( - {"version": 1.0, "tasks": tasks}, sort_keys=False - ) + workflow_yaml = yaml.safe_dump({"version": 1.0, "tasks": tasks}, sort_keys=False) spec = native_specs.WorkflowSpec(workflow_yaml) assert spec.inspect() == {} @@ -103,7 +101,5 @@ def test_rerun_request_collapses_transitive_descendants(shape, requested, expect task_requests=[requests.TaskRerunRequest.new(node, route=0) for node in requested] ) assert conductor.get_workflow_status() == statuses.RESUMING - assert sorted(t["id"] for t in conductor.workflow_state.get_staged_tasks()) == sorted( - expected - ) + assert sorted(t["id"] for t in conductor.workflow_state.get_staged_tasks()) == sorted(expected) assert sorted(t["id"] for t in conductor.get_next_tasks()) == sorted(expected) From 234233e1ca3a55a068cfac31adf95c4acdba7959 Mon Sep 17 00:00:00 2001 From: ChanHyeok Shin <46867834+P1naCol4da@users.noreply.github.com> Date: Fri, 6 Nov 2026 15:58:29 +0900 Subject: [PATCH 5/5] Simplify regression test expressions to satisfy Black formatting --- .../conducting/test_rerun_dedup_transitive.py | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/orquesta/tests/unit/conducting/test_rerun_dedup_transitive.py b/orquesta/tests/unit/conducting/test_rerun_dedup_transitive.py index e0245845..a5a8b1ed 100644 --- a/orquesta/tests/unit/conducting/test_rerun_dedup_transitive.py +++ b/orquesta/tests/unit/conducting/test_rerun_dedup_transitive.py @@ -51,10 +51,10 @@ def _completed_conductor(shape): for node in nodes: task = {"action": "core.noop"} if graph[node]: - task["next"] = [ - {"when": "<% succeeded() %>", "do": next_task} - for next_task in graph[node] - ] + next_steps = [] + for next_task in graph[node]: + next_steps.append({"when": "<% succeeded() %>", "do": next_task}) + task["next"] = next_steps tasks[node] = task workflow_yaml = yaml.safe_dump({"version": 1.0, "tasks": tasks}, sort_keys=False) @@ -72,12 +72,10 @@ def _completed_conductor(shape): task_id, route = task["id"], task["route"] assert task_id not in seen, "Unexpected duplicate initial execution" seen.add(task_id) - conductor.update_task_state( - task_id, route, events.ActionExecutionEvent(statuses.RUNNING) - ) - conductor.update_task_state( - task_id, route, events.ActionExecutionEvent(statuses.SUCCEEDED) - ) + running_event = events.ActionExecutionEvent(statuses.RUNNING) + conductor.update_task_state(task_id, route, running_event) + success_event = events.ActionExecutionEvent(statuses.SUCCEEDED) + conductor.update_task_state(task_id, route, success_event) assert seen == set(nodes) assert conductor.get_workflow_status() == statuses.SUCCEEDED @@ -97,9 +95,8 @@ def _completed_conductor(shape): ) def test_rerun_request_collapses_transitive_descendants(shape, requested, expected): conductor = _completed_conductor(shape) - conductor.request_workflow_rerun( - task_requests=[requests.TaskRerunRequest.new(node, route=0) for node in requested] - ) + rerun_requests = [requests.TaskRerunRequest.new(node, route=0) for node in requested] + conductor.request_workflow_rerun(task_requests=rerun_requests) assert conductor.get_workflow_status() == statuses.RESUMING assert sorted(t["id"] for t in conductor.workflow_state.get_staged_tasks()) == sorted(expected) assert sorted(t["id"] for t in conductor.get_next_tasks()) == sorted(expected)