def print_workspaces() -> None: """Print list of workspaces to standard output.""" rian.set('mode', 'silent') workspaces = rian.list('workspaces', base='user') ui.info('Workspaces:\n') for workspace in workspaces: ui.info(' %s' % (workspace)) ui.info('')
def print_scripts(workspace: str) -> None: """Print list of scripts to standard output.""" rian.set('mode', 'silent') if rian.open(workspace): ui.info('Scripts in workspace %s:\n' % (rian.get('workspace'))) for script in rian.list('scripts'): ui.info(' %s' % (script)) ui.info('')
def optimize(self, config = None, **kwds): """ """ if not self._set_config(config, **kwds): return None if not self._set_buffer_reset(): return None # get name of optimization algorithm name = self._config.get('algorithm', None) if not name: raise ValueError("""could not optimize '%s' (%s): no optimization algorithm has been set.""" % (self.model.name, self.model.system.type)) or None # get instance of optimization algorithm algorithm = self._get_algorithm(name, category = 'optimization') if not algorithm: raise ValueError("""could not optimize '%s': unsupported optimization algorithm '%s'.""" % (self.model.name, name)) or None # start optimization if algorithm.get('type', None) == 'algorithm': ui.info("optimize '%s' (%s) using %s." % (self.model.name, self.model.system.type, name)) # start key events if not self._buffer['key_events_started']: ui.info("press 'h' for help or 'q' to quit.") self._buffer['key_events_started'] = True rian.set('shell', 'buffmode', 'key') # TODO: retval, try / except etc. run_optimizer = algorithm.get('reference', None) if not run_optimizer: return None retval = True try: retval &= run_optimizer() retval &= self.model.network.initialize(self.model.system) except KeyboardInterrupt: retval = False rian.set('shell', 'buffmode', 'line') return retval
def update(self): """Update epoch and check termination criterions.""" self._buffer['epoch'] += 1 if self._buffer['epoch'] >= self._config['updates']: self._buffer['continue'] = False if self._buffer['key_events']: self._update_keypress() if self._config.get('tracker_obj_tracking_enable', False): self._update_objective_function() if self._config.get('tracker_eval_enable', False): self._update_evaluation() if not self._buffer['continue']: rian.set('shell', 'buffmode', 'line') return self._buffer['continue']
def tearDown(self) -> None: # open previous workspace if rian.get('workspace') != self.workspace: rian.open(self.workspace) rian.set('mode', self.mode)
def setUp(self) -> None: self.mode = rian.get('mode') self.workspace = rian.get('workspace') rian.set('mode', 'silent') # open workspace 'testsuite' rian.open('testsuite', base='site')