-
Notifications
You must be signed in to change notification settings - Fork 191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
verdi profile delete
: Make it storage plugin agnostic
#6224
Conversation
070c6e7
to
ac90d8f
Compare
@mbercx this is ready for review now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @sphuber! I tried my best to break the command, but could only find a few nitpicks and comments.
ac90d8f
to
891072f
Compare
891072f
to
6b408f7
Compare
@mbercx I pushed a commit with some further improvements
|
Thanks @sphuber, love the changes. After a discussion with @giovannipizzi, we're still not sure if it's a good idea to change the default behaviour, since:
Some thoughts to still consider (maybe discuss at the AiiDA meeting today):
|
1b41d8d
to
7a62650
Compare
|
||
if not force and not click.confirm('are you sure you want to continue?'): | ||
echo.echo_report(f'deleting of `{profile.name} cancelled.') | ||
echo.echo_warning('This operation cannot be undone, are you sure you want to continue?', nl=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This prompt should only appear when the force flag is not used, right?
❯ verdi profile delete tmp -f --delete-data
Warning: Deleting profile `tmp`, including all data.
Warning: This operation cannot be undone, are you sure you want to continue?Report: Deleted storage directory at `/Users/mbercx/project/core/.aiida/repository/sqlite_dos_5b7189522ae34118b151f65f618d150c`.
Report: Data storage deleted, configuration was: {'filepath': '/Users/mbercx/project/core/.aiida/repository/sqlite_dos_5b7189522ae34118b151f65f618d150c'}
Warning: `tmp` was the default profile, no profiles remain to set as default.
Success: Profile `tmp` was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Damn, my desire to have prompts prefixed with the nice Warning:
strikes again...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. By the way, I changed the flags to --delete-data/--keep-data
because I think that is going to be more clear for most users, rather than "storage" which is kind of vague. You agree?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I like it better! 👍
The `verdi profile delete` implementation was hardcoded to work only for the `core.psql_dos` storage plugin. However, it is possible for profiles to use different storage plugins, causing the command to except. The command now forwards to `Config.delete_profile`. This method gets the storage plugin defined for the profile and constructs an instance of it for the given profile. It then calls `delete` on the storage instance if the `delete_storage` argument is set to `True`. The new `delete` method is defined on the `StorageBackend` abstract base class. It is intentionally not made abstract, but rather explicitly raises `NotImplementedError`. Otherwise existing storage plugins outside of `aiida-core` would no longer be instantiable before they implement the method. The various options of `verdi profile delete` to control what parts of the storage are deleted, are simplified to just a single switch that controls whether the storage is deleted or not. The switch is not defined at all by default. The user will have to explicitly select either `--delete-data` or `--keep-data`, or they will be prompted what value to choose. If the `--force` flag is specified and no explicit flag to delete or keep the data, the command raises. The command now also properly detects if the delete profile was the default, in which case another profile is marked as the new default if any profiles remain at all.
7a62650
to
eda96be
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mr. Scope Creep is pleased. 😄
Fixes #5515
The
verdi profile delete
implementation was hardcoded to work only forthe
core.psql_dos
storage plugin. However, it is possible for profilesto use different storage plugins, causing the command to except.
The command now forwards to
Config.delete_profile
. This method getsthe storage plugin defined for the profile and constructs an instance of
it for the given profile. It then calls
delete
on the storage instanceif the
delete_storage
argument is set toTrue
.The new
delete
method is defined on theStorageBackend
abstract baseclass. It is intentionally not made abstract, but rather explicitly
raises
NotImplementedError
. Otherwise existing storage plugins outsideof
aiida-core
would no longer be instantiable before they implementthe method.
The various options of
verdi profile delete
to control what parts ofthe storage are deleted, are simplified to just a single switch that
controls whether the storage is deleted or not.
The command now also properly detects if the delete profile was the
default, in which case another profile is marked as the new default if
any profiles remain at all.