diff options
author | Jenkins <jenkins@review.openstack.org> | 2013-07-06 22:35:21 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2013-07-06 22:35:21 +0000 |
commit | b89eefea1804ede071747f558bb11571090445b3 (patch) | |
tree | ad04214d953a2f9c0a0ce7c6a30e6e7e0a46776a | |
parent | b04ba8a43c392f36c4cf3b6d342e03822ab04971 (diff) | |
parent | 1f7edf2316fbd9cfccc26e0fb2f396c719bfba9f (diff) | |
download | taskflow-b89eefea1804ede071747f558bb11571090445b3.tar.gz |
Merge "Clear out before connecting."
-rw-r--r-- | taskflow/patterns/graph_flow.py | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/taskflow/patterns/graph_flow.py b/taskflow/patterns/graph_flow.py index 426a236..2883c48 100644 --- a/taskflow/patterns/graph_flow.py +++ b/taskflow/patterns/graph_flow.py @@ -97,29 +97,36 @@ class Flow(linear_flow.Flow): if self._runners: return self._runners + # Clear out all edges (since we want to do a fresh connection) + for (u, v) in self._graph.edges(): + self._graph.remove_edge(u, v) + # Link providers to requirers. # # TODO(harlowja): allow for developers to manually establish these # connections instead of automatically doing it for them?? for n in self._graph.nodes_iter(): + n_providers = {} n_requires = set(utils.get_attr(n.task, 'requires', [])) - LOG.debug("Finding providers of %s for %s", n_requires, n) - for p in self._graph.nodes_iter(): - if not n_requires: - break - if n is p: - continue - p_provides = set(utils.get_attr(p.task, 'provides', [])) - p_satisfies = n_requires & p_provides - if p_satisfies: - # P produces for N so thats why we link P->N and not N->P - self._add_dependency(p, n) - for k in p_satisfies: - n.providers[k] = p - LOG.debug("Found provider of %s from %s", p_satisfies, p) - n_requires = n_requires - p_satisfies if n_requires: - raise exc.MissingDependencies(n, sorted(n_requires)) + LOG.debug("Finding providers of %s for %s", n_requires, n) + for p in self._graph.nodes_iter(): + if n is p: + continue + p_provides = set(utils.get_attr(p.task, 'provides', [])) + p_satisfies = n_requires & p_provides + if p_satisfies: + # P produces for N so thats why we link P->N + # and not N->P + self._add_dependency(p, n) + for k in p_satisfies: + n_providers[k] = p + LOG.debug("Found provider of %s from %s", + p_satisfies, p) + n_requires = n_requires - p_satisfies + if n_requires: + raise exc.MissingDependencies(n, sorted(n_requires)) + n.providers = n_providers # Now figure out the order so that we can give the runners there # optional item providers as well as figure out the topological run |