Skip to content

Commit

Permalink
Connection to openBIS
Browse files Browse the repository at this point in the history
  • Loading branch information
fabioacl committed May 27, 2024
1 parent ba5b169 commit 5bb6900
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion aiidalab_widgets_base/elns.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,39 @@ def _observe_node(self, _=None):
)
info = q.all(flat=True)[0]
except IndexError:
info = {}
structures, _ = self.get_all_structures_and_geoopts(self.node)
info = structures[-1].base.extras.all["eln"]

self.eln.set_sample_config(**info)

def get_all_structures_and_geoopts(self, node):
"""Get all atomistic models that led to the one used in the simulation"""
current_node = node
all_structures = []
all_geoopts = []

while current_node is not None:
if isinstance(current_node, orm.StructureData):
all_structures.append(current_node)
current_node = current_node.creator

elif isinstance(current_node, orm.CalcJobNode):
current_node = current_node.caller

elif isinstance(current_node, orm.CalcFunctionNode):
current_node = current_node.inputs.source_structure

elif isinstance(current_node, orm.WorkChainNode):
if "GeoOpt" in current_node.label:
all_geoopts.append(current_node)
current_node = current_node.inputs.structure
elif "ORBITALS" in current_node.label or "STM" in current_node.label:
current_node = current_node.inputs.structure
else:
current_node = current_node.caller

return all_structures, all_geoopts

def send_to_eln(self, _=None):
if self.eln and self.eln.is_connected:
self.message.value = f"\u29d7 Sending data to {self.eln.eln_instance}..."
Expand Down

0 comments on commit 5bb6900

Please sign in to comment.