diff --git a/src/aiida_quantumespresso_hp/workflows/hubbard.py b/src/aiida_quantumespresso_hp/workflows/hubbard.py index 7ea2506..529c982 100644 --- a/src/aiida_quantumespresso_hp/workflows/hubbard.py +++ b/src/aiida_quantumespresso_hp/workflows/hubbard.py @@ -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)( @@ -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', @@ -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: