Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix location requirement in DataflowTemplatedJobStartOperator #37069

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion airflow/providers/google/cloud/operators/dataflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,9 @@ def set_current_job(current_job):
options = self.dataflow_default_options
options.update(self.options)

if not self.location:
potiuk marked this conversation as resolved.
Show resolved Hide resolved
self.location = DEFAULT_DATAFLOW_LOCATION

self.job = self.hook.start_template_dataflow(
job_name=self.job_name,
variables=options,
Expand Down Expand Up @@ -703,7 +706,7 @@ def set_current_job(current_job):
trigger=TemplateJobStartTrigger(
project_id=self.project_id,
job_id=job_id,
location=self.location if self.location else DEFAULT_DATAFLOW_LOCATION,
location=self.location,
gcp_conn_id=self.gcp_conn_id,
poll_sleep=self.poll_sleep,
impersonation_chain=self.impersonation_chain,
Expand Down
7 changes: 5 additions & 2 deletions tests/providers/google/cloud/operators/test_dataflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
import pytest

import airflow
from airflow.providers.google.cloud.hooks.dataflow import DataflowJobStatus
from airflow.providers.google.cloud.hooks.dataflow import (
DEFAULT_DATAFLOW_LOCATION,
DataflowJobStatus,
)
from airflow.providers.google.cloud.operators.dataflow import (
CheckJobRunning,
DataflowCreateJavaJobOperator,
Expand Down Expand Up @@ -554,7 +557,7 @@ def test_start_with_custom_region(self, dataflow_mock):
assert dataflow_mock.called
_, kwargs = dataflow_mock.call_args_list[0]
assert kwargs["variables"]["region"] == TEST_REGION
assert kwargs["location"] is None
assert kwargs["location"] == DEFAULT_DATAFLOW_LOCATION

@pytest.mark.db_test
@mock.patch("airflow.providers.google.cloud.operators.dataflow.DataflowHook.start_template_dataflow")
Expand Down
Loading