-
Notifications
You must be signed in to change notification settings - Fork 200
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
Forward "verdi code delete" to "verdi node delete" #3546
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -172,25 +172,25 @@ def show(code, verbose): | |
|
||
@verdi_code.command() | ||
@arguments.CODES() | ||
@options.VERBOSE() | ||
@options.DRY_RUN() | ||
@options.FORCE() | ||
@with_dbenv() | ||
def delete(codes): | ||
def delete(codes, verbose, dry_run, force): | ||
"""Delete a code. | ||
|
||
Note that it is possible to delete a code only if it has not yet been used | ||
as an input of a calculation, i.e., if it does not have outgoing links. | ||
Note that codes are part of the data provenance, and deleting a code will delete all calculations using it. | ||
""" | ||
from aiida.common.exceptions import InvalidOperation | ||
from aiida.orm import Node | ||
from aiida.manage.database.delete.nodes import delete_nodes | ||
|
||
for code in codes: | ||
try: | ||
pk = code.pk | ||
full_label = code.full_label | ||
Node.objects.delete(pk) # pylint: disable=no-member | ||
except InvalidOperation as exception: | ||
echo.echo_error(str(exception)) | ||
else: | ||
echo.echo_success('Code<{}> {} deleted'.format(pk, full_label)) | ||
verbosity = 1 | ||
if force: | ||
verbosity = 0 | ||
elif verbose: | ||
verbosity = 2 | ||
|
||
node_pks_to_delete = [code.pk for code in codes] | ||
delete_nodes(node_pks_to_delete, dry_run=dry_run, verbosity=verbosity, force=force) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What will the message now be here for a code with calculations and There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An earlier version of the PR did exactly this - but then I also agree with @ramirezfranciscof that I don't really see a reason to be more strict with codes than with other nodes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair enough |
||
|
||
|
||
@verdi_code.command() | ||
|
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 code also exists for SqlAlchemy, maybe you want to update it there as well. Although this is not as easy as there you cannot simply compare revisions by their value. Anyway this code is touched heavily by PR #3582
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.
Ok, so how would one do it?
If there's no good way to do it, I guess we can leave the sqlalchemy version untouched.
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.
It's fine for now, but these changes will probably become irrelevant with PR #3582 . But we can merge this now.