Hello everyone!
I was trying to access some data with the QueryBuilder when I ran into some unexpected behavior.
What I did was to export some nodes from another profile (running in another machine aiida v 1.6.1) and then I imported it into the current profile (aiida v 2.2.2.post0)
I then tried to find the nodes, and that works okay
from aiida import orm
qb = orm.QueryBuilder()
qb.append(orm.WorkChainNode, filters={'and':[{'extras.property':{'in':['stacking_fault_energy']}}, {'attributes.process_state': {'==': 'finished'}}, {'extras': {'has_key': 'formula'}}]}, tag='workchain',
project=['uuid'])
qb.all(flat=True)
['85d22007-2aa8-4da8-a817-af98dc906621',
'731fb5fd-478a-401d-bf2d-a95a48681e6c']
I then tried to get which code I used for this workchains and suddenly I only get one node, instead of two
from aiida import orm
qb = orm.QueryBuilder()
qb.append(orm.WorkChainNode, filters={'and':[{'extras.property':{'in':['stacking_fault_energy']}}, {'attributes.process_state': {'==': 'finished'}}, {'extras': {'has_key': 'formula'}}]}, tag='workchain',
project=['uuid'])
qb.append(orm.Code, with_outgoing='workchain', project=['uuid'])
qb.all(flat=True)
['731fb5fd-478a-401d-bf2d-a95a48681e6c',
'f82964d2-ee74-4d9e-9088-a897884ca793']
This is unexpected, since if I check each workchain I use a different code. Even stranger if I look if there are input structures I get an empty result
from aiida import orm
qb = orm.QueryBuilder()
qb.append(orm.WorkChainNode, filters={'and':[{'extras.property':{'in':['stacking_fault_energy']}}, {'attributes.process_state': {'==': 'finished'}}, {'extras': {'has_key': 'formula'}}]}, tag='workchain',
project=['uuid'])
qb.append(orm.StructureData, with_outgoing='workchain', project=['uuid'])
qb.all(flat=True)
[]
When I inspect each node, I can see that they clearly have codes and structure nodes
node = load_node('731fb5fd-478a-401d-bf2d-a95a48681e6c')
incoming = node.get_incoming()
print(incoming.get_node_by_label('code'))
print(incoming.get_node_by_label('initial_structure'))
Remote code 'vasp-5.4.4-std-intel-hpc' on moggie (Imported #1) pk: 21736, uuid: f82964d2-ee74-4d9e-9088-a897884ca793
uuid: a09c6b09-cdd8-446d-bede-33e211450f97 (pk: 112171)
What is even stranger if I do the query in a way in which I do not ask explicitly for orm.Code
or orm.StructureData
but instead for nodes which have attributes that match then ones from those types of nodes, then I do get the information that I want
qb = orm.QueryBuilder()
qb.append(orm.Node, tag='structure', filters={'attributes':{'has_key':'cell'}}, project=['uuid'])
qb.append(orm.WorkChainNode, filters={'and':[{'extras.property':{'in':['stacking_fault_energy']}}, {'attributes.process_state': {'==': 'finished'}}, {'extras': {'has_key': 'formula'}}]}, tag='workchain'
, with_incoming='structure', project=['uuid'])
qb.all()
[['cee1ac28-af23-4244-8f2f-7e45002628c5',
'85d22007-2aa8-4da8-a817-af98dc906621'],
['ab04a00f-6541-4621-b54f-1578ce55c871',
'85d22007-2aa8-4da8-a817-af98dc906621'],
['4ca3b4eb-6156-48ff-a4a3-23b4a4e4bd74',
'85d22007-2aa8-4da8-a817-af98dc906621'],
['a09c6b09-cdd8-446d-bede-33e211450f97',
'731fb5fd-478a-401d-bf2d-a95a48681e6c']]
So this leads me to suspect that for some reason when the import was done some information about which kind of node is associated with this inputs was lost. Has someone experienced a similar behavior?
Thanks!