-
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
Do not allow the copy or deepcopy of Node, except for Data #1705
Conversation
63db99b
to
24ca54e
Compare
Codecov Report
@@ Coverage Diff @@
## develop #1705 +/- ##
===========================================
+ Coverage 56.4% 56.41% +0.01%
===========================================
Files 275 275
Lines 33931 33912 -19
===========================================
- Hits 19139 19132 -7
+ Misses 14792 14780 -12
Continue to review full report at Codecov.
|
Why is this blocked Seb? Do you want a review or should it wait? |
It was blocked by #1704 but that is now merged, so I will rebase and then it is ready for review |
24ca54e
to
6e332b9
Compare
6e332b9
to
80cca3b
Compare
aiida/orm/data/__init__.py
Outdated
|
||
:returns: an unstored clone of this Data node | ||
""" | ||
return self.clone() |
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.
Can we raise on is_stored asking the user to use clone instead.
@muhrin I have addressed the issue and its ready for review |
9abe1c7
to
ced9d11
Compare
We explicitly disallow calling the functions copy and deepcopy from the python copy module on a Node instance. The reason is that the behavior of this for a Calculation node, with respect to what should be returned and how this would affect the graph, is not clear. Rather, to clone a Calculation, the caching mechanism should be used or a new ProcessBuilder could be generated from a completed Process that would recreate the necessary inputs that could then easily be relaunched. For Data nodes, the behavior can be defined a bit better. Therefore we allow to call deepcopy on a Data node, which will call the internal clone method, which will return an identical, but unstored, clone of the original Data node. The clone will have no links and a newly generated UUID.
Deep copying an unstored node is fine however and just pipes through to the clone method.
ced9d11
to
220c3ea
Compare
@giovannipizzi could you please give this a look so it can be merged. It can be quite a problem for people running |
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 for me!
Does this need also @muhrin's review to get unlocked?
He already was agreed provided I made the one update, which I did, so I am pretty sure he is on board_ |
Fixes #1699
We explicitly disallow calling the functions copy and deepcopy
from the python copy module on a Node instance. The reason is that
the behavior of this for a Calculation node, with respect to what
should be returned and how this would affect the graph, is not clear.
Rather, to clone a Calculation, the caching mechanism should be
used or a new ProcessBuilder could be generated from a completed
Process that would recreate the necessary inputs that could then
easily be relaunched.
For Data nodes, the behavior can be defined a bit better. Therefore
we allow to call deepcopy on a Data node, which will call the internal
clone method, which will return an identical, but unstored, clone of
the original Data node. The clone will have no links and a newly
generated UUID.