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 side-effect of default options in Beam Operators #37916

Merged
merged 1 commit into from
Mar 5, 2024
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
3 changes: 2 additions & 1 deletion airflow/providers/apache/beam/operators/beam.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ def __init__(
self.py_interpreter = py_interpreter
self.py_requirements = py_requirements
self.py_system_site_packages = py_system_site_packages
self.pipeline_options = copy.deepcopy(self.pipeline_options)
self.pipeline_options.setdefault("labels", {}).update(
{"airflow-version": "v" + version.replace(".", "-").replace("+", "-")}
)
Expand Down Expand Up @@ -740,7 +741,7 @@ def __init__(
self.go_file = go_file
self.launcher_binary = launcher_binary
self.worker_binary = worker_binary or launcher_binary

self.pipeline_options = copy.deepcopy(self.pipeline_options)
self.pipeline_options.setdefault("labels", {}).update(
{"airflow-version": "v" + version.replace(".", "-").replace("+", "-")}
)
Expand Down
5 changes: 3 additions & 2 deletions tests/providers/apache/beam/operators/test_beam.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"output": "gs://test/output",
"labels": {"foo": "bar", "airflow-version": TEST_VERSION},
}

TEST_IMPERSONATION_ACCOUNT = "[email protected]"
BEAM_OPERATOR_PATH = "airflow.providers.apache.beam.operators.beam.{}"

Expand Down Expand Up @@ -286,7 +287,7 @@ def test_exec_dataflow_runner(self, gcs_hook, dataflow_hook_mock, beam_hook_mock
"jobName": job_name,
"stagingLocation": "gs://test/staging",
"region": "us-central1",
"labels": {"foo": "bar", "airflow-version": TEST_VERSION},
"labels": {"foo": "bar"},
Taragolis marked this conversation as resolved.
Show resolved Hide resolved
"output": "gs://test/output",
"impersonateServiceAccount": TEST_IMPERSONATION_ACCOUNT,
}
Expand Down Expand Up @@ -926,7 +927,7 @@ def test_exec_dataflow_runner(self, gcs_hook, dataflow_hook_mock, beam_hook_mock
"job_name": job_name,
"staging_location": "gs://test/staging",
"output": "gs://test/output",
"labels": {"foo": "bar", "airflow-version": TEST_VERSION},
"labels": {"foo": "bar"},
"region": "us-central1",
"impersonate_service_account": TEST_IMPERSONATION_ACCOUNT,
}
Expand Down