From 585229f7543a454a9c969e9d6780cfb990e05e96 Mon Sep 17 00:00:00 2001 From: Xing Wang Date: Mon, 8 Apr 2024 16:27:46 +0200 Subject: [PATCH 1/2] add reminder text when users selecting property (#663) * add reminder text when users select property --- src/aiidalab_qe/app/configuration/workflow.py | 19 ++++++++++++++++++- src/aiidalab_qe/common/panel.py | 2 +- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/aiidalab_qe/app/configuration/workflow.py b/src/aiidalab_qe/app/configuration/workflow.py index c7ccd5001..6a34f727f 100644 --- a/src/aiidalab_qe/app/configuration/workflow.py +++ b/src/aiidalab_qe/app/configuration/workflow.py @@ -94,9 +94,26 @@ def __init__(self, **kwargs): ipw.HTML("Select which properties to calculate:"), ] entries = get_entry_items("aiidalab_qe.properties", "outline") + setting_entries = get_entry_items("aiidalab_qe.properties", "setting") for name, entry_point in entries.items(): self.properties[name] = entry_point() - self.property_children.append(self.properties[name]) + if name in setting_entries: + reminder_text = ipw.HTML() + self.property_children.append( + ipw.HBox([self.properties[name], reminder_text]) + ) + + # observer change to update the reminder text + def update_reminder_text(change, reminder_text=reminder_text, name=name): + if change["new"]: + reminder_text.value = ( + f"""Customize {name} settings in the panel above if needed.""" + ) + else: + reminder_text.value = "" + + self.properties[name].run.observe(update_reminder_text, "value") + self.property_children.append(self.properties_help) self.children = [ self.structure_title, diff --git a/src/aiidalab_qe/common/panel.py b/src/aiidalab_qe/common/panel.py index ca414cb6b..bd6fdcfdc 100644 --- a/src/aiidalab_qe/common/panel.py +++ b/src/aiidalab_qe/common/panel.py @@ -72,7 +72,7 @@ def __init__(self, **kwargs): description=self.title, indent=False, value=False, - layout=ipw.Layout(max_width="50%"), + style={"description_width": "initial"}, ) self.description_html = ipw.HTML( f"""
From 8da3db97e0be6451c2f9d4f5b04780f9e31b825f Mon Sep 17 00:00:00 2001 From: Xing Wang Date: Mon, 8 Apr 2024 17:07:07 +0200 Subject: [PATCH 2/2] assgin clean_workdir to plugin's builder (#667) * assgin clean_workdir to plugin's builder * check if the plugin has a clean_workdir input --- src/aiidalab_qe/plugins/bands/workchain.py | 2 +- src/aiidalab_qe/plugins/pdos/workchain.py | 2 +- src/aiidalab_qe/plugins/xas/workchain.py | 2 +- src/aiidalab_qe/plugins/xps/workchain.py | 2 +- src/aiidalab_qe/workflows/__init__.py | 12 +++++++----- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/aiidalab_qe/plugins/bands/workchain.py b/src/aiidalab_qe/plugins/bands/workchain.py index e60c611f4..9f7bd7d0e 100644 --- a/src/aiidalab_qe/plugins/bands/workchain.py +++ b/src/aiidalab_qe/plugins/bands/workchain.py @@ -227,6 +227,6 @@ def get_builder(codes, structure, parameters, **kwargs): workchain_and_builder = { "workchain": PwBandsWorkChain, - "exclude": ("clean_workdir", "structure", "relax"), + "exclude": ("structure", "relax"), "get_builder": get_builder, } diff --git a/src/aiidalab_qe/plugins/pdos/workchain.py b/src/aiidalab_qe/plugins/pdos/workchain.py index b0c8325e7..4dd5fd665 100644 --- a/src/aiidalab_qe/plugins/pdos/workchain.py +++ b/src/aiidalab_qe/plugins/pdos/workchain.py @@ -80,6 +80,6 @@ def get_builder(codes, structure, parameters, **kwargs): workchain_and_builder = { "workchain": PdosWorkChain, - "exclude": ("clean_workdir", "structure", "relax"), + "exclude": ("structure", "relax"), "get_builder": get_builder, } diff --git a/src/aiidalab_qe/plugins/xas/workchain.py b/src/aiidalab_qe/plugins/xas/workchain.py index bfd175053..0c08ce431 100644 --- a/src/aiidalab_qe/plugins/xas/workchain.py +++ b/src/aiidalab_qe/plugins/xas/workchain.py @@ -106,6 +106,6 @@ def get_builder(codes, structure, parameters, **kwargs): workchain_and_builder = { "workchain": XspectraCrystalWorkChain, - "exclude": ("clean_workdir", "structure", "relax"), + "exclude": ("structure", "relax"), "get_builder": get_builder, } diff --git a/src/aiidalab_qe/plugins/xps/workchain.py b/src/aiidalab_qe/plugins/xps/workchain.py index a58dce82c..238215d62 100644 --- a/src/aiidalab_qe/plugins/xps/workchain.py +++ b/src/aiidalab_qe/plugins/xps/workchain.py @@ -100,6 +100,6 @@ def get_builder(codes, structure, parameters, **kwargs): workchain_and_builder = { "workchain": XpsWorkChain, - "exclude": ("clean_workdir", "structure", "relax"), + "exclude": ("structure", "relax"), "get_builder": get_builder, } diff --git a/src/aiidalab_qe/workflows/__init__.py b/src/aiidalab_qe/workflows/__init__.py index c2d002815..093484d0e 100644 --- a/src/aiidalab_qe/workflows/__init__.py +++ b/src/aiidalab_qe/workflows/__init__.py @@ -158,21 +158,23 @@ def get_builder_from_protocol( if properties is None: properties = [] builder.properties = orm.List(list=properties) + # clean workdir + clean_workdir = orm.Bool(parameters["advanced"]["clean_workdir"]) + builder.clean_workdir = clean_workdir # add plugin workchain for name, entry_point in plugin_entries.items(): if name in properties: plugin_builder = entry_point["get_builder"]( codes, structure, copy.deepcopy(parameters), **kwargs ) + # check if the plugin has a clean_workdir input + plugin_workchain = entry_point["workchain"] + if plugin_workchain.spec().has_input("clean_workdir"): + plugin_builder.clean_workdir = clean_workdir setattr(builder, name, plugin_builder) else: builder.pop(name, None) - # XXX (unkcpz) I smell not proper design here since I have to look at - # configuration step to know what show be set here. - clean_workdir = parameters["advanced"]["clean_workdir"] - builder.clean_workdir = orm.Bool(clean_workdir) - return builder def setup(self):