-
Notifications
You must be signed in to change notification settings - Fork 192
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 node delete 923 #1083
Verdi node delete 923 #1083
Conversation
…the command-line interface. A new module in utils takes care of the abstract part (querying of nodes to delete, with the provenance followed in reverse. Backend-specific utilities take care of the deletion in the DB
…hich means that aiidateam#923 is resolved
…entation for the verdi node subcommands
aiida/cmdline/commands/node.py
Outdated
action='store_true') | ||
# Commenting this option for now | ||
# parser.add_argument('-f', '--force', help='force deletion, disables final user confirmation', action='store_true') | ||
parser.add_argument('-v', '--verbosity', help='verbosity level', action='count', default=1) |
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.
for the verbosity level: not sure it's very clear like this...
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 has been addressed in 3fcab81
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.
Seems good, but since this is quite dangerous I think one needs at least one more review (and maybe an approval from GP?)
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.
Overall and from a fast look it looks OK (but the details are also important). For example, I am not totally sure about the link status and if we cover all the cases with the tests. Maybe we can chat directly.
It's not a bad idea to involve @giovannipizzi to the discussion.
aiida/backends/sqlalchemy/utils.py
Outdated
|
||
session = sa.get_scoped_session() | ||
|
||
with session.begin(subtransactions=True): |
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.
At aiida.orm.implementation.sqlalchemy.code.delete_code I see the following
from aiida.backends.sqlalchemy import get_scoped_session
session = get_scoped_session()
session.begin(subtransactions=True)
try:
code.dbnode.delete()
session.commit()
except:
session.rollback()
raise
Which should be the verbose way of what you wrote. I suppose that at the end of the with clause/statement, there is an auto-commit (according to http://docs.sqlalchemy.org/en/latest/orm/session_transaction.html#session-autocommit).
It is worth verifying that for any kind of error in the queries, there is a rollback.I suppose there is but...
The same for Django
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.
The django part is taken from the existing script, and the same logic is replicated for sqlalchemy.
The django code is working on big databases, I was using it in a while in the current form.
Regarding your comment on verbosity, I disagree: I do explicit deletion of the links, since it's more robust than relying on deletion cascades (which I'm not sure is implemented) for the links. Maybe above example for code deletion should be checked?
From the docs that you cite I understand that using the session in a try-except clause or with a context-manager is equivalent. As for the 'it is worth verifying': That's the reviewers job ;)
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 is not actually a proof of correctness that it runs on big databases (it's an indication). I also never mentioned to do deletion propagation etc.
An overall comment. The reviewers' job is to make some constructive comments on the code and highlight some potential corner cases (of course they should be somehow answered constructively since the author asked the reviewer's opinion & the reviewer invested some time to give feedback).
Unfortunately, I don't have the time to check your code for all these corner cases.
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.
Me see problem, I make fix... Seriously, let's not have a big discussion here, about proofs of correctness, and the role of reviewers. I added the explicit try-and-except clause that you wanted and made some more tests with deliberately wrong queries. The rollback works. Actually, I found that, different from Django, the cascading is not implemented for group-membership, so I also delete on the dbnode_dbgroup table in 83b0478 .
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 for the changes
Welcome to the party @giovannipizzi |
…ement for node deletion for sqlalchemy because it wasn't liked, and actually because the cascading for dbgroup_dbnodes was failing (if node belonged to a group) in sqlalchemy
I gave my comments to @lekah personally, after which he did the two new commits. I think the way it is now it's acceptable. Note that the follow-returns has been removed from the command line (I think it's too dangerous, it's not what people want). It's still in the code to avoid to remove the implementation)> |
Important question: what to do when deleting outputs of sealed calculations? @sphuber @muhrin |
After further discussion with @lekah we realised that there might be a number of reasons why users want to delete outputs. They should at least be aware that they are doing it. So, proposed solution:
|
Do these final checks hold for all calculations or only sealed ones? Do we now have a clear definition and implementation of the |
For all calculations |
…a logging mechanism for calculations that lose created data or called instance. Implemented a printout when this happens and storing to DbLog. To be reviewed for further improvements.
Commit c0da5c4 addresses the first set of remarks by @giovannipizzi . There is a query to find all calculations that lose created data, and a query for calculations that lose called instances. |
I had more time today and I looked at it more carefully. Do we have a draft on the existing link types? |
Current link types are enumerated (literally) here: http://aiida-core.readthedocs.io/en/latest/_modules/aiida/common/links.html |
If with 'draft' you are referencing to the document that I started writing and presented at some point, that is all still purely hypothetical and none of it has been implemented. You already pointed to the link types that currently exist in |
…ations that would lose created data or called instance will get this action written into the log. Additional warnings are printed, but it is still allowed to delete data without its creator or called workflows without their callers, since there are usecases
71cb8df addresses the comments and suggestions by @giovannipizzi . Calculations will have it written to the log if created or called instances are deleted. There is a flag to disable this checks, but it cannot be enabled via command-line. |
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.
I am going to approve this. The documentation on the link types is indeed missing but it is a different issue. When the documentation is ready, we can check if we need to add a few more checks (the only one coming to my mind is a warning for 'RETURN'ed stuff similarly to CREATEd. The rest should be ok as we automatically delete all children via INPUT or CREATE, at least in this version.
I don't merge in case someone wants to give some final comment. |
Yes, I agree. I also had a short chat with Leo and I also agree with what @giovannipizzi said. |
verdi node delete via command line is introduced, making the secret script not longer necessary.
Made a test for that functionality and updated the documentation.