tfx icon indicating copy to clipboard operation
tfx copied to clipboard

ImportError: cannot import name 'shared' from 'tfx_bsl.beam'

Open youquzhiji opened this issue 3 years ago • 2 comments

System information

  • Have I specified the code to reproduce the issue (Yes, No): Yes
  • Environment in which the code is executed: Windows 10, Interactive Notebook, Google Cloud, etc): None
  • TensorFlow version: 2.7.1
  • TFX Version: 1.5.0
  • tfx-bsl Version: 1.5.0
  • Python version: 3.8.10
Python dependencies (from `pip freeze` output)
absl-py==0.12.0
apache-beam==2.37.0
argon2-cffi==21.3.0
argon2-cffi-bindings==21.2.0
astunparse==1.6.3
attrs==20.3.0
backcall==0.2.0
beautifulsoup4==4.10.0
bleach==4.1.0
cachetools==4.2.4
certifi==2021.10.8
cffi==1.15.0
charset-normalizer==2.0.12
click==7.1.2
cloudpickle==2.0.0
colorama==0.4.4
crcmod==1.7
cycler==0.11.0
debugpy==1.5.1
decorator==5.1.1
defusedxml==0.7.1
dill==0.3.1.1
docker==4.4.4
docopt==0.6.2
entrypoints==0.4
fastavro==1.4.10
fasteners==0.17.3
flatbuffers==2.0
fonttools==4.30.0
gast==0.4.0
google-api-core==1.31.5
google-api-python-client==1.12.10
google-apitools==0.5.31
google-auth==1.35.0
google-auth-httplib2==0.1.0
google-auth-oauthlib==0.4.6
google-cloud-aiplatform==1.11.0
google-cloud-bigquery==2.34.2
google-cloud-bigquery-storage==2.13.0
google-cloud-bigtable==1.7.0
google-cloud-core==1.7.2
google-cloud-datastore==1.15.3
google-cloud-dlp==3.6.2
google-cloud-language==1.3.0
google-cloud-pubsub==2.11.0
google-cloud-pubsublite==1.4.1
google-cloud-recommendations-ai==0.2.0
google-cloud-spanner==1.19.1
google-cloud-storage==2.1.0
google-cloud-videointelligence==1.16.1
google-cloud-vision==1.0.0
google-crc32c==1.3.0
google-pasta==0.2.0
google-resumable-media==2.3.2
googleapis-common-protos==1.55.0
grpc-google-iam-v1==0.12.3
grpcio==1.44.0
grpcio-gcp==0.2.2
grpcio-status==1.44.0
h5py==3.6.0
hdfs==2.6.0
httplib2==0.19.1
idna==3.3
importlib-metadata==4.11.2
ipykernel==6.9.1
ipython==7.32.0
ipython-genutils==0.2.0
ipywidgets==7.6.5
jedi==0.18.1
Jinja2==2.11.3
joblib==0.14.1
jsonschema==3.2.0
jupyter-client==7.1.2
jupyter-core==4.9.2
jupyterlab-pygments==0.1.2
jupyterlab-widgets==1.0.2
keras==2.7.0
Keras-Preprocessing==1.1.2
keras-tuner==1.1.0
kiwisolver==1.3.2
kt-legacy==1.0.4
kubernetes==12.0.1
libclang==13.0.0
Markdown==3.3.6
MarkupSafe==2.1.0
matplotlib==3.5.1
matplotlib-inline==0.1.3
mistune==0.8.4
ml-metadata==1.5.0
ml-pipelines-sdk==1.5.0
model-card-toolkit==1.3.0
nbclient==0.5.13
nbconvert==6.4.4
nbformat==5.2.0
nest-asyncio==1.5.4
notebook==6.4.8
numpy==1.19.5
oauth2client==4.1.3
oauthlib==3.2.0
opt-einsum==3.3.0
orjson==3.6.7
overrides==6.1.0
packaging==20.9
pandas==1.4.1
pandocfilters==1.5.0
parso==0.8.3
pickleshare==0.7.5
Pillow==9.0.1
portpicker==1.5.0
prometheus-client==0.13.1
prompt-toolkit==3.0.28
proto-plus==1.20.3
protobuf==3.19.4
psutil==5.9.0
pyarrow==2.0.0
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycparser==2.21
pydot==1.4.2
Pygments==2.11.2
pymongo==3.12.3
pyparsing==2.4.7
pyrsistent==0.18.1
python-dateutil==2.8.2
pytz==2021.3
pywin32==227
pywinpty==2.0.5
PyYAML==5.4.1
pyzmq==22.3.0
requests==2.27.1
requests-oauthlib==1.3.1
rsa==4.8
scipy==1.8.0
semantic-version==2.9.0
Send2Trash==1.8.0
six==1.16.0
soupsieve==2.3.1
tensorboard==2.8.0
tensorboard-data-server==0.6.1
tensorboard-plugin-wit==1.8.1
tensorflow==2.7.1
tensorflow-data-validation==1.5.0
tensorflow-estimator==2.7.0
tensorflow-hub==0.12.0
tensorflow-io-gcs-filesystem==0.24.0
tensorflow-metadata==1.5.0
tensorflow-model-analysis==0.36.0
tensorflow-serving-api==2.7.0
tensorflow-transform==1.5.0
termcolor==1.1.0
terminado==0.13.3
testpath==0.6.0
tfx==1.5.0
tfx-bsl==1.5.0
tornado==6.1
traitlets==5.1.1
typing-extensions==4.1.1
typing-utils==0.1.0
uritemplate==3.0.1
urllib3==1.26.8
wcwidth==0.2.5
webencodings==0.5.1
websocket-client==1.3.1
Werkzeug==2.0.3
widgetsnbextension==3.5.2
wrapt==1.14.0
zipp==3.7.0

Describe the current behavior

Cannot import from tfx.components import CsvExampleGen

Traceback (most recent call last):
  File "C:/Workspace/EECS Research/Python38/model-card-toolkit-mlmd.py", line 4, in <module>
    from tfx.components import CsvExampleGen
  File "C:\Users\luigi\AppData\Local\Programs\Python\Python38\lib\site-packages\tfx\components\__init__.py", line 30, in <module>
    from tfx.components.transform.component import Transform
  File "C:\Users\luigi\AppData\Local\Programs\Python\Python38\lib\site-packages\tfx\components\transform\component.py", line 23, in <module>
    from tfx.components.transform import executor
  File "C:\Users\luigi\AppData\Local\Programs\Python\Python38\lib\site-packages\tfx\components\transform\executor.py", line 28, in <module>
    import tensorflow_transform.beam as tft_beam
  File "C:\Users\luigi\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow_transform\beam\__init__.py", line 23, in <module>
    from tensorflow_transform.beam.impl import AnalyzeAndTransformDataset
  File "C:\Users\luigi\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow_transform\beam\impl.py", line 109, in <module>
    from tfx_bsl.beam import shared
ImportError: cannot import name 'shared' from 'tfx_bsl.beam' (C:\Users\luigi\AppData\Local\Programs\Python\Python38\lib\site-packages\tfx_bsl\beam\__init__.py)

Describe the expected behavior

Import without issues

Standalone code to reproduce the issue

import tensorflow as tf
import tfx
from tfx.components import CsvExampleGen

if __name__ == '__main__':
    pass

youquzhiji avatar Mar 12 '22 19:03 youquzhiji

tfs_bsl.beam.shared was removed in this commit: https://github.com/tensorflow/tfx-bsl/commit/2a6a42c64d12310577806a0a810edb6896bff3fb

youquzhiji avatar Mar 12 '22 19:03 youquzhiji

Could you try 1.6.1?

Sanjay, do you know why 1.5 test didn't catch this?

1025KB avatar Mar 14 '22 07:03 1025KB

Hi @youquzhiji,

Kindly try importing CsvExampleGen using latest version 1.9.1 of TFX and see if this resolves your issue. Thank you.

singhniraj08 avatar Aug 29 '22 17:08 singhniraj08

Closing this due to inactivity. Please take a look into the answers provided above, feel free to reopen and post your comments(if you still have queries on this). Thank you!

singhniraj08 avatar Sep 27 '22 05:09 singhniraj08

Are you satisfied with the resolution of your issue? Yes No

google-ml-butler[bot] avatar Sep 27 '22 05:09 google-ml-butler[bot]