def get_trials(lab: Lab, exp_name: str): exp = ExperimentInfo(lab, exp_name) trials = [] with open(exp.trials_log_file, "r") as file: content = file.read() trials_dict = util.yaml_load(content) for d in trials_dict: trial = Trial.from_dict(d) trials.append(trial) return trials
def __get_run_info(experiment_name: str, run_uuid: str): lab = Analyzer.__get_lab() experiment_path = lab.experiments / experiment_name run_path = experiment_path / run_uuid run_info_path = run_path / 'run.yaml' with open(str(run_info_path), 'r') as f: data = util.yaml_load(f.read()) run = experiment_run.RunInfo.from_dict(experiment_path, data) return run
def _log_trial(self, is_add: bool): """ ### Log trial This will add or update a trial in the `trials.yaml` file """ try: with open(str(self.info.trials_log_file), "r") as file: trials = util.yaml_load(file.read()) except FileNotFoundError: trials = [] if is_add: trials.append(self.trial.to_dict()) else: trials[-1] = self.trial.to_dict() with open(str(self.info.trials_log_file), "w") as file: file.write(util.yaml_dump(trials))
def __init__(self, experiment_name: str, run_uuid: str, is_altair: bool = True): self.run_info = Analyzer.__get_run_info(experiment_name, run_uuid) if not is_altair: from .matplotlib.sqlite import MatPlotLibSQLiteAnalytics from .matplotlib.tb import MatPlotLibTensorBoardAnalytics self.tb = MatPlotLibTensorBoardAnalytics( self.run_info.tensorboard_log_path) self.sqlite = MatPlotLibSQLiteAnalytics(self.run_info.sqlite_path) else: from .altair.tb import AltairTensorBoardAnalytics self.tb = AltairTensorBoardAnalytics( self.run_info.tensorboard_log_path) with open(str(self.run_info.indicators_path), 'r') as f: self.indicators = util.yaml_load(f.read())
def __get_config_files(path: str): path = Path(path) configs = [] while path.exists(): if path.is_dir(): config_file = path / _CONFIG_FILE_NAME if config_file.is_file(): with open(str(config_file)) as f: config = util.yaml_load(f.read()) if config is None: config = {} config['config_file_path'] = path configs.append(config) if str(path) == path.root: break path = path.parent return configs