def result_names(selected_dir): result_dirs = search_dir(saved_results_dir / selected_dir, object_type='dir') # check if the result folder has a f.npy file in it valid_results = [] for result_dir in result_dirs: f_file_path = saved_results_dir / selected_dir / result_dir / 'f.npy' if f_file_path.absolute().exists(): valid_results.append(result_dir) return sorted(valid_results, reverse=True)
def fix_old_settings(self): settings_paths = search_dir(saved_results_dir, file_extension='json', return_path=True) for settings_file_path in settings_paths: settings_dict = self.load_settings(settings_file_path) # if settings dict is missing key add default value for key in default_settings_dict: try: settings_dict[key] except KeyError: settings_dict[key] = default_settings_dict[key] self.make_settings_save_file(settings_dict, settings_file_path)
def dir_names(): saved_results_list = search_dir(saved_results_dir, object_type='dir', iterative_search=False) def is_date_dir(dir_name): try: datetime.strptime(dir_name, "%d-%m-%Y") return True except ValueError: return False date_dirs, other_dirs = [], [] for dir_ in saved_results_list: if is_date_dir(dir_): date_dirs.append(dir_) else: other_dirs.append(dir_) # in place : ) date_dirs.sort(key=lambda date: datetime.strptime(date, "%d-%m-%Y"), reverse=True) if other_dirs: other_dirs.sort() date_dirs.extend(other_dirs) return date_dirs
def get_cst_folder_names(): cst_folders = search_dir(dir_path=cst_results_dir, object_type='dirs') return cst_folders
def get_cst_result_file_names(selected_folder): cst_result_folder_path = cst_results_dir / selected_folder cst_results = search_dir(dir_path=cst_result_folder_path, object_type='file', file_extension='txt') return cst_results