feat: implements right shift operator to provide an interface similar to airflow.

This commit is contained in:
Romain Dorgueil
2018-07-29 16:17:31 +01:00
parent 12fb1cf5c0
commit 3094e43f9f

View File

@ -11,6 +11,16 @@ from bonobo.util import get_name
GraphRange = namedtuple('GraphRange', ['graph', 'input', 'output']) GraphRange = namedtuple('GraphRange', ['graph', 'input', 'output'])
class GraphCursor:
def __init__(self, graph, node):
self.graph = graph
self.node = node
def __rshift__(self, other):
""" Self >> Other """
chain = self.graph.add_chain(other, _input=self.node)
return GraphCursor(chain.graph, chain.output)
class Graph: class Graph:
""" """
@ -35,6 +45,9 @@ class Graph:
def __getitem__(self, key): def __getitem__(self, key):
return self.nodes[key] return self.nodes[key]
def get_cursor(self, ref=BEGIN):
return GraphCursor(self, self._resolve_index(ref))
def outputs_of(self, idx, create=False): def outputs_of(self, idx, create=False):
""" Get a set of the outputs for a given node index. """ Get a set of the outputs for a given node index.
""" """