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

CLI: Deprecate the deprecated_command decorator #6461

Merged

Conversation

sphuber
Copy link
Contributor

@sphuber sphuber commented Jun 6, 2024

In an ironic turn of events, the deprecated_command decorator is itself deprecated. The current way of deprecating verdi commands is by passing the deprecation message in the deprecated argument in the command decorator when the command is declared. New functionality in VerdiCommandGroup then ensures that a deprecation message is printed when the command is invoked and the help text is updated accordingly.

Copy link

codecov bot commented Jun 6, 2024

Codecov Report

Attention: Patch coverage is 81.81818% with 2 lines in your changes missing coverage. Please review.

Project coverage is 77.73%. Comparing base (ef60b66) to head (fd5ec5b).
Report is 112 commits behind head on main.

Files with missing lines Patch % Lines
src/aiida/cmdline/utils/decorators.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6461      +/-   ##
==========================================
+ Coverage   77.51%   77.73%   +0.23%     
==========================================
  Files         560      561       +1     
  Lines       41444    41724     +280     
==========================================
+ Hits        32120    32432     +312     
+ Misses       9324     9292      -32     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@agoscinski agoscinski left a comment

Choose a reason for hiding this comment

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

Should we also replace the one in the cmd_database? There it was where I was not sure if should remove commands, because at least one is saying to be removed with v2.1

(aiida-dev) alexgo@fw:~/code/aiida-core/src/aiida/cmdline(fix/verdi-update-deprecation-method)$ rg 'deprecated.command'
utils/echo.py <-- can be ignored
187:    This should be used to indicate deprecated commands.

utils/decorators.py <-- can be ignored
242:def deprecated_command(message):
248:        @deprecated_command('This command has been deprecated in AiiDA v1.0, please use 'foo' instead.)
257:    warn_deprecation('The `deprecated_command` decorator is deprecated', version=3)

commands/cmd_database.py
27:@decorators.deprecated_command(
43:@decorators.deprecated_command(
76:@decorators.deprecated_command(
97:@decorators.deprecated_command(
110:@decorators.deprecated_command(
122:@decorators.deprecated_command(

Comment on lines 252 to 253
Ironicallly, this decorator itself has been deprecated. ``verdi`` commands that should be deprecated should simply
use the ``deprecated`` argument in the ``command`` decorator and specify the deprecation message.
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we put this into a sphinx deprecation decorator?

Suggested change
Ironicallly, this decorator itself has been deprecated. ``verdi`` commands that should be deprecated should simply
use the ``deprecated`` argument in the ``command`` decorator and specify the deprecation message.
.. deprecated:: 2.6
Ironicallly, this decorator itself has been deprecated. ``verdi`` commands that should be deprecated should simply
use the ``deprecated`` argument in the ``command`` decorator and specify the deprecation message.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@sphuber
Copy link
Contributor Author

sphuber commented Jun 6, 2024

Should we also replace the one in the cmd_database? There it was where I was not sure if should remove commands, because at least one is saying to be removed with v2.1

I am actually removing that one entirely. See #6461

I think that command was a bit of an outlier since it was the only one deprecated when we released v2.0. Nowadays, when we deprecate, we default to it being removed to 3.0. If we want to change this policy, I think that would require a separate discussion.

In an ironic turn of events, the `deprecated_command` decorator is
itself deprecated. The current way of deprecating `verdi` commands is by
passing the deprecation message in the `deprecated` argument in the
`command` decorator when the command is declared. New functionality in
`VerdiCommandGroup` then ensures that a deprecation message is printed
when the command is invoked and the help text is updated accordingly.
@sphuber sphuber force-pushed the fix/verdi-update-deprecation-method branch from 7d50aaf to fd5ec5b Compare June 6, 2024 15:41
@sphuber sphuber requested a review from agoscinski June 6, 2024 15:45
@agoscinski
Copy link
Contributor

I am actually removing that one entirely. See #6461

For reference. @sphuber has sent the correct link on discourse #6460

Since readthedocs is has reached a limit, I checked the docs locally and it works
image

Copy link
Contributor

@agoscinski agoscinski left a comment

Choose a reason for hiding this comment

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

Thanks!

@sphuber sphuber merged commit 4c11c06 into aiidateam:main Jun 6, 2024
11 of 12 checks passed
@sphuber sphuber deleted the fix/verdi-update-deprecation-method branch June 6, 2024 17:22
mikibonacci pushed a commit to mikibonacci/aiida-core that referenced this pull request Sep 3, 2024
In an ironic turn of events, the `deprecated_command` decorator is
itself deprecated. The current way of deprecating `verdi` commands is by
passing the deprecation message in the `deprecated` argument in the
`command` decorator when the command is declared. New functionality in
`VerdiCommandGroup` then ensures that a deprecation message is printed
when the command is invoked and the help text is updated accordingly.
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.

2 participants