def _start_experiments(self): self.cc.settings['general']['distribution'][ 'start_time'] = time.strftime('%Y-%m-%d_%H-%M-%S') # If DB logging is enabled, create a new experiment and attach its ID to settings for clients db_logger = DbLogger() if db_logger.is_enabled: self.experiment_id = db_logger.create_experiment(self.cc.settings) self.cc.settings['general']['logging'][ 'experiment_id'] = self.experiment_id for client in self.cc.settings['general']['distribution'][ 'client_nodes']: address = 'http://{}:{}/experiments'.format( client['address'], client['port']) try: resp = requests.post(address, json=self.cc.settings) assert resp.status_code == 200, resp.text self._logger.info( 'Successfully started experiment on {}'.format(address)) except AssertionError as err: self._logger.critical( 'Could not start experiment on {}: {}'.format( address, err)) self._terminate()
def _start_experiments(self): self.cc.settings['general']['distribution'][ 'start_time'] = time.strftime('%Y-%m-%d_%H-%M-%S') # If DB logging is enabled, create a new experiment and attach its ID to settings for clients db_logger = DbLogger() if db_logger.is_enabled: self.experiment_id = db_logger.create_experiment(self.cc.settings) self.cc.settings['general']['logging'][ 'experiment_id'] = self.experiment_id while self.grid.empty_spaces() > 0: worker = self.topology.get_best_worker() w_id = self.grid.assign_worker(worker) self.topology.assign_worker(worker) self._logger.info("Asigned worker {} to wid {}".format( worker, w_id)) self.comms.send_task("new_comm", worker, data={ "color": 0, "key": w_id }) for off_pu in self.topology.inactive_pu: self._logger.info("Asigned worker {} to rest".format(off_pu)) self.comms.send_task("new_comm", off_pu, data={ "color": 1, "key": off_pu }) self.comms.new_comm(1, 0) # print(self.grid.grid) for proc_unit in self.grid.grid_to_list(): self.cc.settings["general"]["distribution"]["grid"][ "config"] = self.grid.grid self.comms.start_worker(proc_unit, self.cc.settings)