Skip to content

Deprecated decorators#2338

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

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

Conversation

@ericspod
Copy link
Copy Markdown
Member

@ericspod ericspod commented Jun 8, 2021

Signed-off-by: Eric Kerfoot [email protected]

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 ericspod requested review from Nic-Ma and wyli June 8, 2021 20:32
@ericspod
Copy link
Copy Markdown
Member Author

ericspod commented Jun 8, 2021

/black

@ericspod
Copy link
Copy Markdown
Member Author

ericspod commented Jun 8, 2021

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
Copy link
Copy Markdown
Contributor

Nic-Ma commented Jun 8, 2021

Hi @ericspod ,

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

Thanks.


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

Copy link
Copy Markdown
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, it works fine with the pytorch loader, it doesn't break any existing modules, could be merged as an initial solution.

@ericspod ericspod enabled auto-merge (squash) June 9, 2021 22:38
@wyli
Copy link
Copy Markdown
Contributor

wyli commented Jun 10, 2021

/black

@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 <[email protected]>

* Adding deprecated decorators

Signed-off-by: Eric Kerfoot <[email protected]>

* Updates from comments

Signed-off-by: Eric Kerfoot <[email protected]>

Co-authored-by: Nic Ma <[email protected]>
@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