Skip to content
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

[1662] Allow missing keys #1676

Merged
merged 9 commits into from
Mar 3, 2021
Merged

Conversation

rijobro
Copy link
Contributor

@rijobro rijobro commented Mar 2, 2021

Fixes #1662.

Description

Option to not raise exception if keys are missing during transform.

This is my current proposition. I've only done it for a few classes to get opinions before continuing with rest.

The generator in the base class to minimise code duplication.

Status

Work in progress

Types of changes

  • 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 --codeformat --coverage.
  • Quick tests passed locally by running ./runtests.sh --quick.
  • In-line docstrings updated.
  • Documentation updated, tested make html command in the docs/ folder.

Signed-off-by: Richard Brown <33289025+rijobro@users.noreply.github.com>
Signed-off-by: Richard Brown <33289025+rijobro@users.noreply.github.com>
@rijobro rijobro requested review from wyli and Nic-Ma March 2, 2021 10:45
Copy link
Contributor

@wyli wyli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, I think this a nice direction to go... @jansoe would be great to have your comments as well. I was also thinking of using a special key in keys such as None or * to represent the allow_missing_keys flag... but maybe that's more confusing APIs

monai/transforms/transform.py Outdated Show resolved Hide resolved
Copy link

@jansoe jansoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool, I think this will make pipelines much more flexible.

Signed-off-by: Richard Brown <33289025+rijobro@users.noreply.github.com>
Signed-off-by: Richard Brown <33289025+rijobro@users.noreply.github.com>
Signed-off-by: Richard Brown <33289025+rijobro@users.noreply.github.com>
Signed-off-by: Richard Brown <33289025+rijobro@users.noreply.github.com>
@rijobro rijobro changed the title [1662] [WIP] Allow missing keys [1662] Allow missing keys Mar 2, 2021
@rijobro rijobro marked this pull request as ready for review March 2, 2021 15:47
Signed-off-by: Richard Brown <33289025+rijobro@users.noreply.github.com>
Signed-off-by: Richard Brown <33289025+rijobro@users.noreply.github.com>
@wyli
Copy link
Contributor

wyli commented Mar 2, 2021

/black
/integration-test

Copy link
Contributor

@wyli wyli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you, it looks good to me

@rijobro rijobro merged commit 421c0a9 into Project-MONAI:master Mar 3, 2021
@rijobro rijobro deleted the missing_keys branch March 3, 2021 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add option for transforms to skip missing keys instead of raising exception
3 participants