From d824065b7913d2b5912d0bf2aeb6338e0108444c Mon Sep 17 00:00:00 2001 From: Shunping Huang Date: Tue, 14 Jul 2026 15:28:09 -0400 Subject: [PATCH 1/2] Fix test_get_python_sdk_name to use supported Python version Update sys.version_info mock from 3.9 to 3.11 in test_get_python_sdk_name and format version check error message using sys.version_info for consistency. --- .../python/apache_beam/runners/dataflow/internal/apiclient.py | 4 ++-- .../apache_beam/runners/dataflow/internal/apiclient_test.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sdks/python/apache_beam/runners/dataflow/internal/apiclient.py b/sdks/python/apache_beam/runners/dataflow/internal/apiclient.py index 4755aea0bc2c..2a9307a1f110 100644 --- a/sdks/python/apache_beam/runners/dataflow/internal/apiclient.py +++ b/sdks/python/apache_beam/runners/dataflow/internal/apiclient.py @@ -1262,8 +1262,8 @@ def _verify_interpreter_version_is_supported(pipeline_options): return raise Exception( - 'Dataflow runner currently supports Python versions %s, got %s.\n' + 'Dataflow runner currently supports Python versions %s, got %s.%s.\n' 'To ignore this requirement and start a job ' 'using an unsupported version of Python interpreter, pass ' '--experiment use_unsupported_python_version pipeline option.' % - (_PYTHON_VERSIONS_SUPPORTED_BY_DATAFLOW, sys.version)) + (_PYTHON_VERSIONS_SUPPORTED_BY_DATAFLOW, sys.version_info[0], sys.version_info[1])) diff --git a/sdks/python/apache_beam/runners/dataflow/internal/apiclient_test.py b/sdks/python/apache_beam/runners/dataflow/internal/apiclient_test.py index 12c51d305145..e8f760fc29a2 100644 --- a/sdks/python/apache_beam/runners/dataflow/internal/apiclient_test.py +++ b/sdks/python/apache_beam/runners/dataflow/internal/apiclient_test.py @@ -1032,7 +1032,7 @@ def test_experiment_use_multiple_sdk_containers(self): @mock.patch( 'apache_beam.runners.dataflow.internal.apiclient.sys.version_info', - (3, 9)) + (3, 11)) def test_get_python_sdk_name(self): pipeline_options = PipelineOptions([ '--project', @@ -1051,7 +1051,7 @@ def test_get_python_sdk_name(self): '1', FAKE_PIPELINE_URL) self.assertEqual( - 'Apache Beam Python 3.9 SDK', environment._get_python_sdk_name()) + 'Apache Beam Python 3.11 SDK', environment._get_python_sdk_name()) @mock.patch( 'apache_beam.runners.dataflow.internal.apiclient.sys.version_info', From 27071755dddcfe5388a371ce11687eeb47e43118 Mon Sep 17 00:00:00 2001 From: Shunping Huang Date: Tue, 14 Jul 2026 15:40:49 -0400 Subject: [PATCH 2/2] Add a note and reformat --- .../apache_beam/runners/dataflow/internal/apiclient.py | 6 ++++-- .../apache_beam/runners/dataflow/internal/apiclient_test.py | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/sdks/python/apache_beam/runners/dataflow/internal/apiclient.py b/sdks/python/apache_beam/runners/dataflow/internal/apiclient.py index 2a9307a1f110..ac4118643109 100644 --- a/sdks/python/apache_beam/runners/dataflow/internal/apiclient.py +++ b/sdks/python/apache_beam/runners/dataflow/internal/apiclient.py @@ -1265,5 +1265,7 @@ def _verify_interpreter_version_is_supported(pipeline_options): 'Dataflow runner currently supports Python versions %s, got %s.%s.\n' 'To ignore this requirement and start a job ' 'using an unsupported version of Python interpreter, pass ' - '--experiment use_unsupported_python_version pipeline option.' % - (_PYTHON_VERSIONS_SUPPORTED_BY_DATAFLOW, sys.version_info[0], sys.version_info[1])) + '--experiment use_unsupported_python_version pipeline option.' % ( + _PYTHON_VERSIONS_SUPPORTED_BY_DATAFLOW, + sys.version_info[0], + sys.version_info[1])) diff --git a/sdks/python/apache_beam/runners/dataflow/internal/apiclient_test.py b/sdks/python/apache_beam/runners/dataflow/internal/apiclient_test.py index e8f760fc29a2..dc55a28cecf4 100644 --- a/sdks/python/apache_beam/runners/dataflow/internal/apiclient_test.py +++ b/sdks/python/apache_beam/runners/dataflow/internal/apiclient_test.py @@ -1030,6 +1030,9 @@ def test_experiment_use_multiple_sdk_containers(self): self.assertNotIn( 'use_multiple_sdk_containers', environment.proto.experiments) + # Note: We mock Python to 3.11 here. Keep this mocked version aligned with a + # version in _PYTHON_VERSIONS_SUPPORTED_BY_DATAFLOW to prevent test failures + # on release (non-dev) builds. @mock.patch( 'apache_beam.runners.dataflow.internal.apiclient.sys.version_info', (3, 11))