Node streaming complete

This commit is contained in:
Florent Guiotte 2018-04-04 14:44:35 +02:00
parent f0bfac52b9
commit c48f0497e2
4 changed files with 16 additions and 8 deletions

View File

@ -17,3 +17,12 @@ class Input(Node):
def register(self, 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)

View File

@ -16,6 +16,12 @@ class Node:
def __str__(self):
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):
raise NotImplementedError('{} should override _run()'.format(self))

View File

@ -29,15 +29,7 @@ class Output(Node):
self.__dict__['input'] = inode
inode.register(self)
def process(self, data):
self._process(data)
def _process(self, data):
raise NotImplementedError('{} should override _process()'.format(self))
def _run(self):
if self.input is None:
raise RuntimeError('{} do not have an input'.format(self))
return self.input.run()

View File

@ -22,6 +22,7 @@ def main():
n.input = f
o.input = n
o.run()
#i.process(None)
print(n.input)
print(f.outputs)