Skip to content

Commit

Permalink
CLI: Change --profile to -p/--profile-name for `verdi profile set…
Browse files Browse the repository at this point in the history
…up` (#6481)

This to be consistent with naming of the option for `verdi presto`.
  • Loading branch information
GeigerJ2 authored Jun 28, 2024
1 parent 6316099 commit 8ea203c
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docs/source/howto/archive_profile.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ See {ref}`how-to:share:archives` for information on how to create and migrate an
The easiest way to inspect the contents of an archive is to create a profile that "mounts" the archive as its data storage:

```{code-cell} ipython3
!verdi profile setup core.sqlite_zip -n --profile archive --filepath process.aiida
!verdi profile setup core.sqlite_zip -n --profile-name archive --filepath process.aiida
```

You can now inspect the contents of the `process.aiida` archive by using the `archive` profile in the same way you would a standard AiiDA profile.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/reference/command_line.rst
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ Below is a list with all available subcommands.
the newly created profile uses the new PostgreSQL database instead of SQLite.
Options:
--profile-name TEXT Name of the profile. By default, a unique name starting
-p, --profile-name TEXT Name of the profile. By default, a unique name starting
with `presto` is automatically generated. [default:
(dynamic)]
--email TEXT Email of the default user. [default: (dynamic)]
Expand Down
4 changes: 2 additions & 2 deletions docs/source/topics/storage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ A fully operational profile using this storage plugin can be created with a sing

.. code-block:: console
verdi profile setup core.sqlite_dos -n --profile <PROFILE_NAME> --email <EMAIL>
verdi profile setup core.sqlite_dos -n --profile-name <PROFILE_NAME> --email <EMAIL>
replacing ``<PROFILE_NAME>`` with the desired name for the profile and ``<EMAIL>`` with the email for the default user.

Expand All @@ -167,7 +167,7 @@ However, since otherwise it functions like normal storage plugins, a profile can

.. code-block:: console
verdi profile setup core.sqlite_zip -n --profile <PROFILE_NAME> --filepath <ARCHIVE>
verdi profile setup core.sqlite_zip -n --profile-name <PROFILE_NAME> --filepath <ARCHIVE>
replacing ``<PROFILE_NAME>`` with the desired name for the profile and ``<ARCHIVE>`` the path to the archive file.
The created profile can now be loaded like any other profile, and the contents of the provenance graph can be explored as usual.
Expand Down
1 change: 1 addition & 0 deletions src/aiida/cmdline/commands/cmd_presto.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def detect_postgres_config(

@verdi.command('presto')
@click.option(
'-p',
'--profile-name',
default=lambda: get_default_presto_profile_name(),
show_default=True,
Expand Down
2 changes: 1 addition & 1 deletion src/aiida/cmdline/commands/cmd_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def command_create_profile(
command=command_create_profile,
entry_point_group='aiida.storage',
shared_options=[
setup.SETUP_PROFILE(),
setup.SETUP_PROFILE_NAME(),
setup.SETUP_PROFILE_SET_AS_DEFAULT(),
setup.SETUP_USER_EMAIL(required=False),
setup.SETUP_USER_FIRST_NAME(),
Expand Down
11 changes: 11 additions & 0 deletions src/aiida/cmdline/params/options/commands/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,17 @@ def get_quicksetup_password(ctx, param, value):
cls=options.interactive.InteractiveOption,
)

SETUP_PROFILE_NAME = options.OverridableOption(
'-p',
'--profile-name',
'profile',
prompt='Profile name',
help='The name of the new profile.',
required=True,
type=types.ProfileParamType(cannot_exist=True),
cls=options.interactive.InteractiveOption,
)

SETUP_PROFILE_SET_AS_DEFAULT = options.OverridableOption(
'--set-as-default/--no-set-as-default',
prompt='Set as default?',
Expand Down
12 changes: 6 additions & 6 deletions tests/cmdline/commands/test_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def test_delete_storage(run_cli_command, isolated_config, tmp_path, entry_point)
else:
filepath = tmp_path / 'storage'

options = [entry_point, '-n', '--filepath', str(filepath), '--profile', profile_name, '--email', 'email@host']
options = [entry_point, '-n', '--filepath', str(filepath), '--profile-name', profile_name, '--email', 'email@host']
result = run_cli_command(cmd_profile.profile_setup, options, use_subprocess=False)
assert filepath.exists()
assert profile_name in isolated_config.profile_names
Expand Down Expand Up @@ -204,7 +204,7 @@ def test_setup(config_psql_dos, run_cli_command, isolated_config, tmp_path, entr
options = ['--filepath', str(tmp_path)]

profile_name = 'temp-profile'
options = [entry_point, '-n', '--profile', profile_name, '--email', 'email@host', *options]
options = [entry_point, '-n', '--profile-name', profile_name, '--email', 'email@host', *options]
result = run_cli_command(cmd_profile.profile_setup, options, use_subprocess=False)
assert f'Created new profile `{profile_name}`.' in result.output
assert profile_name in isolated_config.profile_names
Expand All @@ -221,7 +221,7 @@ def test_setup_set_as_default(run_cli_command, isolated_config, tmp_path, set_as
'-n',
'--filepath',
str(tmp_path),
'--profile',
'--profile-name',
profile_name,
'--email',
'email@host',
Expand All @@ -247,7 +247,7 @@ def test_setup_email_required(run_cli_command, isolated_config, tmp_path, entry_

isolated_config.unset_option('autofill.user.email')

options = [entry_point, '-n', '--filepath', str(tmp_path), '--profile', profile_name]
options = [entry_point, '-n', '--filepath', str(tmp_path), '--profile-name', profile_name]

if storage_cls.read_only:
result = run_cli_command(cmd_profile.profile_setup, options, use_subprocess=False)
Expand All @@ -261,7 +261,7 @@ def test_setup_email_required(run_cli_command, isolated_config, tmp_path, entry_
def test_setup_no_use_rabbitmq(run_cli_command, isolated_config):
"""Test the ``--no-use-rabbitmq`` option."""
profile_name = 'profile-no-broker'
options = ['core.sqlite_dos', '-n', '--email', 'a@a', '--profile', profile_name, '--no-use-rabbitmq']
options = ['core.sqlite_dos', '-n', '--email', 'a@a', '--profile-name', profile_name, '--no-use-rabbitmq']

result = run_cli_command(cmd_profile.profile_setup, options, use_subprocess=False)
assert f'Created new profile `{profile_name}`.' in result.output
Expand All @@ -276,7 +276,7 @@ def test_configure_rabbitmq(run_cli_command, isolated_config):
profile_name = 'profile'

# First setup a profile without a broker configured
options = ['core.sqlite_dos', '-n', '--email', 'a@a', '--profile', profile_name, '--no-use-rabbitmq']
options = ['core.sqlite_dos', '-n', '--email', 'a@a', '--profile-name', profile_name, '--no-use-rabbitmq']
run_cli_command(cmd_profile.profile_setup, options, use_subprocess=False)
profile = isolated_config.get_profile(profile_name)
assert profile.process_control_backend is None
Expand Down

0 comments on commit 8ea203c

Please sign in to comment.