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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/source/reference/command_line.rst
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ Below is a list with all available subcommands.
Usage: [OPTIONS]
Setup a new profile in a fully automated fashion.
(Deprecated) Setup a new profile in a fully automated fashion.
Options:
-n, --non-interactive In non-interactive mode, the CLI never prompts but
Expand Down
8 changes: 3 additions & 5 deletions src/aiida/cmdline/commands/cmd_archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,13 @@ def archive_info(path, detailed):
echo.echo_dictionary(data, sort_keys=False, fmt='yaml')


@verdi_archive.command('inspect', hidden=True)
@verdi_archive.command(
'inspect', hidden=True, deprecated='Use `verdi archive version` or `verdi archive info` instead.'
)
@click.argument('archive', nargs=1, type=click.Path(exists=True, readable=True))
@click.option('-v', '--version', is_flag=True, help='Print the archive format version and exit.')
@click.option('-m', '--meta-data', is_flag=True, help='Print the meta data contents and exit.')
@click.option('-d', '--database', is_flag=True, help='Include information on entities in the database.')
@decorators.deprecated_command(
'This command has been deprecated and will be removed soon. '
'Please call `verdi archive version` or `verdi archive info` instead.\n'
)
@click.pass_context
def inspect(ctx, archive, version, meta_data, database):
"""Inspect contents of an archive without importing it.
Expand Down
30 changes: 15 additions & 15 deletions src/aiida/cmdline/commands/cmd_data/cmd_upf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ def upf():
"""Manipulate UpfData objects (UPF-format pseudopotentials)."""


@upf.command('uploadfamily')
@decorators.deprecated_command(
'See https://aiida-pseudo.readthedocs.io/en/latest/howto.html#migrate-from-legacy-upfdata-from-aiida-core'
@upf.command(
'uploadfamily',
deprecated='See https://aiida-pseudo.readthedocs.io/en/latest/howto.html#migrate-from-legacy-upfdata-from-aiida-core',
)
@click.argument('folder', type=click.Path(exists=True, file_okay=False, resolve_path=True))
@click.argument('group_label', type=click.STRING)
Expand All @@ -50,9 +50,9 @@ def upf_uploadfamily(folder, group_label, group_description, stop_if_existing):
echo.echo_success(f'UPF files found: {files_found}. New files uploaded: {files_uploaded}')


@upf.command('listfamilies')
@decorators.deprecated_command(
'See https://aiida-pseudo.readthedocs.io/en/latest/howto.html#migrate-from-legacy-upfdata-from-aiida-core'
@upf.command(
'listfamilies',
deprecated='See https://aiida-pseudo.readthedocs.io/en/latest/howto.html#migrate-from-legacy-upfdata-from-aiida-core',
)
@click.option(
'-d',
Expand Down Expand Up @@ -96,9 +96,9 @@ def upf_listfamilies(elements, with_description):
echo.echo_warning('No valid UPF pseudopotential family found.')


@upf.command('exportfamily')
@decorators.deprecated_command(
'See https://aiida-pseudo.readthedocs.io/en/latest/howto.html#migrate-from-legacy-upfdata-from-aiida-core'
@upf.command(
'exportfamily',
deprecated='See https://aiida-pseudo.readthedocs.io/en/latest/howto.html#migrate-from-legacy-upfdata-from-aiida-core',
)
@click.argument('folder', type=click.Path(exists=True, file_okay=False, resolve_path=True))
@arguments.GROUP()
Expand All @@ -119,9 +119,9 @@ def upf_exportfamily(folder, group):
echo.echo_warning(f'File {node.filename} is already present in the destination folder')


@upf.command('import')
@decorators.deprecated_command(
'See https://aiida-pseudo.readthedocs.io/en/latest/howto.html#migrate-from-legacy-upfdata-from-aiida-core'
@upf.command(
'import',
deprecated='See https://aiida-pseudo.readthedocs.io/en/latest/howto.html#migrate-from-legacy-upfdata-from-aiida-core',
)
@click.argument('filename', type=click.Path(exists=True, dir_okay=False, resolve_path=True))
@decorators.with_dbenv()
Expand All @@ -133,9 +133,9 @@ def upf_import(filename):
echo.echo_success(f'Imported: {node}')


@upf.command('export')
@decorators.deprecated_command(
'See https://aiida-pseudo.readthedocs.io/en/latest/howto.html#migrate-from-legacy-upfdata-from-aiida-core'
@upf.command(
'export',
deprecated='See https://aiida-pseudo.readthedocs.io/en/latest/howto.html#migrate-from-legacy-upfdata-from-aiida-core',
)
@arguments.DATUM(type=types.DataParamType(sub_classes=('aiida.data:core.upf',)))
@options.EXPORT_FORMAT(
Expand Down
3 changes: 1 addition & 2 deletions src/aiida/cmdline/commands/cmd_rabbitmq.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,9 @@ def cmd_tasks_list(broker):
echo.echo(pk)


@cmd_tasks.command('analyze')
@cmd_tasks.command('analyze', deprecated='Use `verdi process repair` instead.')
@click.option('--fix', is_flag=True, help='Attempt to fix the inconsistencies if any are detected.')
@decorators.only_if_daemon_not_running()
@decorators.deprecated_command('Use `verdi process repair` instead.')
@click.pass_context
def cmd_tasks_analyze(ctx, fix):
"""Perform analysis of process tasks.
Expand Down
10 changes: 5 additions & 5 deletions src/aiida/cmdline/commands/cmd_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from aiida.cmdline.commands.cmd_verdi import verdi
from aiida.cmdline.params import options
from aiida.cmdline.params.options.commands import setup as options_setup
from aiida.cmdline.utils import decorators, echo
from aiida.cmdline.utils import echo
from aiida.manage.configuration import Profile, load_profile


Expand Down Expand Up @@ -136,10 +136,10 @@ def setup(
echo.echo_success(f'created new profile `{profile.name}`.')


@verdi.command('quicksetup')
@decorators.deprecated_command(
'This command is deprecated. For a fully automated alternative, use `verdi presto --use-postgres` instead. '
'For full control, use `verdi profile setup core.psql_dos`.'
@verdi.command(
'quicksetup',
deprecated='This command is deprecated. For a fully automated alternative, use `verdi presto --use-postgres` '
'instead. For full control, use `verdi profile setup core.psql_dos`.',
)
@options.NON_INTERACTIVE()
# Cannot use `default` because that will fail validation of the `ProfileParamType` if the profile already exists and it
Expand Down
9 changes: 9 additions & 0 deletions src/aiida/cmdline/utils/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,16 @@
@deprecated_command('This command has been deprecated in AiiDA v1.0, please use 'foo' instead.)
def mycommand():
pass

.. deprecated:: 2.6

Ironically, 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.

"""
from aiida.common.warnings import warn_deprecation

Check warning on line 258 in src/aiida/cmdline/utils/decorators.py

View check run for this annotation

Codecov / codecov/patch

src/aiida/cmdline/utils/decorators.py#L258

Added line #L258 was not covered by tests

warn_deprecation('The `deprecated_command` decorator is deprecated', version=3)

Check warning on line 260 in src/aiida/cmdline/utils/decorators.py

View check run for this annotation

Codecov / codecov/patch

src/aiida/cmdline/utils/decorators.py#L260

Added line #L260 was not covered by tests

@decorator
def wrapper(wrapped, _, args, kwargs):
Expand Down
Loading