From 2039c89ff07261d6799537a6a2fc12d586a6abc8 Mon Sep 17 00:00:00 2001 From: Marnik Bercx Date: Fri, 10 Jan 2025 19:45:53 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20default=20`unique=5Fextra?= =?UTF-8?q?=5Fkeys`=20value?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The current default value of `None` for the `unique_extra_keys` in the `BaseSubmissionController` is not a valid approach for setting the default. For `BaseSubmissionController`s, the user should still specify the unique extra keys, since they can't be derived from a parent node. For the `FromGroupSubmissionController`, it is sensible to use the `_aiida_hash` as a default value, instead of `None`. --- aiida_submission_controller/base.py | 3 +-- aiida_submission_controller/from_group.py | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/aiida_submission_controller/base.py b/aiida_submission_controller/base.py index a314fb2..80d13c0 100644 --- a/aiida_submission_controller/base.py +++ b/aiida_submission_controller/base.py @@ -3,7 +3,6 @@ import abc import logging import time -from typing import Optional from aiida import engine, orm from aiida.common import NotExistent @@ -54,7 +53,7 @@ class BaseSubmissionController(BaseModel): """Label of the group to store the process nodes in.""" max_concurrent: int """Maximum concurrent active processes.""" - unique_extra_keys: Optional[tuple] = None + unique_extra_keys: tuple """Tuple of keys defined in the extras that uniquely define each process to be run.""" _validate_group_exists = field_validator("group_label")(validate_group_exists) diff --git a/aiida_submission_controller/from_group.py b/aiida_submission_controller/from_group.py index da92944..f96219a 100644 --- a/aiida_submission_controller/from_group.py +++ b/aiida_submission_controller/from_group.py @@ -15,6 +15,8 @@ class FromGroupSubmissionController(BaseSubmissionController): # pylint: disabl and define the abstract methods. """ + unique_extra_keys: Optional[tuple] = ("_aiida_hash",) + """Tuple of keys defined in the extras that uniquely define each process to be run.""" parent_group_label: str """Label of the parent group from which to construct the process inputs.""" filters: Optional[dict] = None