From 844efbb980c9938702e6d3d8cb63a96a7c366dc1 Mon Sep 17 00:00:00 2001 From: t-reents Date: Mon, 19 Feb 2024 10:59:06 +0100 Subject: [PATCH] First steps to make protocols scheduler agnostic. The current protocols implicitly rely on the `Slurm` scheduler by specifying the number of machines in `metadata.options.resources`. This can cause problems when using different schedulers in combination with `get_builder_from_protocol`. Here, we add this information to the documentation and add a warning that the options need to be explicitly specified in future versions. --- src/aiida_quantumespresso/workflows/pw/bands.py | 2 ++ src/aiida_quantumespresso/workflows/pw/base.py | 11 ++++++++++- src/aiida_quantumespresso/workflows/pw/relax.py | 2 ++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/aiida_quantumespresso/workflows/pw/bands.py b/src/aiida_quantumespresso/workflows/pw/bands.py index e6c5f77cc..a90607cd4 100644 --- a/src/aiida_quantumespresso/workflows/pw/bands.py +++ b/src/aiida_quantumespresso/workflows/pw/bands.py @@ -122,6 +122,8 @@ def get_protocol_filepath(cls): @classmethod def get_builder_from_protocol(cls, code, structure, protocol=None, overrides=None, options=None, **kwargs): """Return a builder prepopulated with inputs selected according to the chosen protocol. + The current protocols rely on the `Slurm` scheduler. To use them nonetheless with a different scheduler, the + protocols might need to be adjusted and explicit resources need to be provided in `options`. :param code: the ``Code`` instance configured for the ``quantumespresso.pw`` plugin. :param structure: the ``StructureData`` instance to use. diff --git a/src/aiida_quantumespresso/workflows/pw/base.py b/src/aiida_quantumespresso/workflows/pw/base.py index 4a3ab0381..7b36b3d70 100644 --- a/src/aiida_quantumespresso/workflows/pw/base.py +++ b/src/aiida_quantumespresso/workflows/pw/base.py @@ -9,6 +9,7 @@ from aiida_quantumespresso.calculations.functions.create_kpoints_from_distance import create_kpoints_from_distance from aiida_quantumespresso.common.types import ElectronicType, RestartType, SpinType from aiida_quantumespresso.utils.defaults.calculation import pw as qe_defaults +import warnings from ..protocols.utils import ProtocolMixin @@ -116,6 +117,8 @@ def get_builder_from_protocol( **_ ): """Return a builder prepopulated with inputs selected according to the chosen protocol. + The current protocols rely on the `Slurm` scheduler. To use them nonetheless with a different scheduler, the + protocols might need to be adjusted and explicit resources need to be provided in `options`. :param code: the ``Code`` instance configured for the ``quantumespresso.pw`` plugin. :param structure: the ``StructureData`` instance to use. @@ -208,9 +211,15 @@ def get_builder_from_protocol( metadata = inputs['pw']['metadata'] + if not options or options.get('resources', None) is None: + warnings.warn( + 'No explicit resources were provided for `metadata.options.resources`. This approach is ' + 'deprecated and will cause an error in future versions.', UserWarning + ) + if options: metadata['options'] = recursive_merge(inputs['pw']['metadata']['options'], options) - + # pylint: disable=no-member builder = cls.get_builder() builder.pw['code'] = code diff --git a/src/aiida_quantumespresso/workflows/pw/relax.py b/src/aiida_quantumespresso/workflows/pw/relax.py index 2888a3e36..e8071ee39 100644 --- a/src/aiida_quantumespresso/workflows/pw/relax.py +++ b/src/aiida_quantumespresso/workflows/pw/relax.py @@ -89,6 +89,8 @@ def get_builder_from_protocol( **kwargs ): """Return a builder prepopulated with inputs selected according to the chosen protocol. + The current protocols rely on the `Slurm` scheduler. To use them nonetheless with a different scheduler, the + protocols might need to be adjusted and explicit resources need to be provided in `options`. :param code: the ``Code`` instance configured for the ``quantumespresso.pw`` plugin. :param structure: the ``StructureData`` instance to use.