Exemplo n.º 1
0
def add_to_canvas(query_dict, unique_query_dict, single_result):

    # get the controller (will be needed to change the module names
    controller = api.get_current_controller()

    # add the broker module to the canvas
    mod_broker = api.add_module(0, -100, 'org.vistrails.vistrails.NSLS2',
                                'BrokerQuery', 'broker')

    api.change_parameter(mod_broker.id, 'query_dict', [query_dict])
    api.change_parameter(mod_broker.id, 'unique_query_dict',
                         [unique_query_dict])
    # refresh the canvas
    controller.current_pipeline_scene.recreate_module(
        controller.current_pipeline, mod_broker.id)

    # get the data dict from the data broker
    mod_dict = api.add_module(0, -200, 'org.vistrails.vistrails.NSLS2',
                              'CalibrationParameters', 'broker')
    # connect the broker to the dict
    api.add_connection(mod_broker.id, 'query_result',
                       mod_dict.id, 'run_header')

    # Commenting out following part due to
    #  metadataStore.utilities.utility import get_data_keys
    #  is no longer there
    
    # get the datakeys from the run header
    """data_keys = get_data_keys(single_result)
Exemplo n.º 2
0
def add_to_canvas(query_dict, unique_query_dict, single_result):

    # get the controller (will be needed to change the module names
    controller = api.get_current_controller()

    # add the broker module to the canvas
    mod_broker = api.add_module(0, -100, 'org.vistrails.vistrails.NSLS2',
                                'BrokerQuery', 'broker')

    api.change_parameter(mod_broker.id, 'query_dict', [query_dict])
    api.change_parameter(mod_broker.id, 'unique_query_dict',
                         [unique_query_dict])
    # refresh the canvas
    controller.current_pipeline_scene.recreate_module(
        controller.current_pipeline, mod_broker.id)

    # get the data dict from the data broker
    mod_dict = api.add_module(0, -200, 'org.vistrails.vistrails.NSLS2',
                              'CalibrationParameters', 'broker')
    # connect the broker to the dict
    api.add_connection(mod_broker.id, 'query_result', mod_dict.id,
                       'run_header')

    # Commenting out following part due to
    #  metadataStore.utilities.utility import get_data_keys
    #  is no longer there

    # get the datakeys from the run header
    """data_keys = get_data_keys(single_result)
Exemplo n.º 3
0
    def test_outputportspec_cache(self):
        """
        Test that signature hash includes port specs

        If it is not included, a module with different port spec may
        be used in the cache, leading to an exception.
        """
        from vistrails import api
        from vistrails.core.vistrail.port_spec import PortSpec
        api.new_vistrail()
        c = api.get_current_controller()
        ps = api.add_module(0, 0, 'org.vistrails.vistrails.basic',
                            'PythonSource', '')
        api.change_parameter(ps.id, 'source', ['a = b = 1\ncache_this()'])
        so = api.add_module(0, 0, 'org.vistrails.vistrails.basic', 'Integer',
                            '')

        api.add_port_spec(
            ps.id,
            PortSpec(name='a',
                     type='output',
                     sigstring='org.vistrails.vistrails.basic:Integer'))
        api.add_connection(ps.id, 'a', so.id, 'value')
        # adds ps to cache
        self.assertEqual(c.execute_current_workflow()[0][0].errors, {})

        api.add_port_spec(
            ps.id,
            PortSpec(name='b',
                     type='output',
                     sigstring='org.vistrails.vistrails.basic:Integer'))
        api.add_connection(ps.id, 'b', so.id, 'value')
        # will fail if outputportspec is not hashed and cache is reused
        self.assertEqual(c.execute_current_workflow()[0][0].errors, {})
Exemplo n.º 4
0
def add_to_canvas(query_dict, unique_query_dict, single_result):

    # get the controller (will be needed to change the module names
    controller = api.get_current_controller()

    # add the broker module to the canvas
    mod_broker = api.add_module(0, -100, 'org.vistrails.vistrails.NSLS2',
                                'BrokerQuery', 'broker')

    api.change_parameter(mod_broker.id, 'query_dict', [query_dict])
    api.change_parameter(mod_broker.id, 'unique_query_dict',
                         [unique_query_dict])
    # refresh the canvas
    controller.current_pipeline_scene.recreate_module(
        controller.current_pipeline, mod_broker.id)

    # get the data dict from the data broker
    mod_dict = api.add_module(0, -200, 'org.vistrails.vistrails.NSLS2',
                              'CalibrationParameters', 'broker')
    # connect the broker to the dict
    api.add_connection(mod_broker.id, 'query_result', mod_dict.id, 'run_header')

    # get the datakeys from the run header
    data_keys = get_data_keys(single_result)
    if 'time' in data_keys:
        data_keys.remove('time')
    horz_offset = 250
    init_horz = -300
    vert_offset = -300

    for index, (key) in enumerate(data_keys):
        # add the vistrails module for the listify key
        # add the vistrails module for the listify operation
        mod_listify = api.add_module(init_horz + horz_offset * index,
                                     vert_offset,
                                     'org.vistrails.vistrails.NSLS2',
                                     'Listify', 'broker')
        # change the key parameter to be 'key'
        api.change_parameter(mod_listify.id, 'data_key', [key])
        # change the module name to [key]
        controller.add_annotation(('__desc__', key),
                                  mod_listify.id)
        # refresh the canvas
        controller.current_pipeline_scene.recreate_module(
            controller.current_pipeline, mod_listify.id)

        # connect the broker result to the listify module
        api.add_connection(mod_broker.id, 'query_result',
                           mod_listify.id, 'run_header')
Exemplo n.º 5
0
def add_to_canvas(query_dict, unique_query_dict, single_result):

    # get the controller (will be needed to change the module names
    controller = api.get_current_controller()

    # add the broker module to the canvas
    mod_broker = api.add_module(0, -100, 'org.vistrails.vistrails.NSLS2',
                                'BrokerQuery', 'broker')

    api.change_parameter(mod_broker.id, 'query_dict', [query_dict])
    api.change_parameter(mod_broker.id, 'unique_query_dict',
                         [unique_query_dict])
    # refresh the canvas
    controller.current_pipeline_scene.recreate_module(
        controller.current_pipeline, mod_broker.id)

    # get the data dict from the data broker
    mod_dict = api.add_module(0, -200, 'org.vistrails.vistrails.NSLS2',
                              'CalibrationParameters', 'broker')
    # connect the broker to the dict
    api.add_connection(mod_broker.id, 'query_result', mod_dict.id,
                       'run_header')

    # get the datakeys from the run header
    data_keys = get_data_keys(single_result)
    if 'time' in data_keys:
        data_keys.remove('time')
    horz_offset = 250
    init_horz = -300
    vert_offset = -300

    for index, (key) in enumerate(data_keys):
        # add the vistrails module for the listify key
        # add the vistrails module for the listify operation
        mod_listify = api.add_module(init_horz + horz_offset * index,
                                     vert_offset,
                                     'org.vistrails.vistrails.NSLS2',
                                     'Listify', 'broker')
        # change the key parameter to be 'key'
        api.change_parameter(mod_listify.id, 'data_key', [key])
        # change the module name to [key]
        controller.add_annotation(('__desc__', key), mod_listify.id)
        # refresh the canvas
        controller.current_pipeline_scene.recreate_module(
            controller.current_pipeline, mod_listify.id)

        # connect the broker result to the listify module
        api.add_connection(mod_broker.id, 'query_result', mod_listify.id,
                           'run_header')
Exemplo n.º 6
0
    def test_outputportspec_cache(self):
        """
        Test that signature hash includes port specs

        If it is not included, a module with different port spec may
        be used in the cache, leading to an exception.
        """
        from vistrails import api
        from vistrails.core.vistrail.port_spec import PortSpec
        api.new_vistrail()
        c = api.get_current_controller()
        ps = api.add_module(0, 0, 'org.vistrails.vistrails.basic', 'PythonSource', '')
        api.change_parameter(ps.id, 'source', ['a = b = 1\ncache_this()'])
        so = api.add_module(0, 0, 'org.vistrails.vistrails.basic', 'Integer', '')

        api.add_port_spec(ps.id, PortSpec(name='a', type='output', sigstring='org.vistrails.vistrails.basic:Integer'))
        api.add_connection(ps.id, 'a', so.id, 'value')
        # adds ps to cache
        self.assertEqual(c.execute_current_workflow()[0][0].errors, {})

        api.add_port_spec(ps.id, PortSpec(name='b', type='output', sigstring='org.vistrails.vistrails.basic:Integer'))
        api.add_connection(ps.id, 'b', so.id, 'value')
        # will fail if outputportspec is not hashed and cache is reused
        self.assertEqual(c.execute_current_workflow()[0][0].errors, {})