File tree Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Original file line number Diff line number Diff line change 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-
63from boltons .setutils import IndexedSet as iset
4+ import networkx as nx
75
86from .base import Operation , NetworkOperation
97from .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 ()
You can’t perform that action at this time.
0 commit comments