From 5c520124cab8a5de3bfc2abc9086b0c349e884e2 Mon Sep 17 00:00:00 2001 From: t-reents Date: Wed, 6 Mar 2024 09:59:23 +0100 Subject: [PATCH 1/4] Remove language version for black pre-commit hook --- .pre-commit-config.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e94b567..be8d691 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -30,7 +30,6 @@ repos: rev: 23.3.0 hooks: - id: black - language_version: python3.9 - repo: https://github.com/charliermarsh/ruff-pre-commit rev: 'v0.0.262' From 5791f429610d36cb821e5a63f195364c7e5640a7 Mon Sep 17 00:00:00 2001 From: t-reents Date: Wed, 6 Mar 2024 09:10:09 +0100 Subject: [PATCH 2/4] Add optional delay between submissions Closes #11 --- aiida_submission_controller/base.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/aiida_submission_controller/base.py b/aiida_submission_controller/base.py index 3a51bcb..e6fbba1 100644 --- a/aiida_submission_controller/base.py +++ b/aiida_submission_controller/base.py @@ -2,6 +2,7 @@ """A prototype class to submit processes in batches, avoiding to submit too many.""" import abc import logging +import time from typing import Optional from aiida import engine, orm @@ -178,7 +179,7 @@ def num_already_run(self): """Number of processes that have already been submitted (and might or might not have finished).""" return len(self._check_submitted_extras()) - def submit_new_batch(self, dry_run=False, sort=False, verbose=False): + def submit_new_batch(self, dry_run=False, sort=False, verbose=False, sleep=0): """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 @@ -239,6 +240,8 @@ def submit_new_batch(self, dry_run=False, sort=False, verbose=False): wc_node.set_extra_many(get_extras_dict(self.get_extra_unique_keys(), workchain_extras)) self.group.add_nodes([wc_node]) submitted[workchain_extras] = wc_node + # Only add a delay if the submission was successful + time.sleep(sleep) return submitted From 888b65644cd6bb7a8aedd108cc52e11d489cb748 Mon Sep 17 00:00:00 2001 From: t-reents Date: Wed, 6 Mar 2024 09:12:36 +0100 Subject: [PATCH 3/4] Fix `submit_new_batch` when `verbose = True` The `submit_new_batch` method fails if `verbose` is set to `True`, as it refers to the `parent_group` to get the total number of submissions. When using the `BaseSubmissionController`, this attribute is not specified. To fix the `verbose` option for the `BaseSubmissionController` and `FromGroupSubmissionController`, the number of submissions is defined by the number of `all extras to `submit`. --- aiida_submission_controller/base.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/aiida_submission_controller/base.py b/aiida_submission_controller/base.py index e6fbba1..15096f5 100644 --- a/aiida_submission_controller/base.py +++ b/aiida_submission_controller/base.py @@ -183,7 +183,8 @@ def submit_new_batch(self, dry_run=False, sort=False, verbose=False, sleep=0): """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 - extras_to_run = list(set(self.get_all_extras_to_submit()).difference(self._check_submitted_extras())) + all_extras = set(self.get_all_extras_to_submit()) + extras_to_run = list(all_extras.difference(self._check_submitted_extras())) if sort: extras_to_run = sorted(extras_to_run) @@ -204,7 +205,7 @@ def submit_new_batch(self, dry_run=False, sort=False, verbose=False, sleep=0): table.add_column("Available", justify="left", style="cyan", no_wrap=True) table.add_row( - str(self.parent_group.count()), + str(len(all_extras)), str(self.num_already_run), str(self.num_to_run), str(self.max_concurrent), From bcd0f0ff92acef2d5005892df366347040c25784 Mon Sep 17 00:00:00 2001 From: Timo Reents Date: Wed, 22 May 2024 12:18:45 +0200 Subject: [PATCH 4/4] Fix number of submitted `WorkChain`s Currently, the number of submitted `WorkChain`s is determined by the number of available slots. This is not the expected behavior, as this number might be unequal to 0, causing a logging message that states that `n` `WorkChain`s have been submitted, even though no processes were left. --- aiida_submission_controller/base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aiida_submission_controller/base.py b/aiida_submission_controller/base.py index 15096f5..af3c837 100644 --- a/aiida_submission_controller/base.py +++ b/aiida_submission_controller/base.py @@ -215,10 +215,10 @@ def submit_new_batch(self, dry_run=False, sort=False, verbose=False, sleep=0): console = Console() console.print(table) - if number_to_submit <= 0: + if number_to_submit <= 0 or self.num_to_run == 0: print("[bold blue]Info:[/] 😴 Nothing to submit.") else: - print(f"[bold blue]Info:[/] 🚀 Submitting {number_to_submit} new workchains!") + print(f"[bold blue]Info:[/] 🚀 Submitting {min(number_to_submit, self.num_to_run)} new workchains!") submitted = {}