-
-
Notifications
You must be signed in to change notification settings - Fork 149
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
chore: Dependency Maintenance (imageio 2->3, pyBIDS<0.15.6, readthedocs.yml v2, Python 3.7->3.8) #1297
Conversation
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.
Thanks @kanishk16 for addressing this. Looks like a bunch of tests are now passing
…1298) GHA stopped support for Ubuntu-18.04 LTS quite some time back. Since it is part of the requisite matrix test to merge a PR, it blocks #1296 and #1297. Moreover, removing python 3.7 as it reached EOL on 27 June 2023 (https://endoflife.date/python) and primarily to reduce GHA workflow quota for future runs. Partly unblocks #1296 and #1297
@hermancollin Though most tests pass, I'd like you to test & verify as in #1296. Also, it would be great if you could check the inference too. @dyt811 Since windows tests aren't passing for some time (unrelated to the current PR) and are required before merging, could you remove the windows tests from the required statuses - Python 3.8 and Ubuntu-18.04, Python 3.8 (#1298) to unblock this PR? |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as outdated.
This comment was marked as outdated.
Ubuntu-18.04, Python 3.8 (#1298) required check also needs to be removed as GitHub Actions stopped the support for Ubuntu-18.04 LTS quite some time back. |
This comment was marked as resolved.
This comment was marked as resolved.
Or we could look into how to resolve the one test that's failing in Windows - has someone looked at it yet / is there an issue/PR? Because all the other tests pass in windows, and it would be a shame to stop testing on windows just for this edge case. |
This comment was marked as resolved.
This comment was marked as resolved.
I think I resolved the bug - essentially pybids changed how they parse regex over the winter, and at some point it started breaking for Windows. Restricting pybids to <15.6.0 resolved the failing test in the draft PR I setup: #1299, see: https://github.com/ivadomed/ivadomed/actions/runs/5467608625/jobs/9954141022 Let me make the change here, and if they all pass, I'll reintroduce the required windows checks and we can move ahead. @hermancollin were you intending on reviewing this PR too? |
Resolves windows bug, see #1299
This comment was marked as resolved.
This comment was marked as resolved.
@mathieuboudreau I'm not in favor of restricting pybids for a windows test as:
Dependency pinning is much more complex than it seems - for detailed discussions #1191 |
@joshuacwnewton after reviewing this thread, I think it may be ready to merge as-is, but requires an admin to force-merge due to the failing windows tests (unrelated to this PR - #1297 (comment)). The last comment in this thread was made by me, expressing some concern for (seemingly arbitrary) hardcoded values that were coded to convert RGBA to greyscale, now that we couldn't use However, I dug a little bit into the old imageio and pillow codebases, and it appears that as_gray used these same hardcoded values (though using an int16 integer set) to do this conversion (https://github.com/python-pillow/Pillow/blob/b723e9e62e4706a85f7e44cb42b3d838dae5e546/src/PIL/ImageColor.py#L152), so all is well here and I'm not satisfied with knowing that there appears to be consistency between how RGBA was converted to grayscale before to now. So, either you can do re-review if you'd like for your own purposes, or you or I can force-merge this PR now! |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
FYI @mathieuboudreau the "random" numbers used in RGB to grayscale conversion go back to Recommendation BT.601-7, which is a document on standardizing colors for television and was first published in the 80s. In the linked document you will find said formula in Annex 2 (page 15, equation 1). The annex describes how to convert sRGB into YCrCb, and the equation everybody uses is this conversion's Y (luminance) component. The numbers aren't uniform because the human eye has different sensitivity to each of the primary colors and choosing them this way is "true to human perception". From there we get RGBA to grayscale by effectively ignoring the alpha component. There is only one image, so no blending is happening, and subsequently alpha doesn't change the result. |
Wow, thank you so much for clarifying where these came from @FirefoxMetzger! My background is in physics and not CS, so this is not something I would have encountered previously :) |
followed by revision based on code review
Thank you @FirefoxMetzger, for the insightful discussion, reviews, and helpful suggestions. BTW, this bug helped me explore imageio extensively and v3 simplifies a lot of the internal stuff making it easier to dive into the codebase. |
I'll try to summarize the essence of the changes. imageio provides a unified interface to read and write a wide range of image data from many 3 rd party libs.
imageio core comprises user-facing APIs and a plugin manager. A plugin manager intelligently configures a plugin (an adapter cum wrapper to backend library, a potential 3rd party lib that responds to a request from imageio.core handling installs and imports related cases) either by searching for a specific plugin as per the priority mentioned in the docs or by sending the request to the plugin you specified explicitly. Now, you send requests to imageio.core through the user-facing API that relays it to the plugin manager, which selects a plugin from a set of plugins to determine which backend to fulfill your request. Previously, using imageio v2: if "tif" in extension:
img = np.expand_dims(imageio.v2.imread(filename, format='tiff-pil'), axis=-1).astype(np.uint8)
if len(img.shape) > 3:
img = np.expand_dims(imageio.v2.imread(filename, format='tiff-pil', as_gray=True), axis=-1).astype(np.uint8)
else:
img = np.expand_dims(imageio.v2.imread(filename, as_gray=True), axis=-1).astype(np.uint8)
The change from v2 to v3 (
So, the recent commit migrates from v2 to v3, while preserving the same plugin and backend libs as before with v2: if '.tif' in extension:
img = np.expand_dims(imageio.v3.imread(filename, plugin='TIFF-PIL'), axis=-1).astype(np.unint8)
if len(img.shape) > 3:
img = np.expand_dims(imageio.v3.imread(filename, plugin='TIFF-PIL', as_gray=True), axis=-1).astype(np.unint8)
else:
img = np.expand_dims(imageio.v3.imread(filename, plugin='PNG-PIL', as_gray=True), axis=-1).astype(np.unint8) So, this handles all the cases whenever a user wants to have the original behaviour (more or less consistent with what @FirefoxMetzger suggested) as well as the case that @hermancollin encountered #1297 (comment). @mathieuboudreau Hopefully, this clarifies the commit. Let me know if you have any other suggestions. |
This comment was marked as resolved.
This comment was marked as resolved.
This commit hits two birds with one stone: Not only do we fix the failing Windows tests (reported back in July 2023), but we also fix the more recent cross-platform bugs (which have yet to be fully investigated).
The Windows tests are passing again, so we can reinstate the requirement.
- Adds missing "build" section containing OS and Python version - Upgrade Python version from 3.7/3.8 tp 3.10 (my reasoning here is that we already test ivadomed against v3.10, so for the docs specifically, this saves us from having to make more maintenance changes soon in the future)
Hi folks! I'm finally back to help get this PR merged. 🎉 I've updated the title and description of this PR, as well as hidden some conversations that have since been resolved, to help make this PR a little easier to parse. In reviewing the most recent updates to this PR (1424f61, Oct 2, 2023), I noticed new test failures stemming from an entirely different PyBIDS-related bug: # Filter dataframe to keep subjects files with available derivatives only
if has_deriv:
self.df = self.df[self.df['filename'].str.contains('|'.join(has_deriv))
| self.df['filename'].str.contains('|'.join(deriv))]
else:
# Raise error and exit if no derivatives are found for any subject files
> raise RuntimeError("Derivatives not found.")
E RuntimeError: Derivatives not found. This seems to be due to a newer version of PyBIDS, as pinning PyBIDS to an older version fixes this error. We could spend time debugging this new issue and update If we truly need to unpin PyBIDS in the future (e.g. for a dependent project), we can always revisit how we want to update the ivadomed-specific code in the future. But, I think pinning is a good short-term patch, given that ivadomed as a whole is in maintenance mode. I've also added some new changes to the |
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.
This has my approval, but it seems wise to have one other ivadomed member review my proposed changes re: Pillow/PyBIDS. :)
I'd like to drop it here to document the little debugging done to pursue this bug previously (also raised in #1305 a few weeks back). This bug originates from the pybids 0.16.2 release. Although the debugging wasn't conclusive enough to raise a patch PR, a hacky fix was to set the
I was not in favour of pinning pybids then as discussed earlier as at that time we were still transitioning to maintenance mode (primarily with respect to ADS) but given the time since then, I don't have any strong opinion about pinning as a short-term patch. Moreover, afaik ADS has transitioned to monai from training models to benchmarking metrics (surpassing the ivadomed benchmarks).
@joshuacwnewton Thanks for your help. LGTM and feel free to merge (but since I opened the PR I can't officially approve xD). |
Thank you for adding the additional context! I'm glad we have an issue open for further debugging the PyBIDS issues later on if need be. :) |
Checklist
GitHub
PR contents
Description
This PR combines a number of maintenance changes, updating various dependencies that have evolved since the last release of ivadomed.
1. imageio 2->3
imageio
had planned a pretty user-friendly (slow and steady) transition to v3, imageio/imageio#725, for a year and a half. It is now approaching its stage to bump to v3. We initially made some hotfixes to move to v2, #1181, rather than migrating to v3, considering it to be in its early days - stabilizing & gathering user feedback. But, it appears to have stabilized after a significant number of minor and patch releases, especially in the last 2-3 months (imageio/imageio#982, imageio/imageio#931).Moreover, the recent
imageio
releases raised quite a few issues #1291 that were high-priority concerns originating from axondeepseg/axondeepseg#738 and axondeepseg/axondeepseg#737. There were attempts to hotfix with #1292 and #1296, but the tests were still broken. Sinceimageio.v3
appears much more stable, this PR attempts to streamline and resolve the above issues by migrating toimageio.v3
.Further details about the migration itself can be found in this comment: #1297 (comment)
2. pyBIDS<0.15.6
In recent months, pyBIDS has introduced some backwards incompatible changes that break our tests in multiple ways: #1297 (comment), #1297 (comment).
We could update
ivadomed
to be compatible with the newest PyBIDS, however in the short term it's simplest just to pin <0.15.6. 0.15.5 was released in November 2022 and its wheel is not limited to specific versions of Python 3, so there should be no forwards-compatibility issues.3. Pillow <10.0.0
Pillow 10.0.0 is incompatible with the outdated version of
tensorboard
we use. This fix will be unnecessary once we updatetorch
in #1304.See: #1297 (comment)
4. readthedocs.yml v2
See: https://blog.readthedocs.com/migrate-configuration-v2/
5. Python 3.7->3.8
Python 3.7 has reached EOL, so it needed to be updated in our tests workflow as well as the readthedocs workflow.
6. Ubuntu 18.04
Reached EOL.
Linked issues
Resolves #1291