Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add clean-up button to control the remote work directory clean #497

Merged
merged 4 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions src/aiidalab_qe/app/configuration/advanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ class AdvancedSettings(Panel):
"""<div style="padding-top: 0px; padding-bottom: 10px">
<h4>Advanced Settings</h4></div>"""
)
description = ipw.HTML("""Select the advanced settings for the <b>pw.x</b> code.""")
pw_adv_description = ipw.HTML(
"""Select the advanced settings for the <b>pw.x</b> code."""
)
kpoints_description = ipw.HTML(
"""<div>
The k-points mesh density of the SCF calculation is set by the <b>protocol</b>.
Expand All @@ -47,6 +49,18 @@ class AdvancedSettings(Panel):
def __init__(self, default_protocol=None, **kwargs):
self._default_protocol = default_protocol or DEFAULT_PARAMETERS["protocol"]

# clean-up workchain settings
self.clean_workdir = ipw.Checkbox(
description="",
indent=False,
value=True,
layout=ipw.Layout(max_width="20px"),
)
self.clean_workdir_description = ipw.HTML(
"""<div style="line-height: 140%; padding-top: 0px; padding-bottom: 5px">
Tick to clean-up the work directory after the calculation is finished.</div>"""
)

# Override setting widget
self.override_prompt = ipw.HTML("<b>&nbsp;&nbsp;Override&nbsp;</b>")
self.override = ipw.Checkbox(
Expand Down Expand Up @@ -120,7 +134,11 @@ def __init__(self, default_protocol=None, **kwargs):
self.children = [
self.title,
ipw.HBox(
[self.description, self.override_widget],
[self.clean_workdir, self.clean_workdir_description],
layout=ipw.Layout(height="50px", justify_content="flex-start"),
),
ipw.HBox(
[self.pw_adv_description, self.override_widget],
layout=ipw.Layout(height="50px", justify_content="space-between"),
),
# total charge setting widget
Expand Down Expand Up @@ -193,6 +211,7 @@ def update_settings(self, **kwargs):

def get_panel_value(self):
# create the the initial_magnetic_moments as None (Default)
# XXX: start from parameters = {} and then bundle the settings by purposes (e.g. pw, bands, etc.)
parameters = {
"initial_magnetic_moments": None,
"pw": {
Expand All @@ -201,6 +220,10 @@ def get_panel_value(self):
},
},
}
# add clean_workdir to the parameters
parameters["clean_workdir"] = self.clean_workdir.value

# add the pseudo_family to the parameters
parameters["pseudo_family"] = self.pseudo_family_selector.value
if self.pseudo_setter.pseudos:
parameters["pw"]["pseudos"] = self.pseudo_setter.pseudos
Expand Down
6 changes: 4 additions & 2 deletions src/aiidalab_qe/workflows/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def define(cls, spec):
super().define(spec)
spec.input('structure', valid_type=StructureData,
help='The inputs structure.')
spec.input('clean_workdir', valid_type=orm.Bool, default=lambda: orm.Bool(False),
spec.input('clean_workdir', valid_type=orm.Bool, default=lambda: orm.Bool(True),
help='If `True`, work directories of all called calculation will be cleaned at the end of execution.')
spec.input('properties', valid_type=orm.List, default=lambda: orm.List(),
help='The properties to calculate, used to control the logic of QeAppWorkChain.')
Expand Down Expand Up @@ -111,7 +111,6 @@ def get_builder_from_protocol(
cls,
structure,
parameters=None,
clean_workdir=False,
**kwargs,
):
"""Return a builder prepopulated with inputs selected according to the chosen protocol."""
Expand Down Expand Up @@ -161,6 +160,9 @@ def get_builder_from_protocol(
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
Expand Down
4 changes: 1 addition & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def _smearing_settings_generator(**kwargs):


@pytest.fixture
def app(pw_code, dos_code, projwfc_code, sssp):
def app(pw_code, dos_code, projwfc_code):
from aiidalab_qe.app.main import App

app = App(qe_auto_setup=False)
Expand Down Expand Up @@ -321,8 +321,6 @@ def app(pw_code, dos_code, projwfc_code, sssp):
def submit_app_generator(
app,
generate_structure_data,
workchain_settings_generator,
smearing_settings_generator,
):
"""Return a function that generates a submit step widget."""

Expand Down
1 change: 0 additions & 1 deletion tests/test_configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ def test_get_configuration_parameters():

wg = ConfigureQeAppWorkChainStep()
parameters = wg.get_configuration_parameters()
print("parameters:", parameters)
parameters_ref = {
"workchain": wg.workchain_settings.get_panel_value(),
"advanced": wg.advanced_settings.get_panel_value(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ bands:
tot_charge: 0.0
pseudos:
Si: Si.upf
clean_workdir: false
clean_workdir: true
pdos:
dos:
parameters:
Expand Down