Skip to content

Commit 7402c17

Browse files
authored
CLI: Fix verdi storage migrate for profile without broker (aiidateam#6550)
The command needs to make sure the daemon of the profile is not running so it instantiates the `DaemonClient` but this raises for profiles that do not define a broker. Since the daemon cannot be started for brokerless profiles anyway the command does not have to check in this case.
1 parent 1b8c58b commit 7402c17

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/aiida/cmdline/commands/cmd_storage.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,14 @@ def storage_migrate(force):
4141
from aiida.engine.daemon.client import get_daemon_client
4242
from aiida.manage import get_manager
4343

44-
client = get_daemon_client()
45-
if client.is_daemon_running:
46-
echo.echo_critical('Migration aborted, the daemon for the profile is still running.')
47-
4844
manager = get_manager()
4945
profile = manager.get_profile()
46+
47+
if profile.process_control_backend:
48+
client = get_daemon_client()
49+
if client.is_daemon_running:
50+
echo.echo_critical('Migration aborted, the daemon for the profile is still running.')
51+
5052
storage_cls = profile.storage_cls
5153

5254
if not force:

tests/cmdline/commands/test_storage.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ def tests_storage_info(aiida_localhost, run_cli_command):
3535
assert node.node_type in result.output
3636

3737

38+
@pytest.mark.usefixtures('stopped_daemon_client')
39+
def tests_storage_migrate_no_broker(aiida_config_tmp, aiida_profile_factory, run_cli_command):
40+
"""Test the ``verdi storage migrate`` command for a profile without a broker."""
41+
with aiida_profile_factory(aiida_config_tmp) as profile:
42+
assert profile.process_control_backend is None
43+
result = run_cli_command(cmd_storage.storage_migrate, parameters=['--force'], use_subprocess=False)
44+
assert 'Migrating to the head of the main branch' in result.output
45+
46+
3847
@pytest.mark.usefixtures('stopped_daemon_client')
3948
def tests_storage_migrate_force(run_cli_command):
4049
"""Test the ``verdi storage migrate`` command (with force option)."""

0 commit comments

Comments
 (0)