Beispiel #1
0
 def test_cycle(self):
     """
     Creating a cycle: A data-instance is both input to and returned by a WorkFlowNode
     """
     d = Data().store()
     c = WorkCalculation().store()
     # New provenance design branch
     # ~ c.add_incoming(d, link_type=LinkType.INPUT_WORK, link_label='lala')
     # ~ d.add_incoming(c, link_type=LinkType.RETURN, link_label='lala')
     c.add_link_from(d, link_type=LinkType.INPUT, label='lala')
     d.add_link_from(c, link_type=LinkType.RETURN, label='lala')
     qb = QueryBuilder().append(Node).append(Node)
     rule = UpdateRule(qb, max_iterations=np.inf)
     es = get_basket(node_ids=(d.id,))
     res = rule.run(es)
     self.assertEqual( res['nodes']._set, set([d.id, c.id]))
Beispiel #2
0
    def test_report(self):
        """Test the report command."""
        grandparent = WorkCalculation().store()
        parent = WorkCalculation().store()
        child = WorkCalculation().store()

        parent.add_link_from(grandparent, link_type=LinkType.CALL)
        child.add_link_from(parent, link_type=LinkType.CALL)

        grandparent.logger.log(LOG_LEVEL_REPORT, 'grandparent_message')
        parent.logger.log(LOG_LEVEL_REPORT, 'parent_message')
        child.logger.log(LOG_LEVEL_REPORT, 'child_message')

        result = self.cli_runner.invoke(cmd_work.work_report,
                                        [str(grandparent.pk)])
        self.assertIsNone(result.exception)
        self.assertEquals(len(get_result_lines(result)), 3)

        result = self.cli_runner.invoke(cmd_work.work_report, [str(parent.pk)])
        self.assertIsNone(result.exception)
        self.assertEquals(len(get_result_lines(result)), 2)

        result = self.cli_runner.invoke(cmd_work.work_report, [str(child.pk)])
        self.assertIsNone(result.exception)
        self.assertEquals(len(get_result_lines(result)), 1)

        # Max depth should limit nesting level
        for flag in ['-m', '--max-depth']:
            for flag_value in [1, 2]:
                result = self.cli_runner.invoke(
                    cmd_work.work_report,
                    [str(grandparent.pk), flag,
                     str(flag_value)])
                self.assertIsNone(result.exception)
                self.assertEquals(len(get_result_lines(result)), flag_value)

        # Filtering for other level name such as WARNING should not have any hits and only print the no log message
        for flag in ['-l', '--levelname']:
            result = self.cli_runner.invoke(
                cmd_work.work_report, [str(grandparent.pk), flag, 'WARNING'])
            self.assertIsNone(result.exception)
            self.assertEquals(len(get_result_lines(result)), 1)
            self.assertEquals(
                get_result_lines(result)[0],
                'No log messages recorded for this work calculation')