From 91fa7356eb7deb75e3b9a70fa047d5961d5365b1 Mon Sep 17 00:00:00 2001 From: feri Date: Mon, 5 May 2025 20:32:52 +0200 Subject: [PATCH 1/3] issue #50206: add more template_fields to RunPipelineJobOperator the fields "template_path", "pipeline_root", "parameter_values", "service_account" where added to allow jinja templating these args. --- .../google/cloud/operators/vertex_ai/pipeline_job.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/providers/google/src/airflow/providers/google/cloud/operators/vertex_ai/pipeline_job.py b/providers/google/src/airflow/providers/google/cloud/operators/vertex_ai/pipeline_job.py index 883dafe6a74eb..30352c541712c 100644 --- a/providers/google/src/airflow/providers/google/cloud/operators/vertex_ai/pipeline_job.py +++ b/providers/google/src/airflow/providers/google/cloud/operators/vertex_ai/pipeline_job.py @@ -112,6 +112,10 @@ class RunPipelineJobOperator(GoogleCloudBaseOperator): "project_id", "input_artifacts", "impersonation_chain", + "template_path", + "pipeline_root", + "parameter_values", + "service_account", ] operator_extra_links = (VertexAIPipelineJobLink(),) From 81b47c84599798b8081ae9d69af06ca8465547ef Mon Sep 17 00:00:00 2001 From: feri Date: Mon, 5 May 2025 21:56:30 +0200 Subject: [PATCH 2/3] add new template_fields to unit tests --- .../tests/unit/google/cloud/operators/test_vertex_ai.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/providers/google/tests/unit/google/cloud/operators/test_vertex_ai.py b/providers/google/tests/unit/google/cloud/operators/test_vertex_ai.py index 80f488a334087..c1299b414829f 100644 --- a/providers/google/tests/unit/google/cloud/operators/test_vertex_ai.py +++ b/providers/google/tests/unit/google/cloud/operators/test_vertex_ai.py @@ -1216,6 +1216,10 @@ def test_templating(self, create_task_instance_of_operator, session): region="{{ 'region' }}", project_id="{{ 'project_id' }}", impersonation_chain="{{ 'impersonation-chain' }}", + template_path="{{ 'template-path' }}", + pipeline_root="{{ 'pipeline-root' }}", + service_account="{{ 'service-account' }}", + parameter_values={"{{ 'parameter-key' }}": "{{ 'parameter-value' }}"}, # Other parameters dag_id="test_template_body_templating_dag", task_id="test_template_body_templating_task", @@ -1229,6 +1233,10 @@ def test_templating(self, create_task_instance_of_operator, session): assert task.region == "region" assert task.project_id == "project_id" assert task.impersonation_chain == "impersonation-chain" + assert task.template_path == "template-path" + assert task.pipeline_root == "pipeline-root" + assert task.service_account == "service-account" + assert task.parameter_values == {"parameter-key": "parameter-value"} assert task.training_pipeline_id == "training-pipeline-id" assert task.custom_job_id == "custom_job_id" From 8108f63b9170f10b34b6022ce82fa046b32c438d Mon Sep 17 00:00:00 2001 From: feri Date: Tue, 6 May 2025 00:46:36 +0200 Subject: [PATCH 3/3] rollback templating tests for wrong operator --- .../tests/unit/google/cloud/operators/test_vertex_ai.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/providers/google/tests/unit/google/cloud/operators/test_vertex_ai.py b/providers/google/tests/unit/google/cloud/operators/test_vertex_ai.py index c1299b414829f..80f488a334087 100644 --- a/providers/google/tests/unit/google/cloud/operators/test_vertex_ai.py +++ b/providers/google/tests/unit/google/cloud/operators/test_vertex_ai.py @@ -1216,10 +1216,6 @@ def test_templating(self, create_task_instance_of_operator, session): region="{{ 'region' }}", project_id="{{ 'project_id' }}", impersonation_chain="{{ 'impersonation-chain' }}", - template_path="{{ 'template-path' }}", - pipeline_root="{{ 'pipeline-root' }}", - service_account="{{ 'service-account' }}", - parameter_values={"{{ 'parameter-key' }}": "{{ 'parameter-value' }}"}, # Other parameters dag_id="test_template_body_templating_dag", task_id="test_template_body_templating_task", @@ -1233,10 +1229,6 @@ def test_templating(self, create_task_instance_of_operator, session): assert task.region == "region" assert task.project_id == "project_id" assert task.impersonation_chain == "impersonation-chain" - assert task.template_path == "template-path" - assert task.pipeline_root == "pipeline-root" - assert task.service_account == "service-account" - assert task.parameter_values == {"parameter-key": "parameter-value"} assert task.training_pipeline_id == "training-pipeline-id" assert task.custom_job_id == "custom_job_id"