more organization
This commit is contained in:
+12
-13
@@ -45,7 +45,7 @@ class TrackDAG:
|
||||
tickets: A list of Ticket instances defining the graph nodes and edges.
|
||||
[C: src/mcp_client.py:_DDGParser.__init__, src/mcp_client.py:_TextExtractor.__init__]
|
||||
"""
|
||||
self.tickets = tickets
|
||||
self.tickets = tickets
|
||||
self.ticket_map = {t.id: t for t in tickets}
|
||||
|
||||
def cascade_blocks(self) -> None:
|
||||
@@ -64,7 +64,7 @@ class TrackDAG:
|
||||
|
||||
# Use a queue-based propagation (BFS) from all currently blocked tickets
|
||||
queue = [t for t in self.tickets if t.status == 'blocked']
|
||||
idx = 0
|
||||
idx = 0
|
||||
while idx < len(queue):
|
||||
curr = queue[idx]
|
||||
idx += 1
|
||||
@@ -110,16 +110,14 @@ class TrackDAG:
|
||||
if start_ticket.id in visited:
|
||||
continue
|
||||
stack = [(start_ticket.id, False)] # (id, is_backtracking)
|
||||
path = set()
|
||||
path = set()
|
||||
while stack:
|
||||
node_id, is_backtracking = stack.pop()
|
||||
if is_backtracking:
|
||||
path.remove(node_id)
|
||||
continue
|
||||
if node_id in path:
|
||||
return True
|
||||
if node_id in visited:
|
||||
continue
|
||||
if node_id in path: return True
|
||||
if node_id in visited: continue
|
||||
visited.add(node_id)
|
||||
path.add(node_id)
|
||||
stack.append((node_id, True))
|
||||
@@ -140,7 +138,7 @@ class TrackDAG:
|
||||
[C: tests/test_conductor_tech_lead.py:TestTopologicalSort.test_topological_sort_complex, tests/test_conductor_tech_lead.py:TestTopologicalSort.test_topological_sort_cycle, tests/test_conductor_tech_lead.py:TestTopologicalSort.test_topological_sort_empty, tests/test_conductor_tech_lead.py:TestTopologicalSort.test_topological_sort_linear, tests/test_conductor_tech_lead.py:TestTopologicalSort.test_topological_sort_missing_dependency, tests/test_conductor_tech_lead.py:test_topological_sort_vlog, tests/test_dag_engine.py:test_topological_sort, tests/test_dag_engine.py:test_topological_sort_cycle, tests/test_orchestration_logic.py:test_topological_sort, tests/test_orchestration_logic.py:test_topological_sort_circular, tests/test_perf_dag.py:test_dag_edge_cases, tests/test_perf_dag.py:test_dag_performance]
|
||||
"""
|
||||
with get_monitor().scope("dag_topological_sort"):
|
||||
in_degree = {t.id: len(t.depends_on) for t in self.tickets}
|
||||
in_degree = {t.id: len(t.depends_on) for t in self.tickets}
|
||||
dependents = {t.id: [] for t in self.tickets}
|
||||
for t in self.tickets:
|
||||
for dep_id in t.depends_on:
|
||||
@@ -148,11 +146,11 @@ class TrackDAG:
|
||||
dependents[dep_id].append(t.id)
|
||||
|
||||
# Queue starts with nodes having no dependencies
|
||||
queue = [t.id for t in self.tickets if in_degree[t.id] == 0]
|
||||
queue = [t.id for t in self.tickets if in_degree[t.id] == 0]
|
||||
result = []
|
||||
idx = 0
|
||||
idx = 0
|
||||
while idx < len(queue):
|
||||
u = queue[idx]
|
||||
u = queue[idx]
|
||||
idx += 1
|
||||
result.append(u)
|
||||
for v_id in dependents.get(u, []):
|
||||
@@ -178,7 +176,7 @@ class ExecutionEngine:
|
||||
auto_queue: If True, ready tasks will automatically move to 'in_progress'.
|
||||
[C: src/mcp_client.py:_DDGParser.__init__, src/mcp_client.py:_TextExtractor.__init__]
|
||||
"""
|
||||
self.dag = dag
|
||||
self.dag = dag
|
||||
self.auto_queue = auto_queue
|
||||
|
||||
def tick(self) -> List[Ticket]:
|
||||
@@ -215,4 +213,5 @@ class ExecutionEngine:
|
||||
"""
|
||||
ticket = self.dag.ticket_map.get(task_id)
|
||||
if ticket:
|
||||
ticket.status = status
|
||||
ticket.status = status
|
||||
|
||||
Reference in New Issue
Block a user