Skip to content

Commit

Permalink
Update suggestions to use verdi presto and verdi profile setup
Browse files Browse the repository at this point in the history
  • Loading branch information
sphuber committed Apr 25, 2024
1 parent d23992b commit a509516
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 27 deletions.
25 changes: 2 additions & 23 deletions src/aiida/cmdline/commands/cmd_presto.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,26 +55,8 @@ def default_profile_name():
show_default=True,
help='The email of the default user.',
)
@click.option(
'--first-name',
default=get_config_option('autofill.user.first_name') or 'John',
show_default=True,
help='The first name of the default user.',
)
@click.option(
'--last-name',
default=get_config_option('autofill.user.last_name') or 'Doe',
show_default=True,
help='The last name of the default user.',
)
@click.option(
'--institution',
default=get_config_option('autofill.user.institution') or 'Unknown',
show_default=True,
help='The institution of the default user.',
)
@click.pass_context
def verdi_presto(ctx, profile_name, email, first_name, last_name, institution):
def verdi_presto(ctx, profile_name, email):
"""Set up a new profile as automatically as possible.
This command aims making setting up a new profile as easy as possible. It intentionally provides a limited amount of
Expand All @@ -91,7 +73,7 @@ def verdi_presto(ctx, profile_name, email, first_name, last_name, institution):
\b
* Create a new profile that is set as the new default
* Create a default user for the profile (can be configured through options)
* Create a default user for the profile (email can be configured through options)
* Set up the localhost as a `Computer` and configure it
* Set a number of configuration options with sensible defaults
Expand All @@ -117,9 +99,6 @@ def verdi_presto(ctx, profile_name, email, first_name, last_name, institution):
ctx.obj.config,
name=profile_name,
email=email,
first_name=first_name,
last_name=last_name,
institution=institution,
storage_backend=storage_backend,
storage_config=storage_config,
broker_backend=broker_backend,
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 @@ -116,7 +116,7 @@ def profile_list():
echo.echo_report(f'configuration folder: {config.dirpath}')

if not config.profiles:
echo.echo_warning('no profiles configured: run `verdi setup` to create one')
echo.echo_warning('no profiles configured: run `verdi presto` to create one')
else:
sort = lambda profile: profile.name # noqa: E731
highlight = lambda profile: profile.name == config.default_profile_name # noqa: E731
Expand Down
5 changes: 4 additions & 1 deletion src/aiida/cmdline/commands/cmd_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ def verdi_status(print_traceback, no_rmq):

if profile is None:
print_status(ServiceStatus.WARNING, 'profile', 'no profile configured yet')
echo.echo_report('Configure a profile by running `verdi quicksetup` or `verdi setup`.')
echo.echo_report(
'Run `verdi presto` to automatically setup a profile using all defaults or use `verdi profile setup` '
'for more control.'
)
return

print_status(ServiceStatus.UP, 'profile', profile.name)
Expand Down
10 changes: 8 additions & 2 deletions tests/cmdline/commands/test_presto.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Tests for ``verdi presto``."""

import pytest
from aiida.cmdline.commands.cmd_presto import default_profile_name
from aiida.cmdline.commands.cmd_presto import verdi_presto, default_profile_name
from aiida.manage.configuration.config import Config


Expand All @@ -16,10 +16,16 @@
),
)
def test_default_profile_name(monkeypatch, profile_names, expected):
"""."""
"""Test the dynamic default profile function."""

def get_profile_names(self):
return profile_names

monkeypatch.setattr(Config, 'profile_names', property(get_profile_names))
assert default_profile_name() == expected


def test_presto(run_cli_command):
"""Test the ``verdi presto``."""
result = run_cli_command(verdi_presto, use_subprocess=False)
assert 'Created new profile `presto`.' in result.output

0 comments on commit a509516

Please sign in to comment.