def reload_burst_operation(self, operation_id, is_group, **_): """ Find out from which burst was this operation launched. Set that burst as the selected one and redirect to the burst page. """ is_group = int(is_group) if not is_group: operation = OperationService.load_operation(int(operation_id)) else: op_group = ProjectService.get_operation_group_by_id(operation_id) first_op = ProjectService.get_operations_in_group(op_group)[0] operation = OperationService.load_operation(int(first_op.id)) SimulatorController().copy_simulator_configuration(operation.burst.id) raise cherrypy.HTTPRedirect("/burst/")
def reload_burst_operation(self, operation_id, is_group, **_): """ Find out from which burst was this operation launched. Set that burst as the selected one and redirect to the burst page. """ is_group = int(is_group) if not is_group: operation = OperationService.load_operation(int(operation_id)) else: op_group = ProjectService.get_operation_group_by_id(operation_id) first_op = ProjectService.get_operations_in_group(op_group)[0] operation = OperationService.load_operation(int(first_op.id)) operation.burst.prepare_after_load() common.add2session(common.KEY_BURST_CONFIG, operation.burst) raise cherrypy.HTTPRedirect("/burst/")
def _compute_operation_details(self, entity_gid, is_group=False): """ Returns a dictionary which contains the details for the given operation. """ selected_project = common.get_current_project() op_details = self.project_service.get_operation_details( entity_gid, is_group) operation_id = op_details.operation_id display_reload_btn = True operation = OperationService.load_operation(operation_id) if (operation.fk_operation_group is not None) or (operation.burst is not None): display_reload_btn = False else: op_categ_id = operation.algorithm.fk_category raw_categories = self.algorithm_service.get_raw_categories() for category in raw_categories: if category.id == op_categ_id: display_reload_btn = False break template_specification = { "entity_gid": entity_gid, "nodeFields": op_details.get_ui_fields(), "operationId": operation_id, "displayReloadBtn": display_reload_btn, "project": selected_project, "isRelevant": operation.visible } return template_specification
def store_exploration_section(self, val_range, step, dt_group_guid): """ Launching method for further simulations. """ range_list = [float(num) for num in val_range.split(",")] step_list = [float(num) for num in step.split(",")] datatype_group_ob = self.project_service.get_datatypegroup_by_gid(dt_group_guid) operation_grp = datatype_group_ob.parent_operation_group operation_obj = OperationService.load_operation(datatype_group_ob.fk_from_operation) parameters = {} range1name, range1_dict = json.loads(operation_grp.range1) range2name, range2_dict = json.loads(operation_grp.range2) parameters[RANGE_PARAMETER_1] = range1name parameters[RANGE_PARAMETER_2] = range2name # change the existing simulator parameters to be min max step types range1_dict = {constants.ATT_MINVALUE: range_list[0], constants.ATT_MAXVALUE: range_list[1], constants.ATT_STEP: step_list[0]} range2_dict = {constants.ATT_MINVALUE: range_list[2], constants.ATT_MAXVALUE: range_list[3], constants.ATT_STEP: step_list[1]} parameters[range1name] = json.dumps(range1_dict) # this is for the x axis parameter parameters[range2name] = json.dumps(range2_dict) # this is for the y axis parameter OperationService().group_operation_launch(common.get_logged_user().id, common.get_current_project(), operation_obj.algorithm.id, operation_obj.algorithm.fk_category, **parameters) return [True, 'Stored the exploration material successfully']
def reloadoperation(self, operation_id, **_): """Redirect to Operation Input selection page, with input data already selected.""" operation = OperationService.load_operation(operation_id) data = parse_json_parameters(operation.parameters) self.context.add_adapter_to_session(operation.algorithm, None, data) category_id = operation.algorithm.fk_category algo_id = operation.fk_from_algo raise cherrypy.HTTPRedirect("/flow/" + str(category_id) + "/" + str(algo_id) + "?not_reset=True")
def reloadoperation(self, operation_id, **_): """Redirect to Operation Input selection page, with input data already selected.""" operation = OperationService.load_operation(operation_id) # Reload previous parameters in session adapter_instance = ABCAdapter.build_adapter(operation.algorithm) view_model = adapter_instance.load_view_model(operation) self.context.add_view_model_to_session(view_model) # Display the inputs tree for the current op category_id = operation.algorithm.fk_category algo_id = operation.fk_from_algo raise cherrypy.HTTPRedirect("/flow/" + str(category_id) + "/" + str(algo_id))
def create_json(self, item_gid, item_type, visibility_filter): """ Method used for creating a JSON representation of a graph. """ selected_filter = StaticFiltersFactory.build_datatype_filters( single_filter=visibility_filter) project = common.get_current_project() is_upload_operation = (item_type == graph_structures.NODE_OPERATION_TYPE) and \ (self.project_service.is_upload_operation(item_gid) or item_gid == "firstOperation") if is_upload_operation: graph_branches = [] uploader_operations = self.project_service.get_all_operations_for_uploaders( project.id) for operation in uploader_operations: dt_outputs = self.project_service.get_results_for_operation( operation.id, selected_filter) dt_outputs = self._create_datatype_nodes(dt_outputs) parent_op = self._create_operation_nodes([operation], item_gid) branch = graph_structures.GraphComponent([], parent_op, dt_outputs, []) graph_branches.append(branch) graph = graph_structures.FullGraphStructure(graph_branches) return graph.prepare_for_json() dt_inputs, parent_op, dt_outputs, op_inputs = [], [], [], [] if item_type == graph_structures.NODE_OPERATION_TYPE: dt_inputs = self.project_service.get_datatype_and_datatypegroup_inputs_for_operation( item_gid, selected_filter) parent_op = self.project_service.load_operation_by_gid(item_gid) dt_outputs = self.project_service.get_results_for_operation( parent_op.id, selected_filter) #create graph nodes dt_inputs, parent_op, dt_outputs, op_inputs = self._create_nodes( dt_inputs, [parent_op], dt_outputs, [], item_gid) elif item_type == graph_structures.NODE_OPERATION_GROUP_TYPE: parent_op_group = self.project_service.get_operation_group_by_gid( item_gid) dt_inputs = self.project_service.get_datatypes_inputs_for_operation_group( parent_op_group.id, selected_filter) datatype_group = self.project_service.get_datatypegroup_by_op_group_id( parent_op_group.id) datatype = self.project_service.get_datatype_by_id( datatype_group.id) dt_inputs = self._create_datatype_nodes(dt_inputs) parent_op = graph_structures.NodeStructure.build_structure_for_operation_group( parent_op_group.gid) parent_op.selected = True parent_op = [parent_op] if selected_filter.display_name == StaticFiltersFactory.RELEVANT_VIEW and datatype.visible is False: dt_outputs = [] else: dt_outputs = self._create_datatype_nodes([datatype]) elif item_type == graph_structures.NODE_DATATYPE_TYPE: selected_dt = ABCAdapter.load_entity_by_gid(item_gid) if self.project_service.is_datatype_group(item_gid): datatype_group = self.project_service.get_datatypegroup_by_gid( selected_dt.gid) parent_op_group = self.project_service.get_operation_group_by_id( datatype_group.fk_operation_group) dt_inputs = self.project_service.get_datatypes_inputs_for_operation_group( parent_op_group.id, selected_filter) op_inputs = self.project_service.get_operations_for_datatype_group( selected_dt.id, selected_filter) op_inputs_in_groups = self.project_service.get_operations_for_datatype_group( selected_dt.id, selected_filter, only_in_groups=True) # create graph nodes dt_inputs, parent_op, dt_outputs, op_inputs = self._create_nodes( dt_inputs, [], [selected_dt], op_inputs, item_gid) parent_op = [ graph_structures.NodeStructure. build_structure_for_operation_group(parent_op_group.gid) ] op_inputs_in_groups = self._create_operation_group_nodes( op_inputs_in_groups) op_inputs.extend(op_inputs_in_groups) else: parent_op = OperationService.load_operation( selected_dt.fk_from_operation) dt_inputs = self.project_service.get_datatype_and_datatypegroup_inputs_for_operation( parent_op.gid, selected_filter) op_inputs = self.project_service.get_operations_for_datatype( selected_dt.gid, selected_filter) op_inputs_in_groups = self.project_service.get_operations_for_datatype( selected_dt.gid, selected_filter, only_in_groups=True) dt_outputs = self.project_service.get_results_for_operation( parent_op.id, selected_filter) # create graph nodes dt_inputs, parent_op, dt_outputs, op_inputs = self._create_nodes( dt_inputs, [parent_op], dt_outputs, op_inputs, item_gid) op_inputs_in_groups = self._create_operation_group_nodes( op_inputs_in_groups) op_inputs.extend(op_inputs_in_groups) else: self.logger.error("Invalid item type: " + str(item_type)) raise Exception("Invalid item type.") branch = graph_structures.GraphComponent(dt_inputs, parent_op, dt_outputs, op_inputs) graph = graph_structures.FullGraphStructure([branch]) return graph.prepare_for_json()