Skip to content
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
11 changes: 10 additions & 1 deletion sdks/python/apache_beam/io/requestresponse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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')

Expand Down Expand Up @@ -689,6 +693,11 @@ 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)
Expand Down
2 changes: 1 addition & 1 deletion sdks/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions sdks/python/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"

Expand Down
Loading