[Python] Solving Version Conflict using Apache beam with ml transforms library

Discussão em 'Python' iniciado por Stack, Junho 19, 2025.

  1. Stack

    Stack Membro Participativo

    I've been trying for a some time to got a beam pipeline to do data transformations for a fairly simple machine learning transformation, but apache beam and Tensorflow-transform won't play nicely together. I've pulled a requirements lists from the tensorflow-transform Compatibility Matrix to ensure versions of the platforms are installed that work nicely together, but I still get a recursion error at the importing stage. I've attempted to use vertex-ai workbench, as well as locally. I'm using Python 3.10.18.

    import apache_beam as beam
    from apache_beam.ml.transforms.base import MLTransform
    #from apache_beam.ml.transforms.tft import ComputeAndApplyVocabulary
    #from apache_beam.ml.transforms.tft import ScaleTo01
    from apache_beam.ml.transforms.tft import ScaleByMinMax
    #from apache_beam.ml.transforms.tft import ScaleToZScore

    import numpy as np


    RecursionError Traceback (most recent call last)
    Cell In[56], line 5
    2 from apache_beam.ml.transforms.base import MLTransform
    3 #from apache_beam.ml.transforms.tft import ComputeAndApplyVocabulary
    4 #from apache_beam.ml.transforms.tft import ScaleTo01
    ----> 5 from apache_beam.ml.transforms.tft import ScaleByMinMax
    6 #from apache_beam.ml.transforms.tft import ScaleToZScore
    8 import numpy as np

    File /opt/conda/envs/tensorflow/lib/python3.10/site-packages/apache_beam/ml/transforms/tft.py:47
    45 import apache_beam as beam
    46 import tensorflow as tf
    ---> 47 import tensorflow_transform as tft
    48 from apache_beam.ml.transforms.base import BaseOperation
    49 from tensorflow_transform import common_types

    File /opt/conda/envs/tensorflow/lib/python3.10/site-packages/tensorflow_transform/__init__.py:21
    19 from tensorflow_transform.analyzers import *
    20 from tensorflow_transform.annotators import *
    ---> 21 from tensorflow_transform.inspect_preprocessing_fn import *
    22 from tensorflow_transform.mappers import *
    23 from tensorflow_transform.output_wrapper import TFTransformOutput

    File /opt/conda/envs/tensorflow/lib/python3.10/site-packages/tensorflow_transform/inspect_preprocessing_fn.py:23
    21 from tensorflow_transform import common_types
    22 from tensorflow_transform import graph_tools
    ---> 23 from tensorflow_transform import impl_helper
    24 from tensorflow_transform import nodes
    25 from tensorflow_transform import tf2_utils

    File /opt/conda/envs/tensorflow/lib/python3.10/site-packages/tensorflow_transform/impl_helper.py:33
    31 from tensorflow_transform import tf2_utils
    32 from tensorflow_transform import tf_utils
    ---> 33 from tensorflow_transform.output_wrapper import TFTransformOutput
    34 from tensorflow_transform.saved import saved_transform_io
    35 from tensorflow_transform.saved import saved_transform_io_v2

    File /opt/conda/envs/tensorflow/lib/python3.10/site-packages/tensorflow_transform/output_wrapper.py:61
    57 def pop(self, key, default=None): # pylint: disable=useless-super-delegation
    58 return super().pop(key, default)
    ---> 61 class TFTransformOutput:
    62 """A wrapper around the output of the tf.Transform."""
    64 # Locations relative to the base output directory, where outputs of
    65 # tf.Transform should be written in order to be read by TFTransformOutput.
    66 # WriteTransformFn will follow these conventions.

    File /opt/conda/envs/tensorflow/lib/python3.10/site-packages/tensorflow_transform/output_wrapper.py:263, in TFTransformOutput()
    259 raise ValueError('Column {} has min value {}, should be 0'.format(
    260 name, domain.min))
    261 return domain.max + 1
    --> 263 def transform_features_layer(self) -> tf_keras.Model:
    264 """Creates a `TransformFeaturesLayer` from this transform output.
    265
    266 If a `TransformFeaturesLayer` has already been created for self, the same
    (...)
    270 A `TransformFeaturesLayer` instance.
    271 """
    272 if self._transform_features_layer is None:

    File /opt/conda/envs/tensorflow/lib/python3.10/site-packages/tensorflow/python/util/lazy_loader.py:182, in KerasLazyLoader.__getattr__(self, item)
    180 if not self._tfll_initialized:
    181 self._initialize()
    --> 182 if self._tfll_keras_version == "keras_3":
    183 if (
    184 self._tfll_mode == "v1"
    185 and not self._tfll_submodule
    186 and item.startswith("compat.v1.")
    187 ):
    188 raise AttributeError(
    189 "`tf.compat.v1.keras` is not available with Keras 3. Keras 3 has "
    190 "no support for TF 1 APIs. You can install the `tf_keras` package "
    (...)
    193 "`tf.compat.v1.keras` to `tf_keras`."
    194 )

    File /opt/conda/envs/tensorflow/lib/python3.10/site-packages/tensorflow/python/util/lazy_loader.py:182, in KerasLazyLoader.__getattr__(self, item)
    180 if not self._tfll_initialized:
    181 self._initialize()
    --> 182 if self._tfll_keras_version == "keras_3":
    183 if (
    184 self._tfll_mode == "v1"
    185 and not self._tfll_submodule
    186 and item.startswith("compat.v1.")
    187 ):
    188 raise AttributeError(
    189 "`tf.compat.v1.keras` is not available with Keras 3. Keras 3 has "
    190 "no support for TF 1 APIs. You can install the `tf_keras` package "
    (...)
    193 "`tf.compat.v1.keras` to `tf_keras`."
    194 )

    [... skipping similar frames: KerasLazyLoader.__getattr__ at line 182 (2928 times)]

    File /opt/conda/envs/tensorflow/lib/python3.10/site-packages/tensorflow/python/util/lazy_loader.py:182, in KerasLazyLoader.__getattr__(self, item)
    180 if not self._tfll_initialized:
    181 self._initialize()
    --> 182 if self._tfll_keras_version == "keras_3":
    183 if (
    184 self._tfll_mode == "v1"
    185 and not self._tfll_submodule
    186 and item.startswith("compat.v1.")
    187 ):
    188 raise AttributeError(
    189 "`tf.compat.v1.keras` is not available with Keras 3. Keras 3 has "
    190 "no support for TF 1 APIs. You can install the `tf_keras` package "
    (...)
    193 "`tf.compat.v1.keras` to `tf_keras`."
    194 )

    File /opt/conda/envs/tensorflow/lib/python3.10/site-packages/tensorflow/python/util/lazy_loader.py:178, in KerasLazyLoader.__getattr__(self, item)
    177 def __getattr__(self, item):
    --> 178 if item in ("_tfll_mode", "_tfll_initialized", "_tfll_name"):
    179 return super(types.ModuleType, self).__getattribute__(item)
    180 if not self._tfll_initialized:

    RecursionError: maximum recursion depth exceeded in comparison


    pip list:

    Package Version
    ------------------------------------- -----------
    absl-py 1.4.0
    annotated-types 0.7.0
    anyio 4.9.0
    apache-beam 2.60.0
    astunparse 1.6.3
    async-timeout 5.0.1
    attrs 25.3.0
    backports.tarfile 1.2.0
    cachetools 5.5.2
    certifi 2025.6.15
    cffi 1.17.1
    charset-normalizer 3.4.2
    cloudpickle 2.2.1
    crcmod 1.7
    cryptography 45.0.4
    dill 0.3.1.1
    dnspython 2.7.0
    docopt 0.6.2
    docstring_parser 0.16
    exceptiongroup 1.3.0
    fastavro 1.11.1
    fasteners 0.19
    flatbuffers 25.2.10
    gast 0.6.0
    google-api-core 2.25.1
    google-api-python-client 1.12.11
    google-apitools 0.5.31
    google-auth 2.40.3
    google-auth-httplib2 0.2.0
    google-cloud-aiplatform 1.97.0
    google-cloud-bigquery 3.34.0
    google-cloud-bigquery-storage 2.32.0
    google-cloud-bigtable 2.31.0
    google-cloud-core 2.4.3
    google-cloud-datastore 2.21.0
    google-cloud-dlp 3.30.0
    google-cloud-language 2.17.2
    google-cloud-pubsub 2.30.0
    google-cloud-pubsublite 1.12.0
    google-cloud-recommendations-ai 0.10.18
    google-cloud-resource-manager 1.14.2
    google-cloud-spanner 3.55.0
    google-cloud-storage 2.19.0
    google-cloud-videointelligence 2.16.2
    google-cloud-vision 3.10.2
    google-crc32c 1.7.1
    google-genai 1.21.1
    google-pasta 0.2.0
    google-resumable-media 2.7.2
    googleapis-common-protos 1.70.0
    grpc-google-iam-v1 0.14.2
    grpc-interceptor 0.15.4
    grpcio 1.65.5
    grpcio-status 1.49.0rc1
    h11 0.16.0
    h5py 3.14.0
    hdfs 2.7.3
    httpcore 1.0.9
    httplib2 0.22.0
    httpx 0.28.1
    idna 3.10
    importlib_metadata 8.7.0
    jaraco.classes 3.4.0
    jaraco.context 6.0.1
    jaraco.functools 4.1.0
    jeepney 0.9.0
    jsonpickle 3.4.2
    jsonschema 4.24.0
    jsonschema-specifications 2025.4.1
    keras 3.10.0
    keyring 25.6.0
    keyrings.google-artifactregistry-auth 1.1.2
    libclang 18.1.1
    Markdown 3.8.2
    markdown-it-py 3.0.0
    MarkupSafe 3.0.2
    mdurl 0.1.2
    ml-dtypes 0.3.2
    more-itertools 10.7.0
    namex 0.1.0
    numpy 1.26.4
    oauth2client 4.1.3
    objsize 0.7.1
    opentelemetry-api 1.34.1
    opentelemetry-sdk 1.34.1
    opentelemetry-semantic-conventions 0.55b1
    opt_einsum 3.4.0
    optree 0.16.0
    orjson 3.10.18
    overrides 7.7.0
    packaging 25.0
    pandas 1.5.3
    pip 25.1.1
    pluggy 1.6.0
    proto-plus 1.26.1
    protobuf 3.20.3
    pyarrow 10.0.1
    pyarrow-hotfix 0.7
    pyasn1 0.6.1
    pyasn1_modules 0.4.2
    pycparser 2.22
    pydantic 2.11.7
    pydantic_core 2.33.2
    pydot 1.4.2
    Pygments 2.19.1
    PyJWT 2.9.0
    pymongo 4.13.2
    pyparsing 3.2.3
    python-dateutil 2.9.0.post0
    pytz 2025.2
    redis 5.3.0
    referencing 0.36.2
    regex 2024.11.6
    requests 2.32.4
    rich 14.0.0
    rpds-py 0.25.1
    rsa 4.9.1
    SecretStorage 3.3.3
    setuptools 80.9.0
    shapely 2.1.1
    six 1.17.0
    sniffio 1.3.1
    sqlparse 0.5.3
    tenacity 8.5.0
    tensorboard 2.16.2
    tensorboard-data-server 0.7.2
    tensorflow 2.16.1
    tensorflow-io-gcs-filesystem 0.37.1
    tensorflow-metadata 1.16.1
    tensorflow-serving-api 2.16.1
    tensorflow-transform 1.16.0
    termcolor 3.1.0
    tf_keras 2.16.0
    tfx-bsl 1.16.1
    typing_extensions 4.14.0
    typing-inspection 0.4.1
    uritemplate 3.0.1
    urllib3 2.5.0
    websockets 15.0.1
    Werkzeug 3.1.3
    wheel 0.45.1
    wrapt 1.17.2
    zipp 3.23.0
    zstandard 0.23.0

    Continue reading...

Compartilhe esta Página