def set_upload_file_flags(self): self._simulation_data = SimulationData(self._selected_operation_type, self._selected_operation)
class Operation: """ parent class of Building, Plotting, Simulating """ _operation_dict = OrderedDict() # depends on self._selected_operation_type _selected_operation = str() _selected_operation_type = str() _item = None # class Build, Sim, or Plot (Item) _simulation_data = None # class SimulationData def __init__(self, subject): """ :param subject: (class Subject) """ self._subject = subject def __del__(self): pass @property def selected_operation(self): return self._selected_operation @property def selected_operation_type(self): return self._selected_operation_type def select_operation(self, selected_operation): """ set self._selected_operation from user input if not already selected via previous loop or constructor of Environment else from setting.operation (which is passed to here as function argument) Required: self._operation_dict (dict) :param selected_operation: (string, None if operation not already selected) :return: """ print('\n-----------------------------------------------------------------\n') print('Test subject {} {}\n on {}'.format( self._subject.code, self._subject.branch, self._subject.computer)) if selected_operation: self._selected_operation = selected_operation else: self._selected_operation = select_from_options(self._operation_dict, 'Select operation') def set_upload_file_flags(self): self._simulation_data = SimulationData(self._selected_operation_type, self._selected_operation) def set_numerics_and_processing_data(self, item_type, item_case, item_configuration, flow_process_name, element_type_name, setting_inst, location_of_operation): """ write files if on local computer and simulationData.ReadFileFlags are set :param item_type: (string) :param item_case: (string) :param item_configuration: (string) :param flow_process_name: (string) :param element_type_name: (string) :param setting_inst: (class Setting) :param location_of_operation: (string) :return: """ if location == 'local': # do database queries if self._simulation_data.read_file_flags.numerics: setting_inst.set_numerics_data(self._simulation_data, item_case, item_configuration, flow_process_name, element_type_name) if location_of_operation == 'remote': # file transfer self._simulation_data.write_numerics_data_files() if self._simulation_data.read_file_flags.processing: setting_inst.set_processing_data(self._simulation_data, item_type, item_configuration) if location_of_operation == 'remote': # file transfer self._simulation_data.write_processing_data_file() def run(self, item): """ direct to cluster or load data files (if necessary) and do operation :param item: (class Item (Build, Sim, Plot)) :param simulation_data: (class SimulationData) :return: """ self._item = item if self._subject.location == 'remote' and location == 'local' \ and self._selected_operation_type != 'p': # plotting operations are executed on local computer operate_on_cluster(self._subject, item, self._selected_operation_type, self._selected_operation, self._simulation_data) else: if location == 'remote': # reload modules with data for numerics and parallelization if self._simulation_data.read_file_flags.numerics: self._simulation_data.get_num_data_from_modules(self._subject.id_local_process) if self._simulation_data.read_file_flags.processing: self._simulation_data.get_processing_data_from_module(self._subject.id_local_process) self.operate() # call member of child class