diff options
| author | Joshua Harlow <harlowja@yahoo-inc.com> | 2013-06-14 16:15:09 -0700 |
|---|---|---|
| committer | Joshua Harlow <harlowja@yahoo-inc.com> | 2013-06-27 12:35:28 -0700 |
| commit | 686ea905ed291d246c13d3727e6b38edd0a460b8 (patch) | |
| tree | 87bf34812d0e015c2973cf8d12e6bb130cb71c5f /taskflow/patterns/graph_flow.py | |
| parent | a7482eaa1857105e2c845a5d31e5f2b2e7b733ae (diff) | |
| download | taskflow-686ea905ed291d246c13d3727e6b38edd0a460b8.tar.gz | |
Allow instance methods to be wrapped and unwrapped correctly.
Change-Id: Ia29e0e8a54fa815dec88016a9444fe7cfad7b8ac
Diffstat (limited to 'taskflow/patterns/graph_flow.py')
| -rw-r--r-- | taskflow/patterns/graph_flow.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/taskflow/patterns/graph_flow.py b/taskflow/patterns/graph_flow.py index 86fa425..dbc9125 100644 --- a/taskflow/patterns/graph_flow.py +++ b/taskflow/patterns/graph_flow.py @@ -25,6 +25,7 @@ from networkx import exception as g_exc from taskflow import exceptions as exc from taskflow.patterns import ordered_flow +from taskflow import utils LOG = logging.getLogger(__name__) @@ -46,6 +47,7 @@ class Flow(ordered_flow.Flow): # # Only insert the node to start, connect all the edges # together later after all nodes have been added. + assert isinstance(task, collections.Callable) self._graph.add_node(task) self._connected = False @@ -54,7 +56,8 @@ class Flow(ordered_flow.Flow): def extract_inputs(place_where, would_like, is_optional=False): for n in would_like: for (them, there_result) in self.results: - if not n in set(getattr(them, 'provides', [])): + they_provide = utils.get_attr(them, 'provides', []) + if n not in set(they_provide): continue if ((not is_optional and not self._graph.has_edge(them, task))): @@ -68,8 +71,8 @@ class Flow(ordered_flow.Flow): elif not is_optional: place_where[n].append(None) - required_inputs = set(getattr(task, 'requires', [])) - optional_inputs = set(getattr(task, 'optional', [])) + required_inputs = set(utils.get_attr(task, 'requires', [])) + optional_inputs = set(utils.get_attr(task, 'optional', [])) optional_inputs = optional_inputs - required_inputs task_inputs = collections.defaultdict(list) @@ -103,9 +106,9 @@ class Flow(ordered_flow.Flow): provides_what = collections.defaultdict(list) requires_what = collections.defaultdict(list) for t in self._graph.nodes_iter(): - for r in getattr(t, 'requires', []): + for r in utils.get_attr(t, 'requires', []): requires_what[r].append(t) - for p in getattr(t, 'provides', []): + for p in utils.get_attr(t, 'provides', []): provides_what[p].append(t) def get_providers(node, want_what): |
