From 6a2d5a5f5e1d367e8dbd7e4d4dd479dd9851c479 Mon Sep 17 00:00:00 2001 From: Fabio Lopes Date: Tue, 7 May 2024 15:36:36 +0200 Subject: [PATCH] Connection to openBIS --- aiidalab_widgets_base/elns.py | 31 ++++++++++++++++++++++++++++- aiidalab_widgets_base/structures.py | 2 +- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/aiidalab_widgets_base/elns.py b/aiidalab_widgets_base/elns.py index 08c34f7df..badf3a04e 100644 --- a/aiidalab_widgets_base/elns.py +++ b/aiidalab_widgets_base/elns.py @@ -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}..." diff --git a/aiidalab_widgets_base/structures.py b/aiidalab_widgets_base/structures.py index 8514d01d8..c591d18da 100644 --- a/aiidalab_widgets_base/structures.py +++ b/aiidalab_widgets_base/structures.py @@ -221,7 +221,7 @@ def store_structure(self, _=None): ): # Make a link between self.input_structure and self.structure_node @engine.calcfunction - def user_modifications(_source_structure): + def user_modifications(): return self.structure_node structure_node = user_modifications(self.input_structure)