Ejemplo n.º 1
0
    def construct_net(self, xml_filename, inputs_filename, resources_filename):
        xml = load_xml(xml_filename)
        inputs = load_inputs(inputs_filename)
        resources = load_resources(resources_filename)

        workflow = WorkflowAdapter(xml, inputs,
                local_workflow=self.local_workflow)

        future_net = workflow.future_net(resources)

        # XXX Update builder to use injector
        builder = Builder(self.storage)
        stored_net = builder.store(future_net, self.variables, self.constants)
        LOG.info('Created net with key (%s)', stored_net.key)

        if self.operation_data:
            parent_future_op = ForeignFutureOperation(
                    operation_data=self.operation_data)
            stored_net.set_initial_color(self.operation_data.color)
        else:
            parent_future_op = NullFutureOperation()

        future_operations = workflow.future_operations(parent_future_op,
                input_connections=None, output_properties=None)

        for future_operation in future_operations:
            future_operation.save(stored_net)
        workflow.store_inputs(stored_net)

        start_place_index = builder.future_places[future_net.start_place]

        return workflow, stored_net, start_place_index
Ejemplo n.º 2
0
 def setUp(self):
     self.inputs = {
         'a': 'value of a',
         'b': 'value of b',
     }
     self.resources = {}
     self.workflow = WorkflowAdapter(
             xml=etree.XML(VALID_XML),
             inputs=self.inputs)
Ejemplo n.º 3
0
class WorkflowTest(unittest.TestCase):
    def setUp(self):
        self.inputs = {
            'a': 'value of a',
            'b': 'value of b',
        }
        self.resources = {}
        self.workflow = WorkflowAdapter(
                xml=etree.XML(VALID_XML),
                inputs=self.inputs)

    def test_input_connections(self):
        expected_ics = {
            self.workflow.inputs_storage_adapter.operation_id:
                {'a': 'a', 'b': 'b'}
        }
        self.assertEqual(expected_ics, self.workflow.input_connections)

    def test_output_properties(self):
        expected_ops = ['out_a', 'out_b']
        self.assertEqual(expected_ops, self.workflow.output_properties)

    def test_future_net(self):
        net = self.workflow.future_net(self.resources)
        self.assertIsInstance(net, WorkflowNet)

    def test_future_operations(self):
        future_ops = self.workflow.future_operations(NullFutureOperation(),
                input_connections=mock.Mock(),
                output_properties=mock.Mock())
        self.assertEqual(6, len(future_ops))

    def test_unique_operation_ids(self):
        future_ops = self.workflow.future_operations(NullFutureOperation(),
                input_connections=mock.Mock(),
                output_properties=mock.Mock())
        operation_ids = set([f.operation_id for f in future_ops])
        self.assertEqual(len(future_ops), len(operation_ids))