diff --git a/src/aiida_quantumespresso_hp/workflows/hubbard.py b/src/aiida_quantumespresso_hp/workflows/hubbard.py index 533beb7..05a3dc6 100644 --- a/src/aiida_quantumespresso_hp/workflows/hubbard.py +++ b/src/aiida_quantumespresso_hp/workflows/hubbard.py @@ -159,6 +159,9 @@ def define(cls, spec): if_(cls.should_check_convergence)( cls.check_convergence, ), + if_(cls.should_clean_workdir)( + cls.clean_iteration, + ) ), cls.run_results, ) @@ -646,14 +649,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: