Skip to content

Commit

Permalink
CLI: Hide misleading message for verdi archive create --test-run
Browse files Browse the repository at this point in the history
Despite it being a dry run, the command would still claim to have
created an archive, which was misleading. The `--test-run` flag is also
deprecated in favor of `--dry-run` which is used as the standard across
the CLI.
  • Loading branch information
danielhollas authored and sphuber committed Mar 18, 2024
1 parent 68ce111 commit 7e42d7a
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions src/aiida/cmdline/commands/cmd_archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,12 @@ def inspect(ctx, archive, version, meta_data, database):
@click.option(
'-b', '--batch-size', default=1000, type=int, help='Stream database rows in batches, to reduce memory usage.'
)
@click.option('--test-run', is_flag=True, help='Determine entities to export, but do not create the archive.')
@click.option(
'--test-run',
is_flag=True,
help='Determine entities to export, but do not create the archive. Deprecated, please use `--dry-run` instead.',
)
@options.DRY_RUN(help='Determine entities to export, but do not create the archive.')
@decorators.with_dbenv()
def create(
output_file,
Expand All @@ -153,6 +158,7 @@ def create(
compress,
batch_size,
test_run,
dry_run,
):
"""Create an archive from all or part of a profiles's data.
Expand All @@ -169,6 +175,10 @@ def create(

archive_format = get_format()

if test_run:
echo.echo_deprecated('the `--test-run` option is deprecated. Use `-n/--dry-run` option instead')
dry_run = test_run

if all_entries:
entities = None
else:
Expand Down Expand Up @@ -199,7 +209,7 @@ def create(
'overwrite': force,
'compression': compress,
'batch_size': batch_size,
'test_run': test_run,
'test_run': dry_run,
}

if AIIDA_LOGGER.level <= logging.REPORT:
Expand All @@ -210,9 +220,10 @@ def create(
try:
create_archive(entities, filename=output_file, archive_format=archive_format, **kwargs)
except ArchiveExportError as exception:
echo.echo_critical(f'failed to write the archive file. Exception: {exception}')
echo.echo_critical(f'failed to write the archive file: {exception}')
else:
echo.echo_success(f'wrote the export archive file to {output_file}')
if not dry_run:
echo.echo_success(f'wrote the export archive file to {output_file}')


@verdi_archive.command('migrate')
Expand Down Expand Up @@ -341,7 +352,12 @@ class ExtrasImportCode(Enum):
@click.option(
'-b', '--batch-size', default=1000, type=int, help='Stream database rows in batches, to reduce memory usage.'
)
@click.option('--test-run', is_flag=True, help='Determine entities to import, but do not actually import them.')
@click.option(
'--test-run',
is_flag=True,
help='Determine entities to import, but do not actually import them. Deprecated, please use `--dry-run` instead.',
)
@options.DRY_RUN(help='Determine entities to import, but do not actually import them.')
@decorators.with_dbenv()
@click.pass_context
def import_archive(
Expand All @@ -357,13 +373,18 @@ def import_archive(
import_group,
group,
test_run,
dry_run,
):
"""Import archived data to a profile.
The archive can be specified by its relative or absolute file path, or its HTTP URL.
"""
from aiida.common.progress_reporter import set_progress_bar_tqdm, set_progress_reporter

if test_run:
echo.echo_deprecated('the `--test-run` option is deprecated. Use `-n/--dry-run` option instead')
dry_run = test_run

if AIIDA_LOGGER.level <= logging.REPORT:
set_progress_bar_tqdm(leave=AIIDA_LOGGER.level <= logging.INFO)
else:
Expand All @@ -384,7 +405,7 @@ def import_archive(
'batch_size': batch_size,
'create_group': import_group,
'group': group,
'test_run': test_run,
'test_run': dry_run,
}

for archive, web_based in all_archives:
Expand Down

0 comments on commit 7e42d7a

Please sign in to comment.