-
Notifications
You must be signed in to change notification settings - Fork 229
Replace RemoteStashFolderData
with RemoteStashCopyData
#6825
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
Conversation
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.
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6825 +/- ##
==========================================
+ Coverage 79.06% 79.06% +0.01%
==========================================
Files 565 566 +1
Lines 43126 43155 +29
==========================================
+ Hits 34095 34118 +23
- Misses 9031 9037 +6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Just talked to @agoscinski , We don't actually need to store the from aiida.orm import load_node, CalcJobNode, Node
def traverse(node: Node) -> CalcJobNode | None:
for l in node.base.links.get_incoming():
if isinstance(l.node, CalcJobNode):
calcjob_node = l.node
return calcjob_node
return traverse(l.node)
return None
node = load_node(12)
calcjob_node = traverse(node)
if None:
raise ValueError("Your stash node is not connected to any calcjob node")
print(calcjob_node) Therefore, this PR, has to be only do the deprecation job. |
e1b1b4a
to
5fb19b3
Compare
@agoscinski I applied your previous review applied, |
RemoteStashFolderData
and introduce an additional property source_uuid
RemoteStashFolderData
RemoteStashFolderData
RemoteStashFolderData
with RemoteStashCopyData
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.
Minor suggestions.
RemoteStashData
should be actually an abstract class right? I mean it should never been used but only the child classes. Maybe we can do this in a subsequent PR? EDIT: just saw that we expose this publicly so I rather don't touch this class for now
'`RemoteStashFolderData` is deprecated, it can only be used to load already stored data. ' | ||
'Not possible to make any new instance of it. Use `RemoteStashCopyData` instead.', | ||
) | ||
raise RuntimeError('`RemoteStashFolderData` instantiation is not allowed. Use `RemoteStashCopyData` instead.') |
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.
Note that this does not conflict with querying old results using RemoteStashFolderData
since it uses __new__
and not __init__
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 old data are from a different class, so it should not conflict with querying.
also this is a __init__
here. I don't understand the comment.
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.
Anyone how has RemoteStashFolderData
in the past AiiDA database for whatever reason, will construct this object during a query. If we raise an error in the __init__
and we would use __init__
to construct the object, then an error appears. However, the query builder does not invoke the __init__
, it invokes only __new__
when creating the object
@@ -12,7 +12,7 @@ | |||
|
|||
from aiida.common.datastructures import StashMode | |||
from aiida.common.exceptions import StoringNotAllowed | |||
from aiida.orm import RemoteStashCompressedData, RemoteStashData, RemoteStashFolderData | |||
from aiida.orm import RemoteStashCompressedData, RemoteStashCopyData, RemoteStashData |
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.
Could we maybe a test that checks if RemoteStashFolderData
is still queryable? I checked that it works but the logic of the query builder is not trivial
from aiida.orm.nodes.data.remote.stash.folder import RemoteStashFolderData
from aiida.common import StashMode
RemoteStashFolderData(stash_mode=StashMode.COPY, target_basepath="/tmp", source_list=("/some",)).store()
QueryBuilder().append(RemoteStashFolderData).first()
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.
not possible to instantiate RemoteStashFolderData
anymore, so your test here would fail.
It's a good thing that you are double checking for query builder, however since I have not removed MetadataField
s I don't see why it should not be working
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 still works, and it would be not good if it does not work. We need to support old databases with new versions. Please read this #6825 (comment) or try the code with your PR and see that it works. But nevertheless I would like a test that tests this for future changes.
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'm confused, this is instantiating the deprecated class, it should raise 🤔
RemoteStashFolderData(stash_mode=StashMode.COPY, target_basepath="/tmp", source_list=("/some",)).store()
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.
So the query builder uses
entity = RemoteStashFolderData.__new__(RemoteStashFolderData)
entity._backend_entity = orm.Int(5)._backend_entity
call_with_super_check(entity.initialize)
one can use this
from aiida.orm.nodes.data.remote.stash.folder import RemoteStashFolderData
entity = RemoteStashFolderData.__new__(RemoteStashFolderData)
entity._backend_entity = Int(5)._backend_entity
call_with_super_check(entity.initialize)
entity.store()
len(QueryBuilder().append(RemoteStashFolderData).all())
but this does not store them in the database, even though the store function is successful, I don't know why. I don't know the database backend enough. Any way we tested it. I think we should use database migration for this to replace it with RemoteStashCopyData
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.
Sorry I thought the migrator also can change node types in the database, but it seems to just update the schema changes. I will think about a way to still store a RemoteStashFolderData
I applied your review @agoscinski |
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.
Please read my comment #6825 (comment)
Also please just reply on
|
review applied r 2 fixed a typo in function signature fields updated review applied
RemoteStashFolderData
with RemoteStashCopyData
RemoteStashFolderData
with RemoteStashCopyData
e49b211
to
3c6bd2d
Compare
Draft for commit, please check
|
We discussed that we need a migration for this as we do not want to have two datatypes in the database that basically do the same thing. Introducing the database migration in the future will causes problem as we need to resolve conflicts in the |
yes, pretty much that's all to be said 🤷♂️ |
I close this for now. |
Fix: #6784
Deprecates the legacy stash node type
RemoteStashFolderData
and replace it withRemoteStashCopyData
.This is only for naming convention which we have discussed before with @agoscinski.
This PR also contains docstring cleanup for
RemoteStashCompressedData
This PR also introduces a new property source_uuid. This is useful for un-stashing, and re-stashing purposes in the coming changes.Note the 1 & 2 are entirely different changes, and deprecation is NOT occurred for introducing source_uuid.