def retro_analyze_sessions(predir): '''Retro-analyze all session level datas.''' logger.info('Retro-analyzing sessions from file') from slm_lab.experiment.control import Session, SpaceSession for filename in os.listdir(predir): # to account for both types of session_df if filename.endswith('_session_df.csv'): body_df_kind = 'eval' # from body.eval_df prefix = '' is_session_df = True elif filename.endswith('_trainsession_df.csv'): body_df_kind = 'train' # from body.train_df prefix = 'train' is_session_df = True else: is_session_df = False if is_session_df: prepath = f'{predir}/{filename}'.replace( f'_{prefix}session_df.csv', '') spec, info_space = util.prepath_to_spec_info_space(prepath) trial_index, session_index = util.prepath_to_idxs(prepath) SessionClass = Session if spec_util.is_singleton( spec) else SpaceSession session = SessionClass(spec, info_space) session_data = session_data_from_file(predir, trial_index, session_index, ps.get(info_space, 'ckpt'), prefix) analysis._analyze_session(session, session_data, body_df_kind)
def __init__(self, spec, info_space): self.spec = spec self.info_space = info_space self.index = self.info_space.get('trial') info_space.set('session', None) # Session starts anew for new trial util.set_logger(self.spec, self.info_space, logger, 'trial') self.session_data_dict = {} self.data = None analysis.save_spec(spec, info_space, unit='trial') self.is_singleton = spec_util.is_singleton( spec) # singleton mode as opposed to multi-agent-env space self.SessionClass = Session if self.is_singleton else SpaceSession self.mp_runner = init_run_session if self.is_singleton else init_run_space_session logger.info(f'Initialized trial {self.index}')
def retro_analyze_sessions(predir): '''Retro-analyze all session level datas.''' logger.info('Retro-analyzing sessions from file') from slm_lab.experiment.control import Session, SpaceSession for filename in os.listdir(predir): if filename.endswith('_session_df.csv'): prepath = f'{predir}/{filename}'.replace('_session_df.csv', '') spec, info_space = util.prepath_to_spec_info_space(prepath) trial_index, session_index = util.prepath_to_idxs(prepath) SessionClass = Session if spec_util.is_singleton( spec) else SpaceSession session = SessionClass(spec, info_space) session_data = session_data_from_file(predir, trial_index, session_index) analyze_session(session, session_data)