Ejemplo n.º 1
0
 def add_empty_task_node(self):
     samples = self.get_selected_samples()
     task_node = queue_model_objects.TaskGroup()
     task_node.set_name('Collection group')
     queue_item.DataCollectionGroupQueueItem(samples[0],
                                             samples[0].lastItem(),
                                             task_node.get_name())
Ejemplo n.º 2
0
def add_data_collection(node_id, task):
    """
    Adds a data collection task to the sample with id: <id>

    :param int id: id of the sample to which the task belongs
    :param dict task: task data

    :returns: The queue id of the data collection
    :rtype: int
    """
    sample_model, sample_entry = get_entry(node_id)
    dc_model, dc_entry = _create_dc(task)
    set_dc_params(dc_model, dc_entry, task)

    pt = dc_model.acquisitions[0].path_template

    if mxcube.queue.check_for_path_collisions(pt):
        msg = "[QUEUE] data collection could not be added to sample: "
        msg += "path collision"
        raise Exception(msg)

    group_model = qmo.TaskGroup()

    group_model.set_enabled(True)
    mxcube.queue.add_child(sample_model, group_model)
    mxcube.queue.add_child(group_model, dc_model)

    group_entry = qe.TaskGroupQueueEntry(Mock(), group_model)
    group_entry.set_enabled(True)
    sample_entry.enqueue(group_entry)
    group_entry.enqueue(dc_entry)

    return dc_model._node_id
Ejemplo n.º 3
0
    def create_task_group(self, task_model):
        group_task_node = queue_model_objects.TaskGroup()
        current_item = self.tool_box.currentWidget()

        group_name = current_item._task_node_name
        group_task_node.set_name(group_name)
        num = task_model.get_next_number_for_name(group_name)
        group_task_node.set_number(num)

        self.tree_brick.queue_model_hwobj.\
            add_child(task_model, group_task_node)

        return group_task_node
Ejemplo n.º 4
0
    def create_task_group(self, task_model):
        group_task_node = queue_model_objects.TaskGroup()
        current_item = self.tool_box.currentItem()

        if current_item is self.workflow_page:
            group_name = current_item._workflow_cbox.currentText()
        else:
            group_name = current_item._task_node_name
        group_task_node.set_name(group_name)
        num = task_model.get_next_number_for_name(group_name)
        group_task_node.set_number(num)

        self.tree_brick.queue_model_hwobj.\
        add_child(task_model, group_task_node)

        return group_task_node
Ejemplo n.º 5
0
def add_characterisation(node_id, task):
    """
    Adds a data characterisation task to the sample with id: <id>

    :param int id: id of the sample to which the task belongs
    :param dict task: Task data (parameters)

    :returns: The queue id of the Data collection
    :rtype: int
    """
    sample_model, sample_entry = get_entry(node_id)
    params = task['parameters']

    refdc_model, refdc_entry = _create_dc(task)
    refdc_model.set_name('refdc')
    char_params = qmo.CharacterisationParameters().set_from_dict(params)

    char_model = qmo.Characterisation(refdc_model, char_params)
    char_entry = qe.CharacterisationGroupQueueEntry(Mock(), char_model)
    char_entry.queue_model_hwobj = mxcube.queue
    # Set the characterisation and reference collection parameters
    set_char_params(char_model, char_entry, task)

    # A characterisation has two TaskGroups one for the characterisation itself
    # and its reference collection and one for the resulting diffraction plans.
    # But we only create a reference group if there is a result !
    refgroup_model = qmo.TaskGroup()

    mxcube.queue.add_child(sample_model, refgroup_model)
    mxcube.queue.add_child(refgroup_model, char_model)
    refgroup_entry = qe.TaskGroupQueueEntry(Mock(), refgroup_model)

    refgroup_entry.set_enabled(True)
    sample_entry.enqueue(refgroup_entry)
    refgroup_entry.enqueue(char_entry)

    char_model.set_enabled(task['checked'])
    char_entry.set_enabled(task['checked'])

    return char_model._node_id
Ejemplo n.º 6
0
    def create_task_button_click(self):
        if self.tool_box.currentItem().approve_creation():
            items = self.tree_brick.get_selected_items()

            if not items:
                logging.getLogger("user_level_log").\
                    warning("Select the sample or group you "\
                            "would like to add to.")
            else:
                for item in items:
                    shapes = self.shape_history.selected_shapes
                    task_model = item.get_model()

                    # Create a new group if sample is selected
                    if isinstance(task_model, queue_model_objects.Sample):
                        group_task_node = queue_model_objects.TaskGroup()
                        current_item = self.tool_box.currentItem()

                        if current_item is self.workflow_page:
                            group_name = current_item._workflow_cbox.currentText()
                        else:
                            group_name = current_item._task_node_name

                        group_task_node.set_name(group_name)
                        num = task_model.get_next_number_for_name(group_name)
                        group_task_node.set_number(num)

                        self.tree_brick.queue_model_hwobj.\
                          add_child(task_model, group_task_node)

                        task_model = group_task_node
                    
                    if len(shapes):
                        for shape in shapes:
                            self.create_task(task_model, shape)
                    else:
                        self.create_task(task_model)

            self.tool_box.currentItem().update_selection()
Ejemplo n.º 7
0
    def execute(self):
        BaseQueueEntry.execute(self)
        log = logging.getLogger("user_level_log")

        self.get_view().setText(1, "Characterising")
        log.info("Characterising, please wait ...")
        char = self.get_data_model()
        reference_image_collection = char.reference_image_collection
        characterisation_parameters = char.characterisation_parameters

        if self.data_analysis_hwobj is not None:
            edna_input = self.data_analysis_hwobj.\
                         from_params(reference_image_collection,
                                     characterisation_parameters)
            #Un-comment to use the test input files
            #edna_input = XSDataInputMXCuBE.parseString(edna_test_data.EDNA_TEST_DATA)
            #edna_input.process_directory = reference_image_collection.acquisitions[0].\
            #                                path_template.process_directory

            self.edna_result = self.data_analysis_hwobj.characterise(
                edna_input)

        if self.edna_result:
            log.info("Characterisation successful.")

            char.html_report = self.data_analysis_hwobj.\
                               get_html_report(self.edna_result)

            try:
                strategy_result = self.edna_result.getCharacterisationResult().\
                                  getStrategyResult()
            except:
                strategy_result = None

            if strategy_result:
                collection_plan = strategy_result.getCollectionPlan()
            else:
                collection_plan = None

            if collection_plan:
                dcg_model = char.get_parent()
                sample_data_model = dcg_model.get_parent()

                new_dcg_name = 'Diffraction plan'
                new_dcg_num = dcg_model.get_parent().\
                              get_next_number_for_name(new_dcg_name)

                new_dcg_model = queue_model_objects.TaskGroup()
                new_dcg_model.set_enabled(False)
                new_dcg_model.set_name(new_dcg_name)
                new_dcg_model.set_number(new_dcg_num)
                self.queue_model_hwobj.add_child(sample_data_model,
                                                 new_dcg_model)

                edna_collections = queue_model_objects.\
                                   dc_from_edna_output(self.edna_result,
                                                       reference_image_collection,
                                                       new_dcg_model,
                                                       sample_data_model,
                                                       self.beamline_setup)

                for edna_dc in edna_collections:
                    path_template = edna_dc.acquisitions[0].path_template
                    run_number = self.queue_model_hwobj.get_next_run_number(
                        path_template)
                    path_template.run_number = run_number

                    edna_dc.set_enabled(False)
                    edna_dc.set_name(path_template.get_prefix())
                    edna_dc.set_number(path_template.run_number)
                    self.queue_model_hwobj.add_child(new_dcg_model, edna_dc)

                self.get_view().setText(1, "Done")
            else:
                self.get_view().setText(1, "No result")
                self.status = QUEUE_ENTRY_STATUS.WARNING
                log.warning("Characterisation completed " +\
                            "successfully but without collection plan.")
        else:
            self.get_view().setText(1, "Charact. Failed")

            if self.data_analysis_hwobj.is_running():
                log.error('EDNA-Characterisation, software is not responding.')
                log.error("Characterisation completed with error: "\
                          + " data analysis server is not responding.")
            else:
                log.error('EDNA-Characterisation completed with a failure.')
                log.error("Characterisation completed with errors.")

        char.set_executed(True)
        self.get_view().setHighlighted(True)