-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Meta_dict and lazy resampling in apply transform #6595
Comments
Seems we missed passing MONAI/monai/transforms/transform.py Lines 389 to 391 in e6ec945
MONAI/monai/transforms/utils.py Line 1753 in e6ec945
|
Thanks, I can replicate this issue in 1.2.0 (but not 1.2.0rc7), it's introduced by #6537. The root cause is that the API changes to the they are inconsistent with the base class MapTransform MONAI/monai/transforms/transform.py Lines 430 to 445 in e6ec945
@Nic-Ma @ericspod we may have to release 1.2.1 to fix these. Let's discuss this in today's dev meeting. cc @mmodat |
@tangy5 please reach out to me so I can further understand the problem. I'm fresh to this as of the meeting |
@tangy5 let's schedule a quick chat on monday, so we can figure out the best way to resolve it, if you are free. |
Thank you so much. Currently, this is not a blocker issue for other MONAI related platforms such as MONAI Label and MONAI Toolkit, but we'd better discuss whether we will make it compatible with In both cases, it should work. Thank you! I'm available for a chat on Monday if a discussion is needed. |
Please feel free to organize the discussion meeting. Thanks. |
Hi @Nic-Ma I'd like to look for other options as well. It seems to be very restrictive for dictionary based transforms to be forced to only accept one call parameter. It isn't true for non-dictionary transforms, and makes us have to have two different mechanisms for essentially the same piece of functionality. It's almost always better to have one mechanism instead of two where possible. I'm trying to understand why it isn't simply a case of extending |
Signed-off-by: Ben Murray <[email protected]>
I've put together a draft PR #6598 that solves the problem. It might need tweaking, of course. |
Hi @atbenmurray , I think the initial reason for accepting only 1 call parameter in the dict transforms is that: Thanks. |
It would make more sense if we also applied the same restriction to array transforms, but we don't. Allowing additional arguments for array transforms but not for dictionary transforms means that we need different code paths elsewhere depending on whether we are handling array transforms and dictionary transforms. In general, I think we should minimize discrepancies if we can. Have you had a look at the PR? It is a really simple and small fix and seems to do away with the need to restrict dictionary call in this way. |
yes, another benefit is that this also allows for the subclass implmentations to dynamically determine the additional arguments based on the value of specific data keys. |
This PR #6598 is simple at first glance, it is in fact worsening the overall transform API inconsistency that I commented on this thread earlier (#6595 (comment)). |
It is the case that array transforms get chained, however. I don't know how many users do it but we certainly make it possible for them to do it and even show them how to do it. |
Do you mean that |
Yse we are treating these as a pattern across all the applications we (the core devs) built as the documentation suggested. we don't explicitly check the inconsistency as it is not a fatal error at this base class level for 3rd party applications. If you propose changes to this, please feel free to raise a new feature request, over the feature request we can investigate the impact and come up with a development plan if it becomes useful. |
My point is that we aren't crossing any red lines by relaxing the restriction on |
could you please define 'crossing any red lines'?
could you please define 'crossing any red lines'? it seems to me that the comment doesn't help address this technical issue or towards solving the issue? |
'Crossing any red lines' just means changing the design in a way that breaks critical assumptions. To rephrase: My point is that we aren't breaking the design by relaxing the restriction on |
The change is the root cause of the bug reported in this ticket. Which means certain types of v1.1 use cases will also be affected and the users upgraded from v1.1 to v1.2 are not expecting these, nor is it documented. so in my understanding it's critical. For this type of base APIs, I believe we should always be very careful when changing the assumptions, even if it looks trivial at first glance. |
If, going forward |
We also have some holes in the unit tests if this was able to get through undetected. If we want to go with the PR, I can add additional tests before review |
Nic and I tried to list reasons why the seemingly simple fix is not ideal, it's unfortunate that this statement appears repeatedly without convincing evidence... and as I understand it, this thread is moving towards unnecessary debate. So I'll gratefully stop making further comments here. |
@tangy5 I think I've understood everything I need to from the code. If I understand correctly, you don't have any transforms that you specifically need to adapt. It's primarily an issue of tests failing. Is this correct? |
@atbenmurray , thanks, currently, this is not impacting subprojects, as we modified the tests. For users, we will recommend using MetaTensor instead. We can think about MONAi itself, and whether the meta_dict and lazy arg can be compatible. |
Hi Team, I'm not sure if this is a bug or it's expected.
When I set env var USE_META_DICT=1, some transforms will fail due to the "lazy" argument. If USE_META_DICT=0 or none, it works normally.
Currently, this is causing some functions to fail when USE_META_DICT is set to true (1).
Here is a code snipet for reproducing:
export USE_META_DICT=1
lazy_meta_dict.py,
then runpython lazy_meta_dict.py
Expected error:
The text was updated successfully, but these errors were encountered: