def test_truncate_graph_with_full_levels(self): class BinaryTreeTask(luigi.Task): idx = luigi.IntParameter() def requires(self): if self.idx < 100: return map(BinaryTreeTask, (self.idx * 2, self.idx * 2 + 1)) root_task = BinaryTreeTask(1) self.scheduler = luigi.scheduler.CentralPlannerScheduler(max_graph_nodes=10) self._build([root_task]) graph = self.scheduler.dep_graph(root_task.task_id) self.assertEqual(10, len(graph)) expected_nodes = [BinaryTreeTask(i).task_id for i in range(1, 11)] six.assertCountEqual(self, expected_nodes, graph)
def test_large_inverse_graph_truncate(self): class LinearTask(luigi.Task): idx = luigi.IntParameter() def requires(self): if self.idx > 0: yield LinearTask(self.idx - 1) def complete(self): return False root_task = LinearTask(100) self.scheduler = luigi.scheduler.Scheduler(max_graph_nodes=10) self._build([root_task]) graph = self.scheduler.inverse_dep_graph(LinearTask(0).task_id) self.assertEqual(10, len(graph)) expected_nodes = [LinearTask(i).task_id for i in range(10)] six.assertCountEqual(self, expected_nodes, graph)
def test_large_inverse_graph_truncate(self): class LinearTask(luigi.Task): idx = luigi.IntParameter() def requires(self): if self.idx > 0: yield LinearTask(self.idx - 1) def complete(self): return False root_task = LinearTask(100) self.scheduler = luigi.scheduler.CentralPlannerScheduler(max_graph_nodes=10) self._build([root_task]) graph = self.scheduler.inverse_dep_graph(LinearTask(0).task_id) self.assertEqual(10, len(graph)) expected_nodes = [LinearTask(i).task_id for i in range(10)] six.assertCountEqual(self, expected_nodes, graph)
def testEmailRecipientsNoConfig(self): six.assertCountEqual(self, notifications._email_recipients(), []) six.assertCountEqual(self, notifications._email_recipients("[email protected]"), ["[email protected]"]) six.assertCountEqual( self, notifications._email_recipients(["[email protected]", "[email protected]"]), ["[email protected]", "[email protected]"])
def testEmailRecipients(self): six.assertCountEqual(self, notifications._email_recipients(), ["[email protected]"]) six.assertCountEqual(self, notifications._email_recipients("[email protected]"), ["[email protected]", "[email protected]"]) six.assertCountEqual( self, notifications._email_recipients(["[email protected]", "[email protected]"]), ["[email protected]", "[email protected]", "[email protected]"])
def test_truncate_graph_with_multiple_depths(self): class LinearTask(luigi.Task): idx = luigi.IntParameter() def requires(self): if self.idx > 0: yield LinearTask(self.idx - 1) yield LinearTask(0) def complete(self): return False root_task = LinearTask(100) self.scheduler = luigi.scheduler.Scheduler(max_graph_nodes=10) self._build([root_task]) graph = self.scheduler.dep_graph(root_task.task_id) self.assertEqual(10, len(graph)) expected_nodes = [LinearTask(i).task_id for i in range(100, 91, -1)] + \ [LinearTask(0).task_id] self.maxDiff = None six.assertCountEqual(self, expected_nodes, graph)
def test_truncate_graph_with_multiple_depths(self): class LinearTask(luigi.Task): idx = luigi.IntParameter() def requires(self): if self.idx > 0: yield LinearTask(self.idx - 1) yield LinearTask(0) def complete(self): return False root_task = LinearTask(100) self.scheduler = luigi.scheduler.CentralPlannerScheduler(max_graph_nodes=10) self._build([root_task]) graph = self.scheduler.dep_graph(root_task.task_id) self.assertEqual(10, len(graph)) expected_nodes = [LinearTask(i).task_id for i in range(100, 91, -1)] +\ [LinearTask(0).task_id] self.maxDiff = None six.assertCountEqual(self, expected_nodes, graph)
def testEmailRecipientsNoConfig(self): six.assertCountEqual(self, notifications._email_recipients(), []) six.assertCountEqual(self, notifications._email_recipients("[email protected]"), ["[email protected]"]) six.assertCountEqual(self, notifications._email_recipients(["[email protected]", "[email protected]"]), ["[email protected]", "[email protected]"])
def testEmailRecipients(self): six.assertCountEqual(self, notifications._email_recipients(), ["[email protected]"]) six.assertCountEqual(self, notifications._email_recipients("[email protected]"), ["[email protected]", "[email protected]"]) six.assertCountEqual(self, notifications._email_recipients(["[email protected]", "[email protected]"]), ["[email protected]", "[email protected]", "[email protected]"])