Skip to content

Conversation

khsrali
Copy link
Contributor

@khsrali khsrali commented Apr 16, 2025

Fix: #6784
Deprecates the legacy stash node type RemoteStashFolderData and replace it with RemoteStashCopyData.
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.

@khsrali khsrali mentioned this pull request Mar 7, 2025
7 tasks
@khsrali khsrali requested a review from Copilot April 16, 2025 12:13
Copy link

@Copilot Copilot AI left a 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.

Copy link

codecov bot commented Apr 17, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.06%. Comparing base (48991ab) to head (07b37d6).
⚠️ Report is 29 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@khsrali
Copy link
Contributor Author

khsrali commented May 2, 2025

Just talked to @agoscinski ,

We don't actually need to store the uuid actually. We could just use the traversals to reach there:

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.

@khsrali khsrali force-pushed the stashing/stashingcopydata-uuid branch 3 times, most recently from e1b1b4a to 5fb19b3 Compare May 23, 2025 15:02
@khsrali
Copy link
Contributor Author

khsrali commented May 23, 2025

@agoscinski I applied your previous review applied,
Please have a look on Monday, now it should be a quick review

@khsrali khsrali requested a review from agoscinski May 23, 2025 15:11
@khsrali khsrali changed the title Deprecate RemoteStashFolderData and introduce an additional property source_uuid Deprecate RemoteStashFolderData May 23, 2025
@agoscinski agoscinski changed the title Deprecate RemoteStashFolderData ReplaceRemoteStashFolderData with RemoteStashCopyData Jun 6, 2025
Copy link
Contributor

@agoscinski agoscinski left a 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.')
Copy link
Contributor

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__

Copy link
Contributor Author

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.

Copy link
Contributor

@agoscinski agoscinski Jun 10, 2025

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

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()

Copy link
Contributor Author

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 MetadataFields I don't see why it should not be working

Copy link
Contributor

@agoscinski agoscinski Jun 10, 2025

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.

Copy link
Contributor Author

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()

Copy link
Contributor

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

Copy link
Contributor

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

@khsrali
Copy link
Contributor Author

khsrali commented Jun 10, 2025

I applied your review @agoscinski
We can talk in person about QB

@khsrali khsrali requested a review from agoscinski June 10, 2025 08:22
Copy link
Contributor

@agoscinski agoscinski left a 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)

@agoscinski
Copy link
Contributor

Also please just reply on

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?

agoscinski pushed a commit to agoscinski/aiida-core that referenced this pull request Jun 11, 2025
review applied

r 2

fixed a typo in function signature

fields updated

review applied
@agoscinski agoscinski changed the title ReplaceRemoteStashFolderData with RemoteStashCopyData Replace RemoteStashFolderData with RemoteStashCopyData Jun 12, 2025
@agoscinski agoscinski force-pushed the stashing/stashingcopydata-uuid branch from e49b211 to 3c6bd2d Compare June 12, 2025 08:43
@agoscinski
Copy link
Contributor

Draft for commit, please check

`RemoteStashFolderData` has been so far only supported the `StashMode.COPY`
option and unlike the name suggests supported also to copy individual file(s).
To be more consistent with the naming scheme of `RemoteData` that also supports
files and folders and `RemoteStashCompressedData` we switch to the name
`RemoteStashCopyData`. For backwards compatibility reasons we keep
`RemoteStashFolderData` but disable the possibility of its construction and
introduce the new class `RemoteStashCopyData` that works exactly as
`RemoteStashFolderData`. This PR also contains docstring cleanup for
`RemoteStashCompressedData`.

@agoscinski
Copy link
Contributor

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 pk. No one in the team knows how the migration works and there is no guide that makes this straightforward. One can figure this out with the existing files and material but it will take a bit of time and this renaming is not essential so we postpone this PR from v2.7.0.

@khsrali
Copy link
Contributor Author

khsrali commented Jun 15, 2025

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 pk. No one in the team knows how the migration works and there is no guide that makes this straightforward. One can figure this out with the existing files and material but it will take a bit of time and this renaming is not essential so we postpone this PR from v2.7.0.

yes, pretty much that's all to be said 🤷‍♂️

@khsrali
Copy link
Contributor Author

khsrali commented Aug 12, 2025

I close this for now.
The implementation of this commit might get used in a more broad PR that deprecates all RemoteStash*Data by removing abstractification in RemoteStashData

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Engine : RemoteStashFolderData could be refactored to RemoteStashCopiedData
2 participants