-
-
Notifications
You must be signed in to change notification settings - Fork 40
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
PR: Update load_dicom
to accommodate Pydicom 3.0
#503
Conversation
…mio.dcmread" pydicom >= 3.0 does not appear to be compatible with Python < 3.10. "TypeError: unsupported operand type(s) for |: 'type' and 'type'" upon import of pydicom.dicomio
@ccordoba12, I think that the environment cache will need to be cleared so that the Linux pip test for Python 3.10 will pass. |
Ok, then, please change this try:
data = dicomio.read_file(filename, force=True)
except TypeError:
data = dicomio.read_file(filename) to be try:
# For Pydicom 3/Python 3.10+
data = dicomio.dcmread(filename, force=True)
except TypeError:
data = dicomio.dcmread(filename)
except AttributeError:
# For Pydicom 2/Python 3.9-
try:
data = dicomio.read_file(filename, force=True)
except TypeError:
data = dicomio.read_file(filename) That will make that code run for Pydicom greater than and less than 3.0.
Ok, then please skip the test that checks our Pydicom integration for Python versions less than 3.10. And then you can remove the constraint you added to Pydicom. It'd be nice too if you could inform Pydicom and Conda-forge maintainers that it's 3.0 version only supports 3.10+. But that's up to you. |
The requirement is correctly enforced by pip. Otherwise our tests with pip packages for Python 3.8/3.9 would fail with the last change you did in this PR. So, the problem is only present in Conda-forge. And in that case, I think the best we can do is to submit a PR to the Pydicom feedstock to fix the situation. If we do that, this shouldn't be necessary:
|
If we skip Pydicom integration test for Python <3.10, then there is no need catch the |
This is not only a matter of fixing our tests. It also has to do with maintaining Pydicom support for Python 3.8/3.9 and 3.10+ at the same time. We need to do that because 3.9 will reach end-of-life in a year or so (3.8 will become unsupported at the end of October though). |
Yep, you are correct. I misspoke. |
pydicom
to <3.0load_dicom
to accommodate Pydicom 3.0
@ccordoba12, this is ready for review |
|
0f829b8
to
372a774
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One additional suggestion so test_load_dicom_files
works for all our supported Python versions, but only when using pip packages.
Co-authored-by: Carlos Cordoba <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me now, thanks @mrclary!
@meeseeksdev please backport to 3.x |
…e Pydicom 3.0) (#507) Co-authored-by: Ryan Clary <[email protected]>
pydicom
released version 3.0 three weeks ago, resulting in recentspyder-kernels
test failures forspyder_kernels/utils/tests/test_iofuncs.py::test_load_dicom_files
.Unfortunately, this includes breaking changes. In particular,
pydicom.dicomio.read_file
is renamedpydicom.dicomio.dcmread
. Also unfortunate,pydicom
does not support Python <3.10. Also unfortunate, this requirement is neither enforced bypip
norconda
for some reason, i.e.pydicom
3.0.1 is installed into Python <3.10 environments.load_dicom
to accommodate only two configurationstest_load_dicom_files
if Python <3.10, since CI will install Pydicom >=3