Skip to content

Commit

Permalink
Using defaultdict to simplify target_nodes initialization.
Browse files Browse the repository at this point in the history
  • Loading branch information
lazyFrogLOL committed Jan 9, 2025
1 parent acad0e9 commit 13e3db7
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions api/core/workflow/graph_engine/graph_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import time
import uuid
from collections.abc import Generator, Mapping
from collections import defaultdict
from concurrent.futures import ThreadPoolExecutor, wait
from copy import copy, deepcopy
from datetime import UTC, datetime
Expand Down Expand Up @@ -440,10 +441,8 @@ def _run_parallel_branches(
handle_exceptions: list[str] = [],
) -> Generator[GraphEngineEvent | str, None, None]:

target_nodes: dict[str, list[GraphEdge]] = {}
target_nodes: defaultdict[str, list[GraphEdge]] = defaultdict(list)
for edge in edge_mappings:
if edge.target_node_id not in target_nodes:
target_nodes[edge.target_node_id] = []
target_nodes[edge.target_node_id].append(edge)

for target_node_id, edges in target_nodes.items():
Expand Down

0 comments on commit 13e3db7

Please sign in to comment.