From 0566c7a556dcb433970efe977c6fd0e7a0d4b2ee 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 | 3 +++ src/aiida_quantumespresso/workflows/pw/base.py | 11 +++++++++++ src/aiida_quantumespresso/workflows/pw/relax.py | 3 +++ 3 files changed, 17 insertions(+) diff --git a/src/aiida_quantumespresso/workflows/pw/bands.py b/src/aiida_quantumespresso/workflows/pw/bands.py index d4d0a32ef..ecd754359 100644 --- a/src/aiida_quantumespresso/workflows/pw/bands.py +++ b/src/aiida_quantumespresso/workflows/pw/bands.py @@ -123,6 +123,9 @@ def get_protocol_filepath(cls): 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. :param protocol: protocol to use, if not specified, the default will be used. diff --git a/src/aiida_quantumespresso/workflows/pw/base.py b/src/aiida_quantumespresso/workflows/pw/base.py index 4a3ab0381..edd1d557b 100644 --- a/src/aiida_quantumespresso/workflows/pw/base.py +++ b/src/aiida_quantumespresso/workflows/pw/base.py @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- """Workchain to run a Quantum ESPRESSO pw.x calculation with automated error handling and restarts.""" +import warnings + from aiida import orm from aiida.common import AttributeDict, exceptions from aiida.common.lang import type_check @@ -117,6 +119,9 @@ 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. :param protocol: protocol to use, if not specified, the default will be used. @@ -208,6 +213,12 @@ 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) diff --git a/src/aiida_quantumespresso/workflows/pw/relax.py b/src/aiida_quantumespresso/workflows/pw/relax.py index 2888a3e36..c9329aa8c 100644 --- a/src/aiida_quantumespresso/workflows/pw/relax.py +++ b/src/aiida_quantumespresso/workflows/pw/relax.py @@ -90,6 +90,9 @@ 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. :param protocol: protocol to use, if not specified, the default will be used.