diff --git a/pipestat/backends/file_backend/filebackend.py b/pipestat/backends/file_backend/filebackend.py index eea0e77b..94dadaa4 100644 --- a/pipestat/backends/file_backend/filebackend.py +++ b/pipestat/backends/file_backend/filebackend.py @@ -66,7 +66,6 @@ def __init__( self.determine_results_file(self.results_file_path) - def determine_results_file(self, results_file_path: str) -> None: """Initialize or load results_file from given path :param str results_file_path: YAML file to report into, if file is @@ -345,7 +344,6 @@ def report( # record_identifier = record_identifier or self.record_identifier record_identifier = record_identifier - result_formatter = result_formatter or self.result_formatter results_formatted = [] current_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") @@ -670,7 +668,7 @@ def _init_results_file(self) -> None: def aggregate_multi_results(self, results_directory): print(f"results directory {results_directory}") all_result_files = get_all_result_files(results_directory) - aggregate_results_file_path = os.path.join(results_directory,"aggregate_results.yaml") + aggregate_results_file_path = os.path.join(results_directory, "aggregate_results.yaml") # THIS WILL OVERWRITE self.results_file_path and self._data on the current psm! self.results_file_path = aggregate_results_file_path @@ -683,9 +681,13 @@ def aggregate_multi_results(self, results_directory): temp_data = YAMLConfigManager() if self.pipeline_name in temp_data: if "project" in temp_data[self.pipeline_name]: - self._data[self.pipeline_name]["project"].update(temp_data[self.pipeline_name]["project"]) + self._data[self.pipeline_name]["project"].update( + temp_data[self.pipeline_name]["project"] + ) if "sample" in temp_data[self.pipeline_name]: - self._data[self.pipeline_name]["sample"].update(temp_data[self.pipeline_name]["sample"]) + self._data[self.pipeline_name]["sample"].update( + temp_data[self.pipeline_name]["sample"] + ) with self._data as data_locked: data_locked.write() diff --git a/pipestat/helpers.py b/pipestat/helpers.py index a379a277..a8f40727 100644 --- a/pipestat/helpers.py +++ b/pipestat/helpers.py @@ -221,7 +221,6 @@ def force_symlink(file1, file2): def get_all_result_files(results_file_path): - files = glob.glob(results_file_path+'**/*.yaml') + files = glob.glob(results_file_path + "**/*.yaml") # get parent directory, glob all results files, build one results file return return files - diff --git a/pipestat/pipestat.py b/pipestat/pipestat.py index 7ffa21ef..c3a508a5 100644 --- a/pipestat/pipestat.py +++ b/pipestat/pipestat.py @@ -198,12 +198,14 @@ def __init__( "pipeline_type", default="sample", override=pipeline_type ) - self.cfg[FILE_KEY] = mk_abs_via_cfg(self.resolve_results_file_path( - self.cfg[CONFIG_KEY].priority_get( - "results_file_path", - env_var=ENV_VARS["results_file"], - override=results_file_path, - )), + self.cfg[FILE_KEY] = mk_abs_via_cfg( + self.resolve_results_file_path( + self.cfg[CONFIG_KEY].priority_get( + "results_file_path", + env_var=ENV_VARS["results_file"], + override=results_file_path, + ) + ), self.cfg["config_path"], ) @@ -290,16 +292,17 @@ def resolve_results_file_path(self, results_file_path): if results_file_path: assert isinstance(results_file_path, str), TypeError("Path is expected to be a str") if not self.record_identifier and "{record_identifier}" in results_file_path: - raise NotImplementedError(f"Must provide record identifier during PipestatManager creation for this results_file_path: {results_file_path}") + raise NotImplementedError( + f"Must provide record identifier during PipestatManager creation for this results_file_path: {results_file_path}" + ) self.cfg["unresolved_result_path"] = results_file_path return results_file_path.format(record_identifier=self.record_identifier) return results_file_path - def initialize_filebackend(self, record_identifier, results_file_path, flag_file_dir): + def initialize_filebackend(self, record_identifier, results_file_path, flag_file_dir): # Check if there will be multiple results_file_paths _LOGGER.debug(f"Determined file as backend: {results_file_path}") - if self.cfg[DB_ONLY_KEY]: _LOGGER.debug( "Running in database only mode does not make sense with a YAML file as a backend. " @@ -760,7 +763,9 @@ def check_multi_results(self): if self.file and self.cfg["unresolved_result_path"] != self.file: if "{record_identifier}" in self.cfg["unresolved_result_path"]: # assume there are multiple result files in sub-directories - results_directory = self.cfg["unresolved_result_path"].split("{record_identifier}")[0] + results_directory = self.cfg["unresolved_result_path"].split( + "{record_identifier}" + )[0] results_directory = mk_abs_via_cfg(results_directory, self.cfg["config_path"]) self.backend.aggregate_multi_results(results_directory) diff --git a/pipestat/reports.py b/pipestat/reports.py index f8c08421..a8f28b80 100644 --- a/pipestat/reports.py +++ b/pipestat/reports.py @@ -638,7 +638,7 @@ def _get_navbar_dropdown_data_objects(self, objs, wd, context): for obj_id in objs: displayable_ids.append(obj_id.replace("_", " ")) page_name = os.path.join( - self.pipeline_reports, (obj_id + ".html").replace(" ", "_").lower() + self.pipeline_reports, (obj_id + ".html").replace(" ", "%20").lower() ) relpaths.append(_make_relpath(page_name, wd, context)) return relpaths, displayable_ids @@ -650,7 +650,7 @@ def _get_navbar_dropdown_data_samples(self, wd, context): sample_name = sample["record_identifier"] page_name = os.path.join( self.pipeline_reports, - f"{sample_name}.html".replace(" ", "_").lower(), + f"{sample_name}.html".replace(" ", "%20").lower(), ) relpaths.append(_make_relpath(page_name, wd, context)) sample_names.append(sample_name)