Skip to content

Commit f08957d

Browse files
committed
FIX(MERGE): broken by NEW_DAG_SOLVER (yahoo#26 ...
many commits ago. Never got it bc TC were not checking merges!
1 parent 43ca37e commit f08957d

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

graphkit/functional.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
# Copyright 2016, Yahoo Inc.
22
# Licensed under the terms of the Apache License, Version 2.0. See the LICENSE file associated with the project for terms.
3-
4-
from itertools import chain
5-
63
from boltons.setutils import IndexedSet as iset
4+
import networkx as nx
75

86
from .base import Operation, NetworkOperation
97
from .network import Network
@@ -190,17 +188,16 @@ def __call__(self, *operations):
190188
merge_set = iset() # Preseve given node order.
191189
for op in operations:
192190
if isinstance(op, NetworkOperation):
193-
plan = op.net.compile()
194-
merge_set.update(s for s in plan.steps
195-
if isinstance(s, Operation))
191+
netop_nodes = nx.topological_sort(op.net.graph)
192+
merge_set.update(s for s in netop_nodes if isinstance(s, Operation))
196193
else:
197194
merge_set.add(op)
198195
operations = merge_set
199196

200-
provides = iset(chain(*[op.provides for op in operations]))
197+
provides = iset(p for op in operations for p in op.provides)
201198
# Mark them all as optional, now that #18 calmly ignores
202199
# non-fully satisfied operations.
203-
needs = iset(chain(*[optional(n) for op in operations for n in op.needs ])) - provides
200+
needs = iset(optional(n) for op in operations for n in op.needs) - provides
204201

205202
# Build network
206203
net = Network()

0 commit comments

Comments
 (0)