From b910171c70be9c7368f452658621f07f66e2cfad Mon Sep 17 00:00:00 2001 From: Marnik Bercx Date: Wed, 20 Dec 2023 17:26:20 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=8C=20Always=20submit=20number=20of=20?= =?UTF-8?q?requested=20processes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now that the `BaseSubmissionController` skips processes for which it is unable to obtain a populated build or submit the process, the _actual_ number of submitted process will be less than the currently available slots. This becomes especially problematic when the number of failures is equal to the number of available slots, in which case the submission controller basically stops working. Here we simply adapt the approach to loop over the `extras_to_run`, and only stop in case the length of the `submitted` dictionary is equal or greater to the number of available slots. --- aiida_submission_controller/base.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/aiida_submission_controller/base.py b/aiida_submission_controller/base.py index d63e3e6..6e104dd 100644 --- a/aiida_submission_controller/base.py +++ b/aiida_submission_controller/base.py @@ -162,23 +162,22 @@ def num_already_run(self): def submit_new_batch(self, dry_run=False, sort=True, verbose=False): """Submit a new batch of calculations, ensuring less than self.max_concurrent active at the same time.""" CMDLINE_LOGGER.level = logging.INFO if verbose else logging.WARNING - to_submit = [] + extras_to_run = set(self.get_all_extras_to_submit()).difference(self._check_submitted_extras()) + if sort: extras_to_run = sorted(extras_to_run) - for workchain_extras in extras_to_run: - if len(to_submit) + self._count_active_in_group() >= self.max_concurrent: - break - to_submit.append(workchain_extras) + + number_to_submit = self.max_concurrent - self._count_active_in_group() if dry_run: - return {key: None for key in to_submit} + return {key: None for key in extras_to_run[:number_to_submit]} if verbose: table = Table(title="Status") table.add_column("Total", justify="left", style="cyan", no_wrap=True) - table.add_column("Finished", justify="left", style="cyan", no_wrap=True) + table.add_column("Submitted", justify="left", style="cyan", no_wrap=True) table.add_column("Left to run", justify="left", style="cyan", no_wrap=True) table.add_column("Max active", justify="left", style="cyan", no_wrap=True) table.add_column("Active", justify="left", style="cyan", no_wrap=True) @@ -195,13 +194,17 @@ def submit_new_batch(self, dry_run=False, sort=True, verbose=False): console = Console() console.print(table) - if len(to_submit) == 0: + if number_to_submit <= 0: print("[bold blue]Info:[/] 😴 Nothing to submit.") else: - print(f"[bold blue]Info:[/] 🚀 Submitting {len(to_submit)} new workchains!") + print(f"[bold blue]Info:[/] 🚀 Submitting {number_to_submit} new workchains!") submitted = {} - for workchain_extras in to_submit: + + for workchain_extras in extras_to_run: + if len(submitted) >= number_to_submit: + break + try: # Get the inputs and the process calculation for submission builder = self.get_inputs_and_processclass_from_extras(workchain_extras)