def setUp(self): input_task1 = InputTask() input_task2 = InputTask() divide_task = DivideTask() self.workflow = EOWorkflow(dependencies=[ Dependency(task=input_task1, inputs=[]), Dependency(task=input_task2, inputs=[]), Dependency(task=divide_task, inputs=[input_task1, input_task2]) ])
def setUp(self): task1 = FooTask() task2 = FooTask() task3 = FooTask() self.workflow = EOWorkflow(dependencies=[ Dependency(task=task1, inputs=[]), Dependency(task=task2, inputs=[]), Dependency(task=task3, inputs=[task1, task2]) ])
def test_workflow_arguments(self): input_task1 = InputTask() input_task2 = InputTask() divide_task = DivideTask() workflow = EOWorkflow(dependencies=[ Dependency(task=input_task1, inputs=[]), Dependency(task=input_task2, inputs=[]), Dependency(task=divide_task, inputs=[input_task1, input_task2]) ]) with concurrent.futures.ProcessPoolExecutor(max_workers=5) as executor: k2future = { k: executor.submit( workflow.execute, { input_task1: {'val': k ** 3}, input_task2: {'val': k ** 2} } ) for k in range(2, 100) } executor.shutdown() for k in range(2, 100): future = k2future[k] self.assertEqual(future.result()[divide_task], k) result1 = workflow.execute({ input_task1: {'val': 15}, input_task2: {'val': 3} }) self.assertEqual(result1[divide_task], 5) result2 = workflow.execute({ input_task1: {'val': 6}, input_task2: {'val': 3} }) self.assertEqual(result2[divide_task], 2) result3 = workflow.execute({ input_task1: {'val': 6}, input_task2: {'val': 3}, divide_task: {'z': 1} }) self.assertEqual(result3[divide_task], 3)
def setUpClass(cls): task = ExampleTask() cls.workflow = EOWorkflow([(task, []), Dependency(task=ExampleTask(), inputs=[task, task])]) cls.execution_args = [ {task: {'arg1': 1}}, {}, {task: {'arg1': 3, 'arg3': 10}}, {task: {'arg1': None}} ]
def setUpClass(cls): cls.task = ExampleTask() cls.final_task = FooTask() cls.workflow = EOWorkflow([(cls.task, []), Dependency(task=cls.final_task, inputs=[cls.task, cls.task])]) cls.execution_args = [ {cls.task: {'arg1': 1}}, {}, {cls.task: {'arg1': 3, 'arg3': 10}}, {cls.task: {'arg1': None}} ]
def test_trivial_workflow(self): task = DummyTask() dep = Dependency(task, []) workflow = EOWorkflow([dep]) result = workflow.execute() self.assertTrue(isinstance(result, WorkflowResults)) self.assertEqual(len(result), 1) self.assertEqual(len(result.keys()), 1) self.assertEqual(len(result.values()), 1) items = list(result.items()) self.assertEqual(len(items), 1) self.assertTrue(isinstance(items[0][0], EOTask)) self.assertEqual(items[0][1], 42) self.assertEqual(result[dep], 42)
def test_report_creation(self): task = ExampleTask() workflow = EOWorkflow(dependencies=[ Dependency(task=task, inputs=[]), ]) execution_args = [ {'arg1': 1} ] with tempfile.TemporaryDirectory() as tmpdirname: executor = EOExecutor(workflow, execution_args, file_path=tmpdirname) executor.run() self.assertIsNotNone(executor.make_report())
def test_execution_errors(self): task = RaiserErrorTask() workflow = EOWorkflow(dependencies=[ Dependency(task=task, inputs=[]), ]) execution_args = [ {'arg1': 1} ] with tempfile.TemporaryDirectory() as tmpdirname: executor = EOExecutor(workflow, execution_args, file_path=tmpdirname) executor.run() self.assertTrue('error' in executor.execution_stats[0])
def test_execution_stats(self): task = ExampleTask() workflow = EOWorkflow(dependencies=[ Dependency(task=task, inputs=[]), ]) execution_args = [ {'arg1': 1}, {'arg1': 2} ] with tempfile.TemporaryDirectory() as tmpdirname: executor = EOExecutor(workflow, execution_args, file_path=tmpdirname) executor.run() self.assertEqual(len(executor.execution_stats), 2)