From 6850d6e99f2587147833c661558a4f9a6a524cc8 Mon Sep 17 00:00:00 2001 From: Cody Baker <51133164+CodyCBakerPhD@users.noreply.github.com> Date: Wed, 14 Feb 2024 22:40:20 -0500 Subject: [PATCH 1/5] try to add test case to reproduce --- tests/test_inspector.py | 50 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/tests/test_inspector.py b/tests/test_inspector.py index 1c207f4d..9d599a1b 100644 --- a/tests/test_inspector.py +++ b/tests/test_inspector.py @@ -589,7 +589,7 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): rmtree(cls.tempdir) - + def test_inspect_nwbfile_dandi_config_critical_only_entire_registry(self): test_results = list( inspect_nwbfile( @@ -656,6 +656,54 @@ def test_inspect_nwbfile_dandi_config_violation_and_above_entire_registry(self): ] self.assertCountEqual(first=test_results, second=true_results) + def inspect_all_dandi_config_parallel(self): + + test_results = list(inspect_all(path=Path(self.nwbfile_paths[0]).parent, config=load_config(filepath_or_keyword="dandi"), n_jobs=2)) + + expected_results = [ + InspectorMessage( + message="Subject is missing.", + importance=Importance.CRITICAL, + check_function_name="check_subject_exists", + object_type="NWBFile", + object_name="root", + location="/", + file_path=self.nwbfile_paths[0], + ), + InspectorMessage( + message="The length of the first dimension of data (4) does not match the length of timestamps (3).", + importance=Importance.CRITICAL, + check_function_name="check_timestamps_match_first_dimension", + object_type="TimeSeries", + object_name="test_time_series_3", + location="/acquisition/test_time_series_3", + file_path=self.nwbfile_paths[0], + ), + InspectorMessage( + message="Subject is missing.", + importance=Importance.CRITICAL, + check_function_name="check_subject_exists", + object_type="NWBFile", + object_name="root", + location="/", + file_path=self.nwbfile_paths[1], + ), + InspectorMessage( + message=( + "Data may be in the wrong orientation. Time should be in the first dimension, " + "and is usually the longest dimension. Here, another dimension is longer." + ), + importance=Importance.BEST_PRACTICE_VIOLATION, + severity=Severity.LOW, + check_function_name="check_data_orientation", + object_type="TimeSeries", + object_name="my_spatial_series", + location="/acquisition/my_spatial_series", + file_path=self.nwbfile_paths[1], + ), + ] + self.assertCountEqual(first=test_results, second=true_results) + class TestCheckUniqueIdentifiersPass(TestCase): maxDiff = None From cbd7656666e69645c96eed009ad7fdd95c73b0cb Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 15 Feb 2024 03:41:11 +0000 Subject: [PATCH 2/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_inspector.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/test_inspector.py b/tests/test_inspector.py index 9d599a1b..55fc4ad3 100644 --- a/tests/test_inspector.py +++ b/tests/test_inspector.py @@ -589,7 +589,7 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): rmtree(cls.tempdir) - + def test_inspect_nwbfile_dandi_config_critical_only_entire_registry(self): test_results = list( inspect_nwbfile( @@ -658,7 +658,11 @@ def test_inspect_nwbfile_dandi_config_violation_and_above_entire_registry(self): def inspect_all_dandi_config_parallel(self): - test_results = list(inspect_all(path=Path(self.nwbfile_paths[0]).parent, config=load_config(filepath_or_keyword="dandi"), n_jobs=2)) + test_results = list( + inspect_all( + path=Path(self.nwbfile_paths[0]).parent, config=load_config(filepath_or_keyword="dandi"), n_jobs=2 + ) + ) expected_results = [ InspectorMessage( From fc0f08c89a2c619ba71db52ef8f9ae6da55636a7 Mon Sep 17 00:00:00 2001 From: Cody Baker <51133164+CodyCBakerPhD@users.noreply.github.com> Date: Wed, 14 Feb 2024 22:56:46 -0500 Subject: [PATCH 3/5] try cli --- tests/test_inspector.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/test_inspector.py b/tests/test_inspector.py index 55fc4ad3..85f5503e 100644 --- a/tests/test_inspector.py +++ b/tests/test_inspector.py @@ -411,7 +411,7 @@ def test_command_line_runs_cli_only_parallel(self): true_file_path=Path(__file__).parent / "true_nwbinspector_default_report.txt", skip_first_newlines=True, ) - + def test_command_line_saves_report(self): console_output_file = self.tempdir / "test_console_output_3.txt" os.system( @@ -657,10 +657,10 @@ def test_inspect_nwbfile_dandi_config_violation_and_above_entire_registry(self): self.assertCountEqual(first=test_results, second=true_results) def inspect_all_dandi_config_parallel(self): - + """Reproducing Issue #436.""" test_results = list( inspect_all( - path=Path(self.nwbfile_paths[0]).parent, config=load_config(filepath_or_keyword="dandi"), n_jobs=2 + path=self.tmpdir, config=load_config(filepath_or_keyword="dandi"), n_jobs=2 ) ) @@ -708,6 +708,13 @@ def inspect_all_dandi_config_parallel(self): ] self.assertCountEqual(first=test_results, second=true_results) + def test_command_line_runs_parallel_with_config_and_report(self): + """Reproducing Issue #436.""" + console_output_file = self.tempdir / "test_command_line_runs_parallel_with_config_and_report_results.txt" + os.system( + f"nwbinspector {str(self.tempdir)} --config dandi --report-file-path {console_output_file} --n-jobs 2" + ) + class TestCheckUniqueIdentifiersPass(TestCase): maxDiff = None From 0082407af33427567c95e9a090fcf135f5044458 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 15 Feb 2024 03:56:53 +0000 Subject: [PATCH 4/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_inspector.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/test_inspector.py b/tests/test_inspector.py index 85f5503e..0bd22d65 100644 --- a/tests/test_inspector.py +++ b/tests/test_inspector.py @@ -411,7 +411,7 @@ def test_command_line_runs_cli_only_parallel(self): true_file_path=Path(__file__).parent / "true_nwbinspector_default_report.txt", skip_first_newlines=True, ) - + def test_command_line_saves_report(self): console_output_file = self.tempdir / "test_console_output_3.txt" os.system( @@ -658,11 +658,7 @@ def test_inspect_nwbfile_dandi_config_violation_and_above_entire_registry(self): def inspect_all_dandi_config_parallel(self): """Reproducing Issue #436.""" - test_results = list( - inspect_all( - path=self.tmpdir, config=load_config(filepath_or_keyword="dandi"), n_jobs=2 - ) - ) + test_results = list(inspect_all(path=self.tmpdir, config=load_config(filepath_or_keyword="dandi"), n_jobs=2)) expected_results = [ InspectorMessage( From 20674815bf348e2760df6047e19ba880bb3d42b1 Mon Sep 17 00:00:00 2001 From: Cody Baker <51133164+CodyCBakerPhD@users.noreply.github.com> Date: Wed, 14 Feb 2024 22:58:24 -0500 Subject: [PATCH 5/5] add assertion --- tests/test_inspector.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_inspector.py b/tests/test_inspector.py index 0bd22d65..1767bd54 100644 --- a/tests/test_inspector.py +++ b/tests/test_inspector.py @@ -710,6 +710,7 @@ def test_command_line_runs_parallel_with_config_and_report(self): os.system( f"nwbinspector {str(self.tempdir)} --config dandi --report-file-path {console_output_file} --n-jobs 2" ) + assert console_output_file.exists() class TestCheckUniqueIdentifiersPass(TestCase):