From 201cdac39d32c8a9a70845c929ba6e82664471f5 Mon Sep 17 00:00:00 2001 From: Marnik Bercx Date: Wed, 20 Dec 2023 17:53:28 +0100 Subject: [PATCH] =?UTF-8?q?=E2=80=BC=EF=B8=8F=20Prioritize=20the=20`order?= =?UTF-8?q?=5Fby`=20approach=20to=20sorting=20submissions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently the `order_by` field of the `FromGroupSubmissionController` does not actually work as intented for default `submit_new_batch` calls, since it will sort the `extras_to_run` again after the extras "to submit" are obtained. Moreover, the `get_all_extras_to_submit` method of the `FromGroupSubmissionController` would return the extras as a set, instead of the list obtained by the ordered query. Here we set the `sort` input argument of the `submit_new_batch()` method to `False` by default. This is technically a backwards-incompatible change, although any impact on users should be minor since it only changes the order of submission. --- aiida_submission_controller/base.py | 4 ++-- aiida_submission_controller/from_group.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/aiida_submission_controller/base.py b/aiida_submission_controller/base.py index f6319c8..4095e70 100644 --- a/aiida_submission_controller/base.py +++ b/aiida_submission_controller/base.py @@ -152,14 +152,14 @@ def num_available_slots(self): @property def num_to_run(self): """Number of processes that still have to be submitted.""" - return len(self.get_all_extras_to_submit().difference(self._check_submitted_extras())) + return len(set(self.get_all_extras_to_submit()).difference(self._check_submitted_extras())) @property 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=True, verbose=False): + def submit_new_batch(self, dry_run=False, sort=False, 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 diff --git a/aiida_submission_controller/from_group.py b/aiida_submission_controller/from_group.py index b7a9908..1eea6a2 100644 --- a/aiida_submission_controller/from_group.py +++ b/aiida_submission_controller/from_group.py @@ -83,4 +83,4 @@ def get_all_extras_to_submit(self): results_set = set(results) assert len(results) == len(results_set), "There are duplicate extras in the parent group" - return results_set + return results