From fda6fde26270c58a0d893d74086122ee45bda95a Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Sat, 6 Dec 2014 12:15:01 -0800 Subject: [PATCH] Use explict 'attr_dict' when adding provider->consumer edge Instead of using the less explicit **kwarg support when adding an edge between a explicit producer and consumer use the 'attr_dict' keyword argument instead and use the constant defined the the flow module as the key into that dictionary (this also ensure that the key will be adjusted automatically if that key value ever changes). Change-Id: Ieeae83b984b7797320997c0c4cb4289eb1a837ee --- taskflow/engines/action_engine/compiler.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/taskflow/engines/action_engine/compiler.py b/taskflow/engines/action_engine/compiler.py index a71b9d17..c55a1e7f 100644 --- a/taskflow/engines/action_engine/compiler.py +++ b/taskflow/engines/action_engine/compiler.py @@ -33,6 +33,7 @@ _RETRY_EDGE_DATA = { flow.LINK_RETRY: True, } _EDGE_INVARIANTS = (flow.LINK_INVARIANT, flow.LINK_MANUAL, flow.LINK_RETRY) +_EDGE_REASONS = flow.LINK_REASONS class Compilation(object): @@ -155,11 +156,15 @@ class Linker(object): "Non-invariant link being created from '%s' ->" " '%s' even though the target '%s' was found to be" " decomposed into an empty graph" % (v, u, u)) - for provider in u_g: - for consumer in v_g: - reasons = provider.provides & consumer.requires - if reasons: - graph.add_edge(provider, consumer, reasons=reasons) + for u in u_g.nodes_iter(): + for v in v_g.nodes_iter(): + depends_on = u.provides & v.requires + if depends_on: + _add_update_edges(graph, + [u], [v], + attr_dict={ + _EDGE_REASONS: depends_on, + }) else: # Connect nodes with no predecessors in v to nodes with no # successors in the *first* non-empty predecessor of v (thus