def __init__(self, parent = None, label = 'multiprocess plan'): self.worker_count = lset.get_setting('worker_processes') self.worker_report = [] if lgpu.gpu_support: self.gpu_worker = lgpu.CL() use_plan = lset.get_setting('multiprocessing') lfu.plan.__init__(self, parent = parent, label = label, use_plan = use_plan)
def on_run(self, *args, **kwargs): global manager print 'running ensemble: ', self.label try: self.multithread_gui = lset.get_setting('multithread_gui') self.sanitize() self.__dict__.rid_widg_templates('template owners') self.set_data_scheme() self.parent = None if self.multithread_gui: manager.worker_threads.append(lwt.worker_thread(self, self.run, len(manager.worker_threads))) else: self.run() self.produce_output() time.sleep(1) self.parent = manager except: traceback.print_exc(file=sys.stdout) lgd.message_dialog(None, 'Failed to run ensemble!', 'Problem') time.sleep(2) self.parent = manager
def __init__(self, *args, **kwargs): self.impose_default('label', 'fit routine plan', **kwargs) self.impose_default('routines', [], **kwargs) self.impose_default('selected_routine', None, **kwargs) self.impose_default('selected_routine_label', None, **kwargs) self.impose_default('show_progress_plots', True, **kwargs) kwargs['use_plan'] = lset.get_setting('fitting') lfu.plan.__init__(self, *args, **kwargs)
def __init__(self, label = 'ensemble manager', parent = None): global manager manager = self self.current_tab_index = 0 self.settings_manager = lset.settings_manager( parent = self, filename = 'modular_settings.txt') self.settings = self.settings_manager.read_settings() lfu.modular_object_qt.__init__(self, label = label, parent = parent) if lset.get_setting('auto_clear_data_pools'): self.clean_data_pools()
def __init__(self, label = 'mapping plan', parent = None, parameter_space_mobjs = {}, traj_count = 1, key_path = ''): self.parameter_space = None self.parameter_space_mobjs = parameter_space_mobjs self.trajectory = [] self.iteration = 0 self.controller_ref = None self.traj_count = traj_count self.key_path = key_path self.trajectory_string = '' use = lset.get_setting('mapparameterspace') lfu.plan.__init__(self, label = label, parent = parent, use_plan = use)
def __init__(self, *args, **kwargs): self.settings_manager = lset.settings_manager(parent = self, filename = "test_proctor_settings.txt") self.settings = self.settings_manager.read_settings() #def_test_dir = os.path.join(os.getcwd(), # 'libs', 'modular_core', 'tests') #def_test_dir = os.path.join(os.getcwd(), # 'libs', 'modules', 'chemicallite_support', 'tests') def_test_dir = lset.get_setting('test_directory') self.impose_default('test_dir', def_test_dir, **kwargs) self.impose_default('_tests_results_', {}, **kwargs) self.impose_default('_active_tests_', {}, **kwargs) self.impose_default('_tests_', {}, **kwargs) lfu.modular_object_qt.__init__(self, *args, **kwargs)
def __init__(self, *args, **kwargs): self.settings_manager = lset.settings_manager( parent=self, filename='daw_trans_settings.txt') self.settings = self.settings_manager.read_settings() def_ip = lset.get_setting('default_IP') self.udp_receiver = ludp.receiver(parent=self, default_IP=def_ip) self.udp_transceiver = ludp.receiver(parent=self, default_IP=def_ip) #self.udp_receiver.parent = self #self.udp_transceiver.parent = self self.script_sorter.parent = self self.daw_signaler.parent = self lfu.modular_object_qt.__init__(self, *args, **kwargs) self._children_ = [ self.script_sorter, self.daw_signaler, self.udp_transceiver ]
def __init__(self, *args, **kwargs): self.settings_manager = lset.settings_manager( parent = self, filename = 'daw_trans_settings.txt') self.settings = self.settings_manager.read_settings() def_ip = lset.get_setting('default_IP') self.udp_receiver = ludp.receiver( parent = self, default_IP = def_ip) self.udp_transceiver = ludp.receiver( parent = self, default_IP = def_ip) #self.udp_receiver.parent = self #self.udp_transceiver.parent = self self.script_sorter.parent = self self.daw_signaler.parent = self lfu.modular_object_qt.__init__(self, *args, **kwargs) self._children_ = [self.script_sorter, self.daw_signaler, self.udp_transceiver]
def set_data_scheme(self): smart = lset.get_setting('use_smart_pool') if smart and self.cartographer_plan.use_plan and\ not self.fitting_plan.use_plan: data_pool = lgeo.batch_data_pool( self.run_params['plot_targets'], self.cartographer_plan) self.data_scheme = 'smart_batch' self.output_plan.flat_data = False self.data_pool_pkl = os.path.join(os.getcwd(), 'data_pools', '.'.join(['data_pool', 'smart', self.data_pool_id, 'pkl'])) else: data_pool = lgeo.batch_scalars( self.run_params['plot_targets']) self.data_scheme = 'batch' self.output_plan.flat_data = False self.data_pool_pkl = os.path.join(os.getcwd(), 'data_pools', '.'.join(['data_pool', self.data_pool_id, 'pkl'])) return data_pool
def __init__(self, *args, **kwargs): self.settings_manager = lset.settings_manager( parent=self, filename='daw_rec_settings.txt') self.settings = self.settings_manager.read_settings() def_ip = lset.get_setting('default_IP') self.udp_receiver = ludp.receiver(parent=self, default_IP=def_ip) self._children_ = [self.udp_receiver] #self.udp_receiver.parent = self #self.udp_transceiver.parent = self self.jog_distance = '0.1' self.jog_units = 'normalized' self.max_position = self.max_offset self.min_position = -self.max_offset self.left_state = lpm.motor_state_left(parent=self) self.right_state = lpm.motor_state_right(parent=self) self.zero_state = lpm.motor_state_zero(parent=self) self.follow_state = lpm.motor_state_follow(parent=self) if self.on_attach_motor(): self.log_event(' : '.join( ['receiver initiated', str(time.ctime()), '\n\n'])) self.current_position = self.motors[-1].get_position() self.curr_accel = self.motors[-1].getAccel() self.curr_accel_bnds = (self.motors[-1].getMinAccel(), self.motors[-1].getMaxAccel()) self.curr_vel_limit = self.motors[-1].getVelLimit() self.curr_vel_limit_bnds = (self.motors[-1].getVelMin(), self.motors[-1].getVelMax()) else: self.current_position = 0 self.curr_accel = 0 self.curr_accel_bnds = (-1, 1) self.curr_vel_limit = 0 self.curr_vel_limit_bnds = (-1, 1) lfu.modular_object_qt.__init__(self, *args, **kwargs)
def __init__(self, *args, **kwargs): self.settings_manager = lset.settings_manager( parent = self, filename = 'daw_rec_settings.txt') self.settings = self.settings_manager.read_settings() def_ip = lset.get_setting('default_IP') self.udp_receiver = ludp.receiver( parent = self, default_IP = def_ip) self._children_ = [self.udp_receiver] #self.udp_receiver.parent = self #self.udp_transceiver.parent = self self.jog_distance = '0.1' self.jog_units = 'normalized' self.max_position = self.max_offset self.min_position = -self.max_offset self.left_state = lpm.motor_state_left(parent = self) self.right_state = lpm.motor_state_right(parent = self) self.zero_state = lpm.motor_state_zero(parent = self) self.follow_state = lpm.motor_state_follow(parent = self) if self.on_attach_motor(): self.log_event(' : '.join(['receiver initiated', str(time.ctime()), '\n\n'])) self.current_position = self.motors[-1].get_position() self.curr_accel = self.motors[-1].getAccel() self.curr_accel_bnds = (self.motors[-1].getMinAccel(), self.motors[-1].getMaxAccel()) self.curr_vel_limit = self.motors[-1].getVelLimit() self.curr_vel_limit_bnds = (self.motors[-1].getVelMin(), self.motors[-1].getVelMax()) else: self.current_position = 0 self.curr_accel = 0 self.curr_accel_bnds = (-1, 1) self.curr_vel_limit = 0 self.curr_vel_limit_bnds = (-1, 1) lfu.modular_object_qt.__init__(self, *args, **kwargs)
def __init__(self, *args, **kwargs): #self.impose_default('current_tab_index', 0, **kwargs) #self.current_tab_index = 0 self.aborted = False self.data_pool = lfu.data_container( data = [], postproc_data = []) self.data_scheme = None self.__dict__ = lfu.dictionary() if 'parent' in kwargs.keys(): self.parent = kwargs['parent'] self.cancel_make = False self.skip_simulation = False self.mcfg_path = '' #self.num_trajectories = 1 num_traj = lset.get_setting('trajectory_count') if num_traj: self.num_trajectories = num_traj else: self.num_trajectories = 1 self.data_pool_descr = '' self.treebook_memory = [0, [], []] self._module_memory_ = [] self.simulation_plan = simulation_plan(parent = self) self.output_plan = lo.output_plan( label = 'Simulation', parent = self) self.fitting_plan = lfr.fit_routine_plan(parent = self) self.cartographer_plan = lgeo.cartographer_plan( label = 'Parameter Scan', parent = self) self.postprocess_plan = lpp.post_process_plan( label = 'Post Process Plan', parent = self, _always_sourceable_ = ['simulation']) self.multiprocess_plan = lmp.multiprocess_plan(parent = self) self.run_params = lfu.dictionary(parent = self) self.run_params['end_criteria'] = \ self.simulation_plan.end_criteria self.run_params['capture_criteria'] = \ self.simulation_plan.capture_criteria self.run_params['plot_targets'] = \ self.simulation_plan.plot_targets self.run_params['output_plans'] = { 'Simulation' : self.output_plan} self.run_params['fit_routines'] = \ self.fitting_plan.routines self.run_params['post_processes'] = \ self.postprocess_plan.post_processes self.run_params['p_space_map'] = None self.run_params['multiprocessing'] = None self.__dict__.create_partition('template owners', ['output_plan', 'fitting_plan', 'cartographer_plan', 'postprocess_plan', 'multiprocess_plan', 'run_params', 'simulation_plan']) if 'label' not in kwargs.keys(): kwargs['label'] = 'ensemble' if 'module_options' in kwargs.keys(): opts = kwargs['module_options'] else: print 'no modules detected; requesting from manager' opts = self.parent.find_module_options() if len(opts) == 0: lgd.message_dialog(None, 'No module options detected!', 'Problem') self.cancel_make = True return elif len(opts) == 1: module = opts[0] else: module_choice_container = lfu.data_container(data = opts[0]) module_options_templates = [lgm.interface_template_gui( layout = 'horizontal', widgets = ['radio'], verbosities = [0], labels = [opts], initials = [[module_choice_container.data]], instances = [[module_choice_container]], keys = [['data']], box_labels = ['Ensemble Module'], minimum_sizes = [[(250, 50)]])] mod_dlg = lgd.create_dialog(title = 'Choose Ensemble Module', templates = module_options_templates, variety = 'templated') module = mod_dlg() if module: module = module_choice_container.data else: self.cancel_make = True return self.impose_default('module', module, **kwargs) self._children_ = [self.simulation_plan, self.output_plan, self.fitting_plan, self.cartographer_plan, self.postprocess_plan, self.multiprocess_plan] self.load_module(reset_params = True) self.mcfg_dir = os.path.join(os.getcwd(), self.module) if not os.path.isdir(self.mcfg_dir): self.mcfg_dir = os.getcwd() lfu.modular_object_qt.__init__(self, *args, **kwargs) self.data_pool_id = lfu.get_new_pool_id() self.data_pool_pkl = os.path.join(os.getcwd(), 'data_pools', '.'.join(['data_pool', self.data_pool_id, 'pkl']))
def run(self, *args, **kwargs): profiling = lset.get_setting('profile', file_ = 'modular_settings.txt') if profiling: pr = cProfile.Profile() pr.enable() start_time = time.time() print 'start time: ', time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(start_time)) save = False if self.skip_simulation: save = self.perform_post_processing(load = True) else: if self.fitting_plan.use_plan: if not self.cartographer_plan.parameter_space: print 'fitting requires a parameter space!' return False else: self.fitting_plan(self) else: if not self.cartographer_plan.parameter_space and\ self.cartographer_plan.use_plan: print 'no parameter space; ignoring map request' self.cartographer_plan.use_plan = False if self.multiprocess_plan.use_plan and\ self.cartographer_plan.use_plan: self.run_systems_multiproc_mapping() elif not self.multiprocess_plan.use_plan and\ self.cartographer_plan.use_plan: self.run_systems_mapping() elif self.multiprocess_plan.use_plan and not\ self.cartographer_plan.use_plan: self.run_systems_mutliproc() elif not self.multiprocess_plan.use_plan and not\ self.cartographer_plan.use_plan: self.run_systems_boring() save = True print 'duration of simulations: ', time.time() - start_time self.perform_post_processing(load = False) if save: self.save_data_pool() print 'finished last simulation run: exiting' print 'duration: ', time.time() - start_time, ' seconds' if profiling: pr.disable() s = StringIO.StringIO() sortby = 'cumulative' ps = pstats.Stats(pr, stream=s).sort_stats(sortby) ps.print_stats(0.1) print s.getvalue() return True
def __init__(self, label='another output plan', use_plan=True, visible_attributes=[ 'label', 'use_plan', 'output_vtk', 'output_pkl', 'output_txt', 'output_plt', 'save_directory', 'save_filename', 'filenames', 'directories', 'targeted' ], save_directory='', save_filename='', parent=None): self.__dict__ = lfu.dictionary() self.writers = [ writer_vtk(parent=self), writer_pkl(parent=self), writer_txt(parent=self), writer_plt(parent=self) ] self.flat_data = True #if label is not 'another output plan': one_of_a_kind = True self.targeted = [] #lists of strings to list of scalars self.outputs = [[], [], [], []] #strings pointing to targeted scalars self.save_directory = save_directory self.save_filename = save_filename self.filenames = { 'vtk filename': '', 'pkl filename': '', 'txt filename': '', 'plt filename': '' } self.directories = { 'vtk directory': '', 'pkl directory': '', 'txt directory': '', 'plt directory': '' } op_vtk = lset.get_setting('output_vtk') op_pkl = lset.get_setting('output_pkl') op_txt = lset.get_setting('output_txt') op_plt = lset.get_setting('output_plt') if not op_vtk is None: self.output_vtk = op_vtk else: self.output_vtk = False if not op_pkl is None: self.output_pkl = op_pkl else: self.output_pkl = False if not op_txt is None: self.output_txt = op_txt else: self.output_txt = False if not op_plt is None: self.output_plt = op_plt else: self.output_plt = False self.default_targets_vtk = True self.default_targets_pkl = True self.default_targets_txt = True self.default_targets_plt = True self.default_paths_vtk = True self.default_paths_pkl = True self.default_paths_txt = True self.default_paths_plt = True lfu.plan.__init__(self, label=label, use_plan=True, visible_attributes=visible_attributes, parent=parent) self._children_ = self.writers self.__dict__.create_partition('template owners', ['writers'])
def debug_filter(debug_, verbosity = 0, verb_thresh = 100): if lset: check = lset.get_setting('debug_verbosity', fail_silent = True) if check: verb_thresh = check if not verbosity > verb_thresh: print str(debug_)