AssertionError from `uff` in example bmode reconstruction example
Traceback (most recent call last):
File "C:\Users\nhl08\code\k-wave-python\examples\bmode_reconstruction_example.py", line 207, in <module>
beamform(channel_data)
File "C:\Users\nhl08\code\k-wave-python\kwave\reconstruction\beamform.py", line 73, in beamform
transform = ShiftedTransform.deserialize(probe.transform.serialize())
File "C:\Users\nhl08\miniconda3\envs\kwave\lib\site-packages\uff\uff_io.py", line 58, in deserialize
assert k in fields, f'Class {cls} does not have property named {k}.'
AssertionError: Class <class 'kwave.reconstruction.shifted_transform.ShiftedTransform'> does not have property named translation.
fresh install of k-wave-python with the example dependencies.
Seems to be caused by the Serializable mechanism in uff. Opened an issue in uff to discuss.
Which version of Python are you running the example with? I was able to reproduce this behavior with python 3.10.6. Can you share the output of python --version with me?
Update: The example does work with python 3.9.13. It would seem uff.py is not compatible with 3.10.x. I will investigate where the break originates.
I am indeed using 3.10.x. Thanks!
Going back to UFF.py I see that I at some point found uff was not compatible with python 3.10 but did not yet address it. I'll let this be my motivation.
The __annotation__ mechanism that uff relies on changed in 3.10
See https://docs.python.org/3/howto/annotations.html for best practices in inspecting __annotations__.
It maybe more maintainable and forward/backward compatible to us something like pydantic to handle serialization/deserialization
We had discussed that when we were developing uff.py. Right now we are working to finish building out testing against k-Wave for this project. I'm always welcome to PRs if you have a suggestion.
Also feel free to drop by the development meeting if you want to discuss further.
I'll try to come this week!
Hi, May I ask if there is any update for python 3.10.x? I also encountered the same issue when using the code on Google Colab and cannot really downgrade the Python version ...
Hi @tonyzzr, overall k-wave-python supports Python 3.10 but uff library does not support it yet. So the example which require uff library will not work with Python 3.10.
As a workaround and depending on your use case, I think it should be possible (example) to change the Python version in Colab. Though you might need to re-install the pre-installed libraries that come with the default Python version in Colab.
Thank you @faridyagubbayli ! Let me try to follow the example to work it around.