You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2023/12/11 15:27:36 UTC
(airflow) branch main updated: Add overrides to template fields of Google Cloud Run Jobs Execute Operator (#36133)
This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 3dddfb4a4a Add overrides to template fields of Google Cloud Run Jobs Execute Operator (#36133)
3dddfb4a4a is described below
commit 3dddfb4a4ae112544fd02e09a5633961fa725a36
Author: guillaume blaquiere <gu...@gmail.com>
AuthorDate: Mon Dec 11 16:27:29 2023 +0100
Add overrides to template fields of Google Cloud Run Jobs Execute Operator (#36133)
* feat: add overrides in the template fields
* feat: add test on overrides in the template fields
---
airflow/providers/google/cloud/operators/cloud_run.py | 2 +-
tests/providers/google/cloud/operators/test_cloud_run.py | 9 ++++++++-
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/airflow/providers/google/cloud/operators/cloud_run.py b/airflow/providers/google/cloud/operators/cloud_run.py
index 91b3ae6cea..7aab64096f 100644
--- a/airflow/providers/google/cloud/operators/cloud_run.py
+++ b/airflow/providers/google/cloud/operators/cloud_run.py
@@ -264,7 +264,7 @@ class CloudRunExecuteJobOperator(GoogleCloudBaseOperator):
:param deferrable: Run operator in the deferrable mode
"""
- template_fields = ("project_id", "region", "gcp_conn_id", "impersonation_chain", "job_name")
+ template_fields = ("project_id", "region", "gcp_conn_id", "impersonation_chain", "job_name", "overrides")
def __init__(
self,
diff --git a/tests/providers/google/cloud/operators/test_cloud_run.py b/tests/providers/google/cloud/operators/test_cloud_run.py
index 829518e0d0..459dd81b27 100644
--- a/tests/providers/google/cloud/operators/test_cloud_run.py
+++ b/tests/providers/google/cloud/operators/test_cloud_run.py
@@ -40,6 +40,12 @@ TASK_ID = "test"
PROJECT_ID = "testproject"
REGION = "us-central1"
JOB_NAME = "jobname"
+OVERRIDES = {
+ "container_overrides": [{"args": ["python", "main.py"]}],
+ "task_count": 1,
+ "timeout": "60s",
+}
+
JOB = Job()
JOB.name = JOB_NAME
@@ -78,11 +84,12 @@ class TestCloudRunCreateJobOperator:
class TestCloudRunExecuteJobOperator:
def test_template_fields(self):
operator = CloudRunExecuteJobOperator(
- task_id=TASK_ID, project_id=PROJECT_ID, region=REGION, job_name=JOB_NAME
+ task_id=TASK_ID, project_id=PROJECT_ID, region=REGION, job_name=JOB_NAME, overrides=OVERRIDES
)
_assert_common_template_fields(operator.template_fields)
assert "job_name" in operator.template_fields
+ assert "overrides" in operator.template_fields
@mock.patch(CLOUD_RUN_HOOK_PATH)
def test_execute_success(self, hook_mock):