Skip to content

Deprecated decorators#2338

Merged
ericspod merged 8 commits into
Project-MONAI:devfrom
ericspod:deprecated_decorators
Jun 10, 2021
Merged

Deprecated decorators#2338
ericspod merged 8 commits into
Project-MONAI:devfrom
ericspod:deprecated_decorators

Conversation

@ericspod

@ericspod ericspod commented Jun 8, 2021

Copy link
Copy Markdown
Member

Signed-off-by: Eric Kerfoot eric.kerfoot@kcl.ac.uk

Fixes #2335 .

Description

This adds a "deprecated" decorator to apply to functions, methods, and classes to designate them deprecated. A "deprecated_arg" decorator is provided to apply to callables to designate a particular argument as deprecated. Both decorators use the MONAI version to determine if they should issue a warning or raise an exception depending on what version they have been deprecated or removed on.

Status

Ready

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

ericspod and others added 3 commits June 8, 2021 21:26
Signed-off-by: Eric Kerfoot <eric.kerfoot@kcl.ac.uk>
Signed-off-by: Eric Kerfoot <eric.kerfoot@kcl.ac.uk>
@ericspod ericspod requested review from Nic-Ma and wyli June 8, 2021 20:32
@ericspod

ericspod commented Jun 8, 2021

Copy link
Copy Markdown
Member Author

/black

Comment thread monai/utils/deprecated.py
@ericspod

ericspod commented Jun 8, 2021

Copy link
Copy Markdown
Member Author

The lock will only ensure the warnings are issued once if warnings get issued on the parent process before multiprocessing begins, otherwise each subprocess will issue the warning once.

I was going to discuss what to do about the docstring. Other packages that provide deprecation decorators such as this do update the docstring but we should decide on how and what style we will use.

Also the flake8-py3 error I'm getting is related to the test environment?

@Nic-Ma

Nic-Ma commented Jun 8, 2021

Copy link
Copy Markdown
Contributor

Hi @ericspod ,

I think all the open PRs have this same flake8 issue now.

Thanks.

Comment thread monai/utils/deprecated.py
Comment thread monai/utils/deprecated.py
Comment thread tests/test_deprecated.py

class TestDeprecated(unittest.TestCase):
def setUp(self):
self.test_version = "0.5.3+96.g1fa03c2.dirty"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I tested cases when test_version > next_version > prev_version, some of the DeprecatedError were missing

@wyli wyli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thanks, it works fine with the pytorch loader, it doesn't break any existing modules, could be merged as an initial solution.

ericspod and others added 2 commits June 9, 2021 23:37
Signed-off-by: Eric Kerfoot <eric.kerfoot@kcl.ac.uk>
@ericspod ericspod enabled auto-merge (squash) June 9, 2021 22:38
@wyli

wyli commented Jun 10, 2021

Copy link
Copy Markdown
Contributor

/black

monai-bot and others added 2 commits June 10, 2021 08:22
Signed-off-by: monai-bot <monai.miccai2019@gmail.com>
@ericspod ericspod merged commit e6aa268 into Project-MONAI:dev Jun 10, 2021
wyli pushed a commit to wyli/MONAI that referenced this pull request Jun 10, 2021
* Adding deprecated decorators

Signed-off-by: Eric Kerfoot <eric.kerfoot@kcl.ac.uk>

* Adding deprecated decorators

Signed-off-by: Eric Kerfoot <eric.kerfoot@kcl.ac.uk>

* Updates from comments

Signed-off-by: Eric Kerfoot <eric.kerfoot@kcl.ac.uk>

Co-authored-by: Nic Ma <nma@nvidia.com>
@ericspod ericspod deleted the deprecated_decorators branch June 11, 2021 09:55
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.

Methods to warn the deprecating/deprecated API features

4 participants