From 928f83070fd907d650049cc9cc6d46eba780012a Mon Sep 17 00:00:00 2001 From: Hana Snow Date: Wed, 9 Oct 2024 16:06:07 -0400 Subject: [PATCH] do not throw error when no data has been loaded yet --- .../commands/check_for_new_samples_from_pipeline.py | 6 +++++- .../tests/check_for_new_samples_from_pipeline_tests.py | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/seqr/management/commands/check_for_new_samples_from_pipeline.py b/seqr/management/commands/check_for_new_samples_from_pipeline.py index 018aab46b0..7c19dfa95e 100644 --- a/seqr/management/commands/check_for_new_samples_from_pipeline.py +++ b/seqr/management/commands/check_for_new_samples_from_pipeline.py @@ -51,7 +51,11 @@ def handle(self, *args, **options): success_runs = {path: re.match(path_regex, path).groupdict() for path in list_files(path, user=None)} if not success_runs: user_args = [f'{k}={options[k]}' for k in RUN_PATH_FIELDS if options[k]] - raise CommandError(f'No successful runs found for {", ".join(user_args)}') + if user_args: + raise CommandError(f'No successful runs found for {", ".join(user_args)}') + else: + logger.info('No loaded data available') + return loaded_runs = set(Sample.objects.filter(data_source__isnull=False).values_list('data_source', flat=True)) new_runs = {path: run for path, run in success_runs.items() if run['run_version'] not in loaded_runs} diff --git a/seqr/management/tests/check_for_new_samples_from_pipeline_tests.py b/seqr/management/tests/check_for_new_samples_from_pipeline_tests.py index 69ecf3b372..d567e5f9f0 100644 --- a/seqr/management/tests/check_for_new_samples_from_pipeline_tests.py +++ b/seqr/management/tests/check_for_new_samples_from_pipeline_tests.py @@ -326,6 +326,12 @@ def test_command(self, mock_email, mock_airtable_utils): self.mock_glob.assert_called_with('/seqr/seqr-hail-search-data/GRCh37/MITO/runs/*/_SUCCESS') self.mock_subprocess.assert_not_called() + call_command('check_for_new_samples_from_pipeline') + self.mock_logger.info.assert_called_with('No loaded data available') + self.mock_subprocess.assert_not_called() + mock_email.assert_not_called() + self.mock_send_slack.assert_not_called() + local_files = [ '/seqr/seqr-hail-search-data/GRCh38/SNV_INDEL/runs/auto__2023-08-09/_SUCCESS', '/seqr/seqr-hail-search-data/GRCh37/SNV_INDEL/runs/manual__2023-11-02/_SUCCESS',