From 4036b363a1c638bf89e504a71ed5b546f0de6965 Mon Sep 17 00:00:00 2001 From: Danny Mccormick Date: Mon, 10 Nov 2025 11:26:54 -0500 Subject: [PATCH 1/4] split redis into extra --- sdks/python/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdks/python/setup.py b/sdks/python/setup.py index 074d64ae8921..289433f9ea5b 100644 --- a/sdks/python/setup.py +++ b/sdks/python/setup.py @@ -402,7 +402,6 @@ def get_portability_package_data(): 'protobuf>=3.20.3,<7.0.0.dev0,!=4.0.*,!=4.21.*,!=4.22.0,!=4.23.*,!=4.24.*', # pylint: disable=line-too-long 'python-dateutil>=2.8.0,<3', 'pytz>=2018.3', - 'redis>=5.0.0,<6', 'requests>=2.32.4,<3.0.0', 'sortedcontainers>=2.4.0', 'typing-extensions>=3.7.0', @@ -588,6 +587,7 @@ def get_portability_package_data(): 'torch==2.8.0+cpu', 'transformers>=4.28.0,<4.56.0' ], + 'redis': ['redis>=5.0.0,<6'], 'tft': [ 'tensorflow_transform>=1.14.0,<1.15.0' # tensorflow-transform requires dill, but doesn't set dill as a From f0319b4e7aa58f02774d498831c28e95996a54c6 Mon Sep 17 00:00:00 2001 From: Danny Mccormick Date: Thu, 20 Nov 2025 15:56:57 -0500 Subject: [PATCH 2/4] guard missing imports --- sdks/python/apache_beam/io/requestresponse.py | 10 +++++++++- sdks/python/tox.ini | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/sdks/python/apache_beam/io/requestresponse.py b/sdks/python/apache_beam/io/requestresponse.py index 213a1a3fc7ea..6a4a76e8537b 100644 --- a/sdks/python/apache_beam/io/requestresponse.py +++ b/sdks/python/apache_beam/io/requestresponse.py @@ -35,7 +35,6 @@ from typing import TypeVar from typing import Union -import redis from google.api_core.exceptions import TooManyRequests import apache_beam as beam @@ -46,6 +45,11 @@ from apache_beam.transforms.util import BatchElements from apache_beam.utils import retry +try: + import redis +except ImportError: + redis = None + RequestT = TypeVar('RequestT') ResponseT = TypeVar('ResponseT') @@ -689,6 +693,10 @@ def __init__( self._kwargs = kwargs if kwargs else {} self._source_caller = None + if redis is None: + raise ImportError('Failed to import redis. You can ensure it is ' + 'installed by installing the redis beam extra') + def get_read(self): """get_read returns a PTransform for reading from the cache.""" ensure_coders_exist(self._request_coder) diff --git a/sdks/python/tox.ini b/sdks/python/tox.ini index 7d84ca7a2c62..095c1f1fa3de 100644 --- a/sdks/python/tox.ini +++ b/sdks/python/tox.ini @@ -33,7 +33,7 @@ pip_pre = True # allow apps that support color to use it. passenv=TERM,CLOUDSDK_CONFIG,DOCKER_*,TESTCONTAINERS_*,TC_*,ALLOYDB_PASSWORD # Set [] options for pip installation of apache-beam tarball. -extras = test,dataframe,tfrecord,yaml +extras = test,dataframe,redis,tfrecord,yaml # Don't warn that these commands aren't installed. allowlist_externals = false From c3d185d514c6c8b3c501dc8584b903540c03d948 Mon Sep 17 00:00:00 2001 From: Danny Mccormick Date: Fri, 21 Nov 2025 10:26:01 -0500 Subject: [PATCH 3/4] yapf --- sdks/python/apache_beam/io/requestresponse.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sdks/python/apache_beam/io/requestresponse.py b/sdks/python/apache_beam/io/requestresponse.py index 6a4a76e8537b..e53fa07471af 100644 --- a/sdks/python/apache_beam/io/requestresponse.py +++ b/sdks/python/apache_beam/io/requestresponse.py @@ -694,8 +694,9 @@ def __init__( self._source_caller = None if redis is None: - raise ImportError('Failed to import redis. You can ensure it is ' - 'installed by installing the redis beam extra') + raise ImportError( + 'Failed to import redis. You can ensure it is ' + 'installed by installing the redis beam extra') def get_read(self): """get_read returns a PTransform for reading from the cache.""" From 77bab2e54e5628394a83b5b3ec512d3013641d06 Mon Sep 17 00:00:00 2001 From: Danny McCormick Date: Fri, 21 Nov 2025 16:53:37 -0500 Subject: [PATCH 4/4] Get coverage tasks --- sdks/python/tox.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdks/python/tox.ini b/sdks/python/tox.ini index 095c1f1fa3de..da0932728b20 100644 --- a/sdks/python/tox.ini +++ b/sdks/python/tox.ini @@ -97,7 +97,7 @@ install_command = {envbindir}/python.exe {envbindir}/pip.exe install --retries 1 list_dependencies_command = {envbindir}/python.exe {envbindir}/pip.exe freeze [testenv:py{310,311,312,313}-cloud] -; extras = test,gcp,interactive,dataframe,aws,azure +; extras = test,gcp,interactive,dataframe,aws,azure,redis extras = test,gcp,interactive,dataframe,aws,azure commands = python apache_beam/examples/complete/autocomplete_test.py @@ -173,7 +173,7 @@ setenv = TC_SLEEP_TIME = {env:TC_SLEEP_TIME:1} # NOTE: we could add ml_test to increase the collected code coverage metrics, but it would make the suite slower. -extras = test,gcp,interactive,dataframe,aws +extras = test,gcp,interactive,dataframe,aws,redis commands = bash {toxinidir}/scripts/run_pytest.sh {envname} "{posargs}" "--cov-report=xml --cov=. --cov-append"