Skip to content

Commit 5bb6900

Browse files
committed
Connection to openBIS
1 parent ba5b169 commit 5bb6900

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

aiidalab_widgets_base/elns.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,39 @@ def _observe_node(self, _=None):
141141
)
142142
info = q.all(flat=True)[0]
143143
except IndexError:
144-
info = {}
144+
structures, _ = self.get_all_structures_and_geoopts(self.node)
145+
info = structures[-1].base.extras.all["eln"]
145146

146147
self.eln.set_sample_config(**info)
147148

149+
def get_all_structures_and_geoopts(self, node):
150+
"""Get all atomistic models that led to the one used in the simulation"""
151+
current_node = node
152+
all_structures = []
153+
all_geoopts = []
154+
155+
while current_node is not None:
156+
if isinstance(current_node, orm.StructureData):
157+
all_structures.append(current_node)
158+
current_node = current_node.creator
159+
160+
elif isinstance(current_node, orm.CalcJobNode):
161+
current_node = current_node.caller
162+
163+
elif isinstance(current_node, orm.CalcFunctionNode):
164+
current_node = current_node.inputs.source_structure
165+
166+
elif isinstance(current_node, orm.WorkChainNode):
167+
if "GeoOpt" in current_node.label:
168+
all_geoopts.append(current_node)
169+
current_node = current_node.inputs.structure
170+
elif "ORBITALS" in current_node.label or "STM" in current_node.label:
171+
current_node = current_node.inputs.structure
172+
else:
173+
current_node = current_node.caller
174+
175+
return all_structures, all_geoopts
176+
148177
def send_to_eln(self, _=None):
149178
if self.eln and self.eln.is_connected:
150179
self.message.value = f"\u29d7 Sending data to {self.eln.eln_instance}..."

0 commit comments

Comments
 (0)