diff --git a/sdks/python/apache_beam/runners/dataflow/internal/apiclient.py b/sdks/python/apache_beam/runners/dataflow/internal/apiclient.py index 4755aea0bc2c..ac4118643109 100644 --- a/sdks/python/apache_beam/runners/dataflow/internal/apiclient.py +++ b/sdks/python/apache_beam/runners/dataflow/internal/apiclient.py @@ -1262,8 +1262,10 @@ 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)) + '--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 12c51d305145..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,9 +1030,12 @@ 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, 9)) + (3, 11)) def test_get_python_sdk_name(self): pipeline_options = PipelineOptions([ '--project', @@ -1051,7 +1054,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',