Example #1
0
    def test_label(self):
        """Test setting a label."""
        dummy_process = test_processes.DummyProcess(inputs={'metadata': {'label': 'My label'}})
        self.assertEqual(dummy_process.node.label, 'My label')

        with self.assertRaises(ValueError):
            test_processes.DummyProcess(inputs={'label': 5})
Example #2
0
    def test_description(self):
        """Testing setting a process description."""
        dummy_process = test_processes.DummyProcess(inputs={'metadata': {'description': "Rockin' process"}})
        self.assertEqual(dummy_process.node.description, "Rockin' process")

        with self.assertRaises(ValueError):
            test_processes.DummyProcess(inputs={'metadata': {'description': 5}})
Example #3
0
 def test_save_instance_state():
     """Test save instance's state."""
     proc = test_processes.DummyProcess()
     # Save the instance state
     bundle = plumpy.Bundle(proc)
     proc.close()
     bundle.unbundle()
Example #4
0
    def test_input_after_stored(self):
        """Verify that adding an input link after storing a `ProcessNode` will raise because it is illegal."""
        from aiida.common import LinkType
        process = test_processes.DummyProcess()

        with self.assertRaises(ValueError):
            process.node.add_incoming(orm.Int(1), link_type=LinkType.INPUT_WORK, link_label='illegal_link')
Example #5
0
    def test_process_type_without_entry_point(self):
        """
        For a process without a registered entry point, the process_type will fall back on the fully
        qualified class name
        """
        process = test_processes.DummyProcess()
        expected_process_type = f'{process.__class__.__module__}.{process.__class__.__name__}'
        self.assertEqual(process.node.process_type, expected_process_type)

        # Verify that process_class on the calculation node returns the original entry point class
        recovered_process = process.node.process_class
        self.assertEqual(recovered_process, process.__class__)
Example #6
0
    def test_calculation_future_polling(self):
        """Test calculation future polling."""

        runner = get_manager().get_runner()
        process = test_processes.DummyProcess()

        # No communicator
        future = processes.futures.ProcessFuture(pk=process.pid, loop=runner.loop, poll_interval=0)

        runner.run(process)
        calc_node = runner.run_until_complete(asyncio.wait_for(future, self.TIMEOUT))

        self.assertEqual(process.node.pk, calc_node.pk)
Example #7
0
    def test_input_link_creation(self):
        """Test input link creation."""
        dummy_inputs = ['a', 'b', 'c', 'd']

        inputs = {string: orm.Str(string) for string in dummy_inputs}
        inputs['metadata'] = {'store_provenance': True}
        process = test_processes.DummyProcess(inputs)

        for entry in process.node.get_incoming().all():
            self.assertTrue(entry.link_label in inputs)
            self.assertEqual(entry.link_label, entry.node.value)
            dummy_inputs.remove(entry.link_label)

        # Make sure there are no other inputs
        self.assertFalse(dummy_inputs)
Example #8
0
    def test_calculation_future_broadcasts(self):
        """Test calculation future broadcasts."""
        manager = get_manager()
        runner = manager.get_runner()
        process = test_processes.DummyProcess()

        # No polling
        future = processes.futures.ProcessFuture(
            pk=process.pid, loop=runner.loop, communicator=manager.get_communicator()
        )

        run(process)
        calc_node = runner.run_until_complete(asyncio.wait_for(future, self.TIMEOUT))

        self.assertEqual(process.node.pk, calc_node.pk)
Example #9
0
    def test_calculation_future_broadcasts(self):
        """Test calculation future broadcasts."""
        manager = get_manager()
        runner = manager.get_runner()
        process = test_processes.DummyProcess()

        # No polling
        future = processes.futures.CalculationFuture(
            pk=process.pid,
            poll_interval=None,
            communicator=manager.get_communicator())

        run(process)
        calc_node = runner.run_until_complete(
            gen.with_timeout(self.TIMEOUT, future))

        self.assertEqual(process.node.pk, calc_node.pk)
Example #10
0
 def test_work_calc_finish(self):
     process = test_processes.DummyProcess()
     self.assertFalse(process.node.is_finished_ok)
     run(process)
     self.assertTrue(process.node.is_finished_ok)