Skip to content

Commit afb325b

Browse files
committed
f-d
1 parent a4549ff commit afb325b

File tree

2 files changed

+21
-20
lines changed

2 files changed

+21
-20
lines changed

aiidalab_launch/__main__.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -238,27 +238,27 @@ def remove_profile(ctx, app_state, profile, yes, force, purge):
238238
profile = app_state.config.get_profile(profile)
239239
except ValueError:
240240
raise click.ClickException(f"Profile with name '{profile}' does not exist.")
241-
else:
242-
if not force:
243-
instance = AiidaLabInstance(client=app_state.docker_client, profile=profile)
244-
status = asyncio.run(instance.status())
245-
if status not in (
246-
instance.AiidaLabInstanceStatus.DOWN,
247-
instance.AiidaLabInstanceStatus.CREATED,
248-
instance.AiidaLabInstanceStatus.EXITED,
249-
):
250-
raise click.ClickException(
251-
f"The instance associated with profile '{profile.name}' "
252-
"is still running. Use the -f/--force option to remove the "
253-
"profile anyways."
254-
)
255241

256-
if yes or click.confirm(
257-
f"Are you sure you want to remove profile '{profile.name}'?"
242+
if not force:
243+
instance = AiidaLabInstance(client=app_state.docker_client, profile=profile)
244+
status = asyncio.run(instance.status())
245+
if status not in (
246+
instance.AiidaLabInstanceStatus.DOWN,
247+
instance.AiidaLabInstanceStatus.CREATED,
248+
instance.AiidaLabInstanceStatus.EXITED,
258249
):
259-
app_state.config.profiles.remove(profile)
260-
app_state.save_config()
261-
click.echo(f"Removed profile with name '{profile.name}'.")
250+
raise click.ClickException(
251+
f"The instance associated with profile '{profile.name}' "
252+
"is still running. Use the -f/--force option to remove the "
253+
"profile anyways."
254+
)
255+
256+
if yes or click.confirm(
257+
f"Are you sure you want to remove profile '{profile.name}'?"
258+
):
259+
app_state.config.profiles.remove(profile)
260+
app_state.save_config()
261+
click.echo(f"Removed profile with name '{profile.name}'.")
262262

263263
if purge:
264264
ctx.invoke(reset, profile=profile, yes=yes)
@@ -701,7 +701,7 @@ def reset(app_state, profile, yes):
701701
)
702702

703703
click.secho(
704-
f"Resetting instance for profile '{profile.name}'. This action cannot be undone!",
704+
f"Resetting instance for profile '{profile.name}'. It will remove ALL DATA, the docker container and the volumes associated. This action cannot be undone!",
705705
err=True,
706706
fg="red",
707707
)

tests/test_cli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ def test_add_remove_profile():
107107
# Check that new-profile exists
108108
result: Result = runner.invoke(cli.cli, ["profile", "list"])
109109
assert "new-profile" in result.output
110+
assert "second-profile" in result.output
110111
result: Result = runner.invoke(cli.cli, ["profile", "show", "new-profile"])
111112
assert result.exit_code == 0
112113

0 commit comments

Comments
 (0)