From 1ccd24d8551e8a30bf8f2c9c23f88b5856eb57eb Mon Sep 17 00:00:00 2001 From: Domantas Jurkus Date: Wed, 30 Oct 2019 16:44:54 +0000 Subject: [PATCH 1/2] [AIRFLOW-5819] Fix default array_properties value for AWSBatchOperator The default value of `None` throws an error and should be changed to `{}` --- airflow/contrib/operators/awsbatch_operator.py | 2 +- tests/contrib/operators/test_awsbatch_operator.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/airflow/contrib/operators/awsbatch_operator.py b/airflow/contrib/operators/awsbatch_operator.py index 22508d17c56a2a..7527d27e0f21d9 100644 --- a/airflow/contrib/operators/awsbatch_operator.py +++ b/airflow/contrib/operators/awsbatch_operator.py @@ -93,7 +93,7 @@ def __init__(self, job_name, job_definition, job_queue, overrides, array_propert self.job_definition = job_definition self.job_queue = job_queue self.overrides = overrides - self.array_properties = array_properties + self.array_properties = array_properties if array_properties is not None else {} self.max_retries = max_retries self.jobId = None # pylint: disable=invalid-name diff --git a/tests/contrib/operators/test_awsbatch_operator.py b/tests/contrib/operators/test_awsbatch_operator.py index 8814857c147369..64bcbf2f68add9 100644 --- a/tests/contrib/operators/test_awsbatch_operator.py +++ b/tests/contrib/operators/test_awsbatch_operator.py @@ -53,7 +53,7 @@ def test_init(self): self.assertEqual(self.batch.job_definition, 'hello-world') self.assertEqual(self.batch.max_retries, 5) self.assertEqual(self.batch.overrides, {}) - self.assertEqual(self.batch.array_properties, None) + self.assertEqual(self.batch.array_properties, {}) self.assertEqual(self.batch.region_name, 'eu-west-1') self.assertEqual(self.batch.aws_conn_id, None) self.assertEqual(self.batch.hook, self.aws_hook_mock.return_value) @@ -78,7 +78,7 @@ def test_execute_without_failures(self, check_mock, wait_mock): jobName='51455483-c62c-48ac-9b88-53a6a725baa3', containerOverrides={}, jobDefinition='hello-world', - arrayProperties=None + arrayProperties={} ) wait_mock.assert_called_once_with() @@ -99,7 +99,7 @@ def test_execute_with_failures(self): jobName='51455483-c62c-48ac-9b88-53a6a725baa3', containerOverrides={}, jobDefinition='hello-world', - arrayProperties=None + arrayProperties={} ) def test_wait_end_tasks(self): From 3eb4cb3e29f8e5cfb972dfcb7c684af0d62d4420 Mon Sep 17 00:00:00 2001 From: Domantas Jurkus Date: Thu, 7 Nov 2019 17:14:21 +0000 Subject: [PATCH 2/2] Update airflow/contrib/operators/awsbatch_operator.py Co-Authored-By: Felix Uellendall --- airflow/contrib/operators/awsbatch_operator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airflow/contrib/operators/awsbatch_operator.py b/airflow/contrib/operators/awsbatch_operator.py index 7527d27e0f21d9..a90f57ddd47d1c 100644 --- a/airflow/contrib/operators/awsbatch_operator.py +++ b/airflow/contrib/operators/awsbatch_operator.py @@ -93,7 +93,7 @@ def __init__(self, job_name, job_definition, job_queue, overrides, array_propert self.job_definition = job_definition self.job_queue = job_queue self.overrides = overrides - self.array_properties = array_properties if array_properties is not None else {} + self.array_properties = array_properties or {} self.max_retries = max_retries self.jobId = None # pylint: disable=invalid-name