def load_all_trials(self, status: 'TRIAL_STATUS' = None) -> 'Trials': """ Load all hyperparameter trials with their corresponding score. Reads all the saved trial json files, sorted by creation date. :return: (hyperparams, scores) """ trials = Trials() files = glob.glob(os.path.join(self.cache_folder, '*.json')) # sort by created date: def getmtimens(filename): return os.stat(filename).st_mtime_ns files.sort(key=getmtimens) for base_path in files: with open(base_path) as f: try: trial_json = json.load(f) except Exception as err: print('invalid trial json file'.format(base_path)) print(traceback.format_exc()) continue if status is None or trial_json['status'] == status.value: trials.append(Trial.from_json( update_trial_function=self.save_trial, trial_json=trial_json )) return trials
def load_all_trials(self, status: 'TRIAL_STATUS' = None) -> 'Trials': """ Load all hyperparameter trials with their corresponding score. Reads all the saved trial json files, sorted by creation date. :return: (hyperparams, scores) """ trials = Trials() files = glob.glob(os.path.join(self.cache_folder, '*.json')) # sort by created date: def getmtimens(filename): return os.stat(filename).st_mtime_ns files.sort(key=getmtimens) for base_path in files: with open(base_path) as f: trial_json = json.load(f) if status is None or trial_json['status'] == status.value: trials.append(Trial.from_json(trial_json)) return trials