Skip to content

Commit

Permalink
Feat: clean the workdirs at each iteration (#47)
Browse files Browse the repository at this point in the history
Modify the `SelfConsistentHubbardWorkChain`
to clean the work directories at each iteration instead
of cleaning everything at the end, eventually saving
lots of storage space. This may be crucial for large scale
calculations or for users with low disk availability.
  • Loading branch information
bastonero authored Dec 6, 2023
1 parent a61f2bf commit 0ebfd5d
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/aiida_quantumespresso_hp/workflows/hubbard.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ def define(cls, spec):
spec.inputs.validator = validate_inputs
spec.inputs['hubbard']['hp'].validator = None

# yapf: disable
spec.outline(
cls.setup,
while_(cls.should_run_iteration)(
Expand All @@ -188,10 +189,16 @@ def define(cls, spec):
),
cls.run_hp,
cls.inspect_hp,
if_(cls.should_check_convergence)(cls.check_convergence,),
if_(cls.should_check_convergence)(
cls.check_convergence,
),
if_(cls.should_clean_workdir)(
cls.clean_iteration,
)
),
cls.run_results,
)
# yapf: enable

spec.output(
'hubbard_structure',
Expand Down Expand Up @@ -673,14 +680,12 @@ def run_results(self):
self.report(f'Hubbard parameters self-consistently converged in {self.ctx.iteration} iterations')
self.out('hubbard_structure', self.ctx.current_hubbard_structure)

def on_terminated(self):
"""Clean the working directories of all child calculations if `clean_workdir=True` in the inputs."""
super().on_terminated()

if self.inputs.clean_workdir.value is False:
self.report('remote folders will not be cleaned')
return
def should_clean_workdir(self):
"""Whether to clean the work directories at each iteration."""
return self.inputs.clean_workdir.value

def clean_iteration(self):
"""Clean all work directiories of the current iteration."""
cleaned_calcs = []

for called_descendant in self.node.called_descendants:
Expand Down

0 comments on commit 0ebfd5d

Please sign in to comment.