def test_single(self): graph = ExeGraph() n1 = ExeNode('foo', in0out1, output='a') graph.add(n1) self.assertEqual(collections.OrderedDict([(n1, [])]), graph.adjacency_matrix)
def test_simple_chain(self): graph = ExeGraph() n1 = ExeNode('foo', in0out1, output='a') n2 = ExeNode('foh', in1out1, input={'a': 'x'}, output='b') n3 = ExeNode('fum', in1out1, input={'b': 'x'}, output='c') expected = collections.OrderedDict([ (n1, [n2]), (n2, [n3]), (n3, []) ]) graph.add(n1) graph.add(n2) graph.add(n3) self.assertEqual(expected, graph.adjacency_matrix)
def test_diamond(self): graph = ExeGraph() n1 = ExeNode('fee', in0out2, output=('a', 'b')) n2 = ExeNode('fie', in1out1, input={'a': 'x'}, output='c') n3 = ExeNode('foh', in1out1, input={'b': 'x'}, output='d') n4 = ExeNode('fum', in2out1, input={'c': 'x', 'd': 'y'}, output='e') expected = collections.OrderedDict([ (n1, [n2, n3]), (n2, [n4]), (n3, [n4]), (n4, []) ]) graph.add(n1) graph.add(n2) graph.add(n3) graph.add(n4) self.assertEqual(expected, graph.adjacency_matrix)
from yax.state.exe import ExeGraph, ExeNode from yax.modules.example.module import main as example_main pipeline = ExeGraph() pipeline.add(ExeNode('example', example_main, output=('a', 'b')))
from yax.state.exe import ExeGraph, ExeNode from yax.state.tests.test_pipeline.modules.module_1 import main as main_1 from yax.state.tests.test_pipeline.modules.module_2 import main as main_2 from yax.state.tests.test_pipeline.modules.module_3 import main as main_3 from yax.state.tests.test_pipeline.modules.module_4 import main as main_4 pipeline = ExeGraph() pipeline.add(ExeNode('module1', main_1, output=('a', 'b'))) pipeline.add(ExeNode('module2', main_2, output=('c', 'x'))) pipeline.add(ExeNode('module3', main_3, input={'b': 'art_b', 'c': 'art_c'}, output='d')) pipeline.add(ExeNode('module4', main_4, input={'a': 'art_a', 'd': 'art_d'}, output='y'))
from yax.state.type import Str, Int, Float from yax.state.tests.test_pipeline.modules.module_1 import main as main_1 from yax.state.tests.test_pipeline.modules.module_2 import main as main_2 from yax.state.tests.test_pipeline.modules.module_3 import main as main_3 from yax.state.tests.test_pipeline.modules.module_4 import main as main_4 pipeline = ExeGraph() pipeline.set_details({ 'some_detail': (Str, "foo"), 'other_detail': Int, 'too_much_detail': (Float, float('inf')) }) pipeline.add(ExeNode('module1', main_1, output=('a', 'b'))) pipeline.add(ExeNode('module2', main_2, output=('c', 'x'))) pipeline.add(ExeNode('module3', main_3, input={'b': 'art_b', 'c': 'art_c'}, output='d')) pipeline.add(ExeNode('module4', main_4, input={'a': 'art_a', 'd': 'art_d'}, output='y'))