-
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
👌 IMPROVE: Check nodes are from same backend in validate_link
#5462
Conversation
FYI, this is how you would use engine = sa.create_engine('sqlite:///:memory:', future=True, echo=False)
Base.metadata.create_all(engine)
session1 = Session(bind=engine, future=True)
session2 = Session(bind=engine, future=True)
node1 = DbNode(node_type='data.dict.dict', label='test1')
session1.add(node1)
node2 = DbNode(node_type='data.dict.dict', label='test2')
session2.add(node2)
link = DbLink(input=node1, output=node2, label='test', type='test')
session1.add(link)
Perhaps could add this also 🤷 |
Ran a quick benchmark to get a sense of the impact on performance and it seems negligible. Both get roughly 3.00 ms per loop when calling |
Cool cheers, well if you're happy then I'm happy lol |
|
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.
Thanks @chrisjsewell
Since here:
aiida-core/aiida/storage/psql_dos/orm/nodes.py
Line 204 in bab1ad6
Only the node ID's are used to create the
DbLink
row, it would be possible currently to accidentally pass it two nodes associated with different backends, and so create an incorrect link.We could possibly use the actual
DbNode
s, to instantiate theDbLink
, and have sqlalchemy check that they are associated with the sameSession
,but adding the check in
validate_link
should catch any issue earlier on, and make it backend agnostic.