-
Notifications
You must be signed in to change notification settings - Fork 74.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
typing_extensions >= 4.6.0 causes pip unit test failure #60687
Comments
@elfringham, Could you please confirm whether changes are reflected as mentioned. Thank you! |
The rough cause of error is here. The current getattribute for dictwrapper can return TypeError. When an attribute is not found it's instead expected to return AttributeError. Finding place that produces TypeError and replacing it with AttributeError should fix typing extensions incompatibility. typing 4.6 uses inspect.getattr_static which expects that failed attribute access using getattribute only triggers attribute error. This particular error will also be an error if you try to run tensorflow on python 3.12. The typing extensions change was motivated from here. edit: Minimal version of this error is, from tensorflow.python.trackable.data_structures import _DictWrapper
t = _DictWrapper()
object.__getattribute__(t, "__dict__") The last line raises TypeError. On other hand The error message comes from here. I've cross posted in cpython side as unsure whether this tensorflow bug or cpython bug. |
FYI folks @AlexWaygood over on typing-extensions thinks this is an issue with wrapt, from python/typing_extensions#216 (comment) here's @AlexWaygood's message: Looks to me like it's probably an issue with wrapt rather than typing_extensions or TensorFlow, actually. We discussed this a bit in python/cpython#105134. Wrapt raises TypeError if you do object.getattribute(<some_wrapt_ObjectProxy_instance, 'dict'). I know of no way to construct a class using pure Python that has this behaviour (wrapt achieves this behaviour by using a C extension), and it breaks some fundamental assumptions that the stdlib function inspect.getattr_static makes. That, in turn, breaks typing_extensions. |
This issue is stale because it has been open for 7 days with no activity. It will be closed if no further activity occurs. Thank you. |
This issue is stale because it has been open for 7 days with no activity. It will be closed if no further activity occurs. Thank you. |
This issue is stale because it has been open for 7 days with no activity. It will be closed if no further activity occurs. Thank you. |
A consequence of this is that Tensorflow is not compatible with Pydantic V2 due to the restraints on typing_extensions |
The root issue comes more from wrapt then tensorflow and is this one. I think downgrading wrapt version should be enough to work around this until that issue is closed. Specifically I think only wrapt 1.15 (or maybe 1.14+) causes an issue while tensorflow requirement is >1.11. Add an upper bound and we should be fine. This is not ideal long term fix and that is still resolve wrapt issue (or remove wrapt dependency). Second solution is set |
A change in the behaviour of wrapt ends up in a unit test failure for TensorFlow. This can be removed once mitigation in TensorFlow is in place. tensorflow#60687 and GrahamDumpleton/wrapt#231 This is an alternative and less intrusive fix to tensorflow#60688 which was inadvertently reverted by a mis-merge in another commit.
Is anything being done to loosen the upper bound on typing-extensions here? This continues to cause issues on macOS. I have a Pipfile which includes
|
@tommyzieba You can see from #61387 that there is no longer an upper limit on typing-extensions in git HEAD and that this will be picked up by the next release of TensorFlow which will be 2.14.0. |
Is this issue still active? It looks like it is about to cause an issue for keras-core with the 2.14 release, probably other things affected as well. More directly, with keras out of the picture, I think the minimal repro below will cause failures in the tensorflow 2.14 docker images (which have a more recent
|
Fixes #1753 See also tensorflow/tensorflow#60687 and tensorflow/tensorflow#61387 PiperOrigin-RevId: 572657594
Fixes #1753 See also tensorflow/tensorflow#60687 and tensorflow/tensorflow#61387 PiperOrigin-RevId: 572657594
Click to expand!
Issue Type
Bug
Have you reproduced the bug with TF nightly?
Yes
Source
source
Tensorflow Version
git HEAD
Custom Code
No
OS Platform and Distribution
Ubuntu 20.04
Mobile device
n/a
Python version
3.10
Bazel version
5.3.0
GCC/Compiler version
10.2.1
CUDA/cuDNN version
n/a
GPU model and memory
n/a
Current Behaviour?
//bazel_pip/tensorflow/python/trackable:data_structures_test will fail with typing_extensions >= 4.6.0 installed when run as a pip test against an installed TensorFlow wheel.
Standalone code to reproduce the issue
bazel test --build_tests_only --cache_test_results=no --config=mkl_aarch64_threadpool --copt=-flax-vector-conversions --jobs=75 --test_env=TF_ENABLE_ONEDNN_OPTS=1 --test_env=TF2_BEHAVIOR=1 --define=no_tensorflow_py_deps=true --test_lang_filters=py --test_size_filters=small,medium --test_output=errors --verbose_failures=true //bazel_pip/tensorflow/python/trackable:data_structures_test
Relevant log output
The text was updated successfully, but these errors were encountered: