-
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
Instantiation mode "partial"
to "callable"
. Return the _target_
component as-is when in _mode_="callable"
and no kwargs are specified
#7413
Conversation
Hi @ibro45, thanks for your PR, could you please mention the case when it will be an issue? Perhaps a small snippets of code. Thanks. |
I was trying to achieve this: inferer:
_target_: monai.inferers.PatchInferer
batch_size: 8
splitter:
_target_: monai.inferers.SlidingWindowSplitter
patch_size: [96, 96, 96]
overlap: 0.5
merger_cls:
_target_: monai.inferers.AvgMerger # I had a custom merger here that I would have to import if I wanted to use $
_mode_: partial but it would fail to instantiate because the I know this could be solved with Thank you! |
I get the point now, so instead of return the component directly when no kwargs, I would suggest add a mode here or make it clear in the docstring. Lines 235 to 239 in 6c9e49e
What do you think? cc @ericspod @Nic-Ma |
I'd suggest a mode name change too. Perhaps "partial" should become "callable" or something to indicate that you could get a partial object back or just whatever the callable thing was if you gave no arguments. |
I think renaming I may be overcomplicating it here, but what about changing the mode names as follows:
|
I would leave "default" alone but otherwise this sounds sensible. @KumoLiu thoughts? |
Agreed. |
Let's fix the minor flake issues but otherwise it looks good. |
Hi @ibro45, could you please fix the flake8 issue and DCO issue, then I will help merge this one. Thanks. |
Signed-off-by: Ibrahim Hadzic <ibrahimhadzic45@gmail.com>
DCO Remediation Commit for Ibrahim Hadzic <ibrahimhadzic45@gmail.com> I, Ibrahim Hadzic <ibrahimhadzic45@gmail.com>, hereby add my Signed-off-by to this commit: ba27569 I, Ibrahim Hadzic <ibrahimhadzic45@gmail.com>, hereby add my Signed-off-by to this commit: bcc5bde Signed-off-by: Ibrahim Hadzic <ibrahimhadzic45@gmail.com>
_target_
component as-is when in _mode_="partial"
and no kwargs are specified"partial"
to "callable"
. Return the _target_
component as-is when in _mode_="callable"
and no kwargs are specified
@KumoLiu should be good now, also renamed "partial" to "callable" |
/build |
… component as-is when in `_mode_="callable"` and no kwargs are specified (Project-MONAI#7413) ### Description A `_target_` component with `_mode_="partial"` will still be wrapped in `functools.partial` even when no kwargs are passed: `functool.partial(component)`. In such cases, the component can just be returned as-is. If you agree with this, I will add tests for it. Thank you! ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [ ] New tests added to cover the changes. - [ ] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [ ] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [ ] In-line docstrings updated. - [ ] Documentation updated, tested `make html` command in the `docs/` folder. --------- Signed-off-by: Ibrahim Hadzic <ibrahimhadzic45@gmail.com> Signed-off-by: Juan Pablo de la Cruz Gutiérrez <juampatronics@gmail.com>
… component as-is when in `_mode_="callable"` and no kwargs are specified (Project-MONAI#7413) ### Description A `_target_` component with `_mode_="partial"` will still be wrapped in `functools.partial` even when no kwargs are passed: `functool.partial(component)`. In such cases, the component can just be returned as-is. If you agree with this, I will add tests for it. Thank you! ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [ ] New tests added to cover the changes. - [ ] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [ ] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [ ] In-line docstrings updated. - [ ] Documentation updated, tested `make html` command in the `docs/` folder. --------- Signed-off-by: Ibrahim Hadzic <ibrahimhadzic45@gmail.com> Signed-off-by: Yu0610 <612410030@alum.ccu.edu.tw>
Description
A
_target_
component with_mode_="partial"
will still be wrapped infunctools.partial
even when no kwargs are passed:functool.partial(component)
. In such cases, the component can just be returned as-is.If you agree with this, I will add tests for it. Thank you!
Types of changes
./runtests.sh -f -u --net --coverage
../runtests.sh --quick --unittests --disttests
.make html
command in thedocs/
folder.