From eaa1177de7c0c5e381d851000ec0e84ddbf54aaa Mon Sep 17 00:00:00 2001 From: Kurt Wheeler Date: Thu, 18 Oct 2018 10:14:23 -0400 Subject: [PATCH 1/4] Handle no downloader work gracefully. --- workers/data_refinery_workers/downloaders/utils.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/workers/data_refinery_workers/downloaders/utils.py b/workers/data_refinery_workers/downloaders/utils.py index 37cf19662..eeb0a4da5 100644 --- a/workers/data_refinery_workers/downloaders/utils.py +++ b/workers/data_refinery_workers/downloaders/utils.py @@ -196,6 +196,10 @@ def create_processor_job_for_original_files(original_files: List[OriginalFile], """ + # If there's no original files then we've created all the jobs we need to! + if len(original_files) == 0: + return + # For anything that has raw data there should only be one Sample per OriginalFile sample_object = original_files[0].samples.first() pipeline_to_apply = determine_processor_pipeline(sample_object, original_files[0]) From 0433c32cd4212947517e57b6dc24d7d215123df9 Mon Sep 17 00:00:00 2001 From: Kurt Wheeler Date: Thu, 18 Oct 2018 10:20:36 -0400 Subject: [PATCH 2/4] Add unit test to make sure no work isn't an error. --- .../downloaders/test_utils.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 workers/data_refinery_workers/downloaders/test_utils.py diff --git a/workers/data_refinery_workers/downloaders/test_utils.py b/workers/data_refinery_workers/downloaders/test_utils.py new file mode 100644 index 000000000..1d88c8891 --- /dev/null +++ b/workers/data_refinery_workers/downloaders/test_utils.py @@ -0,0 +1,15 @@ +import os + +from django.test import TestCase, tag +from typing import List +from unittest.mock import patch, call +from urllib.error import URLError + +from data_refinery_workers.downloaders import utils + +class UtilsTestCase(TestCase): + def test_no_jobs_to_create(self): + """Make sure this function doesn't raise an exception with no files.""" + create_processor_job_for_original_files([]) + + self.assertTrue(True) From 982f4af638e83ee49c87a0dffad2b47daf872749 Mon Sep 17 00:00:00 2001 From: Kurt Wheeler Date: Tue, 23 Oct 2018 11:18:16 -0400 Subject: [PATCH 3/4] Add tag to downloaders test so it is actually run. --- workers/data_refinery_workers/downloaders/test_utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/workers/data_refinery_workers/downloaders/test_utils.py b/workers/data_refinery_workers/downloaders/test_utils.py index 1d88c8891..8028c2809 100644 --- a/workers/data_refinery_workers/downloaders/test_utils.py +++ b/workers/data_refinery_workers/downloaders/test_utils.py @@ -8,6 +8,7 @@ from data_refinery_workers.downloaders import utils class UtilsTestCase(TestCase): + @tag('downloaders') def test_no_jobs_to_create(self): """Make sure this function doesn't raise an exception with no files.""" create_processor_job_for_original_files([]) From 6b4e73a386ae0b4b904c32554cbdfba17aa2997a Mon Sep 17 00:00:00 2001 From: Kurt Wheeler Date: Fri, 26 Oct 2018 13:18:21 -0400 Subject: [PATCH 4/4] Fix test for no download jobs. --- workers/data_refinery_workers/downloaders/test_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workers/data_refinery_workers/downloaders/test_utils.py b/workers/data_refinery_workers/downloaders/test_utils.py index 8028c2809..26f7d6526 100644 --- a/workers/data_refinery_workers/downloaders/test_utils.py +++ b/workers/data_refinery_workers/downloaders/test_utils.py @@ -11,6 +11,6 @@ class UtilsTestCase(TestCase): @tag('downloaders') def test_no_jobs_to_create(self): """Make sure this function doesn't raise an exception with no files.""" - create_processor_job_for_original_files([]) + utils.create_processor_job_for_original_files([]) self.assertTrue(True)