From 074a41cd739b8c17e63341b93a0e31bba4e7555f Mon Sep 17 00:00:00 2001 From: Donald Campbell <125581724+donaldcampbelljr@users.noreply.github.com> Date: Tue, 23 Apr 2024 12:06:16 -0400 Subject: [PATCH 1/5] potential fix for #150 --- pipestat/reports.py | 2 +- tests/test_pipestat.py | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/pipestat/reports.py b/pipestat/reports.py index 2cf5422b..ffff8a57 100644 --- a/pipestat/reports.py +++ b/pipestat/reports.py @@ -704,7 +704,7 @@ def create_index_html(self, navbar, footer): all_result_identifiers = input_sample_attributes + all_result_identifiers if self.prj.cfg["multi_result_files"] is True: - pipeline_types = ["sample", "project"] + pipeline_types = ["sample"] else: pipeline_types = [self.prj.backend.pipeline_type] diff --git a/tests/test_pipestat.py b/tests/test_pipestat.py index 1015e418..cd0a6ec7 100644 --- a/tests/test_pipestat.py +++ b/tests/test_pipestat.py @@ -2514,3 +2514,36 @@ def test_select_history_complex_objects( assert len(history_result.keys()) == 1 assert "output_image" in history_result assert len(history_result["output_image"].keys()) == 2 + + @pytest.mark.parametrize("backend", ["file"]) + def test_temp( + self, + config_file_path, + results_file_path, + recursive_schema_file_path, + backend, + range_values, + ): + # This is for temporary PEATAC testing for determining summarize function + with TemporaryDirectory() as d, ContextManagerDBTesting(DB_URL): + temp_dir = d + # single_results_file_path = "{record_identifier}/results.yaml" + # results_file_path = os.path.join(temp_dir, single_results_file_path) + # args = dict(schema_path=recursive_schema_file_path, database_only=False) + # n = 3 + config_file_path = "/home/drc/pepatac_tutorial/processed/looper_pipestat_config.yaml" + + # for i in range_values[:n]: + # r_id = i[0] + # val = i[1] + # backend_data = {"record_identifier": r_id, "results_file_path": results_file_path} + # args.update(backend_data) + # psm = SamplePipestatManager(**args) + # psm.report(record_identifier=r_id, values=val, force_overwrite=True) + psm = PipestatManager(config_file=config_file_path) + reportlink = psm.summarize() + print(reportlink) + statstsv = psm.table() + print(statstsv) + # data = YAMLConfigManager(filepath=os.path.join(temp_dir, "aggregate_results.yaml")) + # assert r_id in data[psm.pipeline_name][psm.pipeline_type].keys() From 182455a09d68a7c1ff70b1cdb3d808e04f3af70d Mon Sep 17 00:00:00 2001 From: Donald Campbell <125581724+donaldcampbelljr@users.noreply.github.com> Date: Tue, 23 Apr 2024 12:58:29 -0400 Subject: [PATCH 2/5] potential fix for #148 --- pipestat/reports.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pipestat/reports.py b/pipestat/reports.py index ffff8a57..ee2d0989 100644 --- a/pipestat/reports.py +++ b/pipestat/reports.py @@ -731,6 +731,15 @@ def create_index_html(self, navbar, footer): if key not in sample_stat_results.keys(): sample_stat_results[key] = "" + for key in self.schema.keys(): + if "type" in self.schema[key]: + if ( + self.schema[key]["type"] == "file" + or self.schema[key]["type"] == "image" + or self.schema[key]["type"] == "object" + ): + del sample_stat_results[key] + # Sort to ensure alignment in the table sorted_sample_stat_results = dict(sorted(sample_stat_results.items())) From 5379c36dee8ae19ce7112f894d835361f8f7a377 Mon Sep 17 00:00:00 2001 From: Donald Campbell <125581724+donaldcampbelljr@users.noreply.github.com> Date: Tue, 23 Apr 2024 15:09:01 -0400 Subject: [PATCH 3/5] Remove record identifier from stats column #148 --- pipestat/reports.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pipestat/reports.py b/pipestat/reports.py index ee2d0989..b4ff4c79 100644 --- a/pipestat/reports.py +++ b/pipestat/reports.py @@ -789,13 +789,14 @@ def create_index_html(self, navbar, footer): ) project_objects = self.create_project_objects() - columns = ["Record Identifiers"] + list(sorted_sample_stat_results.keys()) + columns_table = ["Record Identifiers"] + list(sorted_sample_stat_results.keys()) + columns_stats = list(sorted_sample_stat_results.keys()) template_vars = dict( navbar=navbar, stats_file_path=stats_file_path, objs_file_path=objs_file_path, - columns=columns, - columns_json=dumps(columns), + columns=columns_table, + columns_json=dumps(columns_stats), table_row_data=table_row_data, project_name=self.prj.cfg[PROJECT_NAME], pipeline_name=self.pipeline_name, @@ -947,7 +948,7 @@ def get_nonhighlighted_results(self, types): def _stats_to_json_str(self): results = {} if self.prj.cfg["multi_result_files"] is True: - pipeline_types = ["sample", "project"] + pipeline_types = ["sample"] else: pipeline_types = [self.prj.backend.pipeline_type] From 07b4697378c7fe16fe8f98a263cb15915474193d Mon Sep 17 00:00:00 2001 From: Donald Campbell <125581724+donaldcampbelljr@users.noreply.github.com> Date: Tue, 23 Apr 2024 15:17:34 -0400 Subject: [PATCH 4/5] Remove manual reporting test --- tests/test_pipestat.py | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/tests/test_pipestat.py b/tests/test_pipestat.py index cd0a6ec7..7e5f08fe 100644 --- a/tests/test_pipestat.py +++ b/tests/test_pipestat.py @@ -2515,35 +2515,3 @@ def test_select_history_complex_objects( assert "output_image" in history_result assert len(history_result["output_image"].keys()) == 2 - @pytest.mark.parametrize("backend", ["file"]) - def test_temp( - self, - config_file_path, - results_file_path, - recursive_schema_file_path, - backend, - range_values, - ): - # This is for temporary PEATAC testing for determining summarize function - with TemporaryDirectory() as d, ContextManagerDBTesting(DB_URL): - temp_dir = d - # single_results_file_path = "{record_identifier}/results.yaml" - # results_file_path = os.path.join(temp_dir, single_results_file_path) - # args = dict(schema_path=recursive_schema_file_path, database_only=False) - # n = 3 - config_file_path = "/home/drc/pepatac_tutorial/processed/looper_pipestat_config.yaml" - - # for i in range_values[:n]: - # r_id = i[0] - # val = i[1] - # backend_data = {"record_identifier": r_id, "results_file_path": results_file_path} - # args.update(backend_data) - # psm = SamplePipestatManager(**args) - # psm.report(record_identifier=r_id, values=val, force_overwrite=True) - psm = PipestatManager(config_file=config_file_path) - reportlink = psm.summarize() - print(reportlink) - statstsv = psm.table() - print(statstsv) - # data = YAMLConfigManager(filepath=os.path.join(temp_dir, "aggregate_results.yaml")) - # assert r_id in data[psm.pipeline_name][psm.pipeline_type].keys() From 66cdc2f9ed321f374d36858d2b2344ed2db879b5 Mon Sep 17 00:00:00 2001 From: Donald Campbell <125581724+donaldcampbelljr@users.noreply.github.com> Date: Tue, 23 Apr 2024 15:23:43 -0400 Subject: [PATCH 5/5] lint --- tests/test_pipestat.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_pipestat.py b/tests/test_pipestat.py index 7e5f08fe..1015e418 100644 --- a/tests/test_pipestat.py +++ b/tests/test_pipestat.py @@ -2514,4 +2514,3 @@ def test_select_history_complex_objects( assert len(history_result.keys()) == 1 assert "output_image" in history_result assert len(history_result["output_image"].keys()) == 2 -