Skip to content
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

Merged
merged 4 commits into from
Nov 28, 2019

Conversation

ltalirz
Copy link
Member

@ltalirz ltalirz commented Nov 14, 2019

fix #3545

verdi code delete was preventing users from deleting codes with
associated calculations.
While it's good to warn users, preventing them from doing it entirely
seems unnecessary, also given that they could simply use verdi node
delete (which most users won't realize).

Thus adding a --force option that pipes verdi code delete through to
verdi node delete.

verdi code delete was preventing users from deleting codes with
associated calculations.
While it's good to warn users, preventing them from doing it entirely
seems unnecessary, also given that they could simply use verdi node
delete (which most users won't realize).

Thus adding a --force option that pipes `verdi code delete` through to
`verdi node delete`.
@ramirezfranciscof
Copy link
Member

ramirezfranciscof commented Nov 15, 2019

I'm not sure I understand. Why was it preventing the deletion of those codes? were they trying to delete the codes (which are data nodes) without deleting the calculations associated? If this is so, passing the force keyword from code delete to node delete wouldn't help because it is only used to avoid asking for confirmation, it does not allow you to override fixed traversal rules which would be the issue in that case.

EDIT: Nevermind, I now understand the problem is actually the confirmation prompt.

@ramirezfranciscof
Copy link
Member

Now, although adding the force keyword could be useful, I don't see why for verdi code delete you get an error instead of the information and confirmation prompt you get when you call verdi node delete.

Also, mildly unrelated: is verdi code delete checking that the provided pks are actually codes instead of just any node?

@ltalirz
Copy link
Member Author

ltalirz commented Nov 15, 2019

Now, although adding the force keyword could be useful, I don't see why for verdi code delete you get an error instead of the information and confirmation prompt you get when you call verdi node delete.

Well, one could pipe through directly to verdi node delete - but this would be a larger step from the current status (impossible to delete a code with associated calculations).
People might argue that it is dangerous to make it too easy to delete a code.
Since there is always the confirmation prompt, however, I would be perfectly fine with that.

@sphuber @giovannipizzi What's your take on this?

is verdi code delete checking that the provided pks are actually codes instead of just any node?

Yes.

@ramirezfranciscof
Copy link
Member

Well, one could pipe through directly to verdi node delete - but this would be a larger step from the current status (impossible to delete a code with associated calculations).

But I mean, isn't that what you wanted with this PR? (or at least one of the options proposed) To be able to have 'verdi code delete' work when deleting codes that have calculations attached?

 * pipe "verdi code delete" through to the same function
   used in "verdi node delete"
 * fix migration warning for newer DB version
@ltalirz
Copy link
Member Author

ltalirz commented Nov 26, 2019

@ramirezfranciscof I just updated the PR to indeed simply pipe through to the function used by verdi node delete.
I agree that this is the most straightforward solution.

@ltalirz ltalirz requested a review from sphuber November 26, 2019 18:00
Copy link
Contributor

@sphuber sphuber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ltalirz all good, just one suggestion

@@ -162,16 +162,23 @@ def check_schema_version(profile_name):
set_db_schema_version(code_schema_version)
db_schema_version = get_db_schema_version()

if code_schema_version != db_schema_version:
if code_schema_version > db_schema_version:
Copy link
Contributor

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

Copy link
Member Author

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.

Copy link
Contributor

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.

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)
Copy link
Contributor

Choose a reason for hiding this comment

The 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 force=False? I guess since it pipes through to delete_nodes it will not explicitly mention code or its calculations but just nodes in general. Would it maybe be better to do the check in this command and raise a critical error unless force=True. Then the message can be made more specific.

Copy link
Member Author

Choose a reason for hiding this comment

The 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.
When one calls verdi code delete ... without --force, it will simply prompt yes/no if there are other nodes attached.
To me this seems fine.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough

@sphuber sphuber merged commit 970247d into aiidateam:develop Nov 28, 2019
@sphuber sphuber deleted the issue_3545_code_delete branch November 28, 2019 07:41
@sphuber
Copy link
Contributor

sphuber commented Nov 28, 2019

Thanks @ltalirz

@ltalirz ltalirz changed the title add --force option for verdi code delete Forward "verdi code delete" to "verdi node delete" Dec 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

allow to delete nodes starting from code
3 participants