Node streaming complete
This commit is contained in:
parent
f0bfac52b9
commit
c48f0497e2
@ -17,3 +17,12 @@ class Input(Node):
|
|||||||
|
|
||||||
def register(self, output):
|
def register(self, output):
|
||||||
self.outputs.append(output)
|
self.outputs.append(output)
|
||||||
|
|
||||||
|
def process(self, data, metadata=None):
|
||||||
|
"""Override abstract method"""
|
||||||
|
data, meta = self._process(data, metadata)
|
||||||
|
for output in self.outputs:
|
||||||
|
output.process(data, meta)
|
||||||
|
|
||||||
|
def _run(self):
|
||||||
|
self.process(None, None)
|
||||||
|
|||||||
@ -16,6 +16,12 @@ class Node:
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
return ("Node:{}".format(self.name))
|
return ("Node:{}".format(self.name))
|
||||||
|
|
||||||
|
def process(self, data, metadata=None):
|
||||||
|
self._process(data)
|
||||||
|
|
||||||
|
def _process(self, data, metadata=None):
|
||||||
|
raise NotImplementedError('{} should override _process()'.format(self))
|
||||||
|
|
||||||
def _run(self):
|
def _run(self):
|
||||||
raise NotImplementedError('{} should override _run()'.format(self))
|
raise NotImplementedError('{} should override _run()'.format(self))
|
||||||
|
|
||||||
|
|||||||
@ -29,15 +29,7 @@ class Output(Node):
|
|||||||
self.__dict__['input'] = inode
|
self.__dict__['input'] = inode
|
||||||
inode.register(self)
|
inode.register(self)
|
||||||
|
|
||||||
def process(self, data):
|
|
||||||
self._process(data)
|
|
||||||
|
|
||||||
def _process(self, data):
|
|
||||||
raise NotImplementedError('{} should override _process()'.format(self))
|
|
||||||
|
|
||||||
def _run(self):
|
def _run(self):
|
||||||
if self.input is None:
|
if self.input is None:
|
||||||
raise RuntimeError('{} do not have an input'.format(self))
|
raise RuntimeError('{} do not have an input'.format(self))
|
||||||
return self.input.run()
|
return self.input.run()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -22,6 +22,7 @@ def main():
|
|||||||
n.input = f
|
n.input = f
|
||||||
o.input = n
|
o.input = n
|
||||||
o.run()
|
o.run()
|
||||||
|
#i.process(None)
|
||||||
print(n.input)
|
print(n.input)
|
||||||
print(f.outputs)
|
print(f.outputs)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user