예제 #1
0
    def test_label(self):
        dp = DummyProcess.new_instance(inputs={'_label': 'My label'})
        self.assertEquals(dp.calc.label, 'My label')
        dp.run_until_complete()

        with self.assertRaises(ValueError):
            DummyProcess.new_instance(inputs={'_label': 5})
예제 #2
0
    def test_description(self):
        dp = DummyProcess.new_instance(inputs={'_description': 'My description'})
        self.assertEquals(dp.calc.description, 'My description')
        dp.run_until_complete()

        with self.assertRaises(ValueError):
            DummyProcess.new_instance(inputs={'_description': 5})
예제 #3
0
    def test_delete_checkpoint(self):
        process = DummyProcess()

        self.persister.save_checkpoint(process)
        self.assertTrue(isinstance(process.calc.checkpoint, basestring))

        self.persister.delete_checkpoint(process.pid)
        self.assertEquals(process.calc.checkpoint, None)
예제 #4
0
    def test_save_load(self):
        process = DummyProcess()
        saved_state = work.Bundle(process)
        del process

        loaded_process = saved_state.unbundle()
        result_from_loaded = work.launch.run(loaded_process)

        self.assertEqual(loaded_process.state, work.ProcessState.FINISHED)
예제 #5
0
    def test_save_load(self):
        dp = DummyProcess.new_instance()

        # Create a bundle
        b = self.persistence.create_bundle(dp)
        # Save a bundle and reload it
        self.persistence.save(dp)
        b2 = self.persistence.load_checkpoint(dp.pid)
        # Now check that they are equal
        self.assertEqual(b, b2)

        dp.run_until_complete()
예제 #6
0
    def test_queue_up(self):
        inputs = {'a': Int(2), 'b': Str('test')}

        # Queue up the process
        pid = queue_up(DummyProcess, inputs, self.storage)

        # Then load the checkpoint and instantiate the class
        cp = self.storage.load_checkpoint(pid)

        dp = DummyProcess.create_from(cp)
        self.assertIsInstance(dp, DummyProcess)
        self.assertEqual(dp.raw_inputs, inputs)
        dp.run_until_complete()
예제 #7
0
    def test_calculation_input(self):
        @workfunction
        def simple_wf():
            return {'a': Int(6), 'b': Int(7)}

        outputs, pid = run(simple_wf, _return_pid=True)
        calc = load_node(pid)
        dp = DummyProcess.new_instance(inputs={'calc': calc})
        dp.run_until_complete()

        input_calc = dp.calc.get_inputs_dict()['calc']
        self.assertTrue(isinstance(input_calc, FrozenDict))
        self.assertEqual(input_calc['a'], outputs['a'])
예제 #8
0
    def test_seal(self):
        rinfo = run(DummyProcess, _return_pid=True)[1]
        self.assertTrue(load_node(pk=rinfo).is_sealed)

        storedir = tempfile.mkdtemp()
        storage = Persistence.create_from_basedir(storedir)

        rinfo = submit(DummyProcess, _jobs_store=storage)
        n = load_node(pk=rinfo.pid)
        self.assertFalse(n.is_sealed)

        dp = DummyProcess.create_from(storage.load_checkpoint(rinfo.pid))
        dp.run_until_complete()
        self.assertTrue(n.is_sealed)
        shutil.rmtree(storedir)
예제 #9
0
    def test_input_link_creation(self):
        dummy_inputs = ["1", "2", "3", "4"]

        inputs = {l: Int(l) for l in dummy_inputs}
        inputs['_store_provenance'] = True
        p = DummyProcess.new_instance(inputs)

        for label, value in p._calc.get_inputs_dict().iteritems():
            self.assertTrue(label in inputs)
            self.assertEqual(int(label), int(value.value))
            dummy_inputs.remove(label)

        # Make sure there are no other inputs
        self.assertFalse(dummy_inputs)

        p.stop()
        p.run_until_complete()
예제 #10
0
 def test_none_input(self):
     # Check that if we pass no input the process runs fine
     DummyProcess.new_instance().run_until_complete()
     # Check that if we explicitly pass None as the input it also runs fine
     DummyProcess.new_instance(inputs=None).run_until_complete()
예제 #11
0
 def test_pid_is_uuid(self):
     p = DummyProcess.new_instance(inputs={'_store_provenance': False})
     self.assertEqual(uuid.UUID(p._calc.uuid), p.pid)
     p.stop()
     p.run_until_complete()
예제 #12
0
    def test_save_load_checkpoint(self):
        process = DummyProcess()
        bundle_saved = self.persister.save_checkpoint(process)
        bundle_loaded = self.persister.load_checkpoint(process.calc.pk)

        self.assertEquals(bundle_saved, bundle_loaded)
예제 #13
0
 def test_inputs_template(self):
     inputs = DummyProcess.get_inputs_template()
     dp = DummyProcess.new_instance(inputs=inputs)
     dp.run_until_complete()