-
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
Raise when calling Node.objects.delete
for node with incoming links
#4168
Raise when calling Node.objects.delete
for node with incoming links
#4168
Conversation
tests/orm/node/test_node.py
Outdated
Regression test for storing a Node with (nested) repository | ||
content with caching. | ||
""" | ||
class TestNodeDelete(AiidaTestCase): |
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.
Do these tests actually need the AiidaTestCase
, or could that just be removed?
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, just copy/paste error, will remove it
Btw I think the docstring here is wrong, no?
|
This is a common coding paradigm and the magic is in the
By doing it like this, we just have to define the specific
Yes, it is incorrect.
Because the delete functionality of a node in AiiDA is quite complicated and often has big (unforeseen) consequences. A simple ORM method doesn't really convey this. Its signature would also become a lot more complex. The caller would have to be able to pass in the traversal rules. Will it always just delete everything it needs to without confirmation? If you do want some feedback, you are starting to build in a-back-and-forth that much more resembles CLI commands. That shouldn't be implemented in a simple ORM method. This is all to say that we could just implement the |
What is it called? I would like to read more about it. I tried googling "nested collection" but aparently this is not the correct name of the concept, he-he.
Uhm, no, I agree that there are different uses that need to have slightly different behaviours. What I meant to say perhaps is that it could pay of to do some thinking considering all ways in which AiiDA aproaches the node deletion process that would allow us to structure the code into a more consistent shape. When I worked on the |
c12dde2
to
ff2a08a
Compare
Codecov Report
@@ Coverage Diff @@
## develop #4168 +/- ##
===========================================
+ Coverage 78.89% 78.93% +0.04%
===========================================
Files 467 467
Lines 34503 34505 +2
===========================================
+ Hits 27217 27232 +15
+ Misses 7286 7273 -13
Continue to review full report at Codecov.
|
Not sure of the official name, but it is not necessarily related to "collections". It could be any abstract class that has another subclass as attribute that is exposed through its properties or method.
Fair enough. It is always a good idea to think about and discuss the design and I agree that the design around deleting entities could benefit quite significantly |
ff2a08a
to
430b1c2
Compare
@ramirezfranciscof did you want to further discuss this or do you think this can be merged before the release |
Ah no, that's ok, I didn't do an approve review because I thought @greschd was doing the review but now I see it was just a comment. I'll do it 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.
Good to go, thanks!
This guard was already in place for a node that has outgoing links but if a node had only incoming links, the method would happily delete it. This means that one could delete output nodes for example as long as they had not been used as inputs. Note also that this would leave the link in place as the deletion is not cascaded automatically. Deletion through the objects collection currently cannot deal with automated cascading rules on links and nodes. These rules are implemented in the ORM itself through the graph traversal rules for deletion. Nodes that are not isolated should therefore only be deleted through the utility function that makes sure to leave the resulting provenance graph in a coherent state.
430b1c2
to
f58b4c7
Compare
Fixes #4167
This guard was already in place for a node that has outgoing links but
if a node had only incoming links, the method would happily delete it.
This means that one could delete output nodes for example as long as
they had not been used as inputs. Note also that this would leave the
link in place as the deletion is not cascaded automatically.
Deletion through the objects collection currently cannot deal with
automated cascading rules on links and nodes. These rules are
implemented in the ORM itself through the graph traversal rules for
deletion. Nodes that are not isolated should therefore only be deleted
through the utility function that makes sure to leave the resulting
provenance graph in a coherent state.