From e5f11489e5cc3b0770943e8580e69312e159a59f Mon Sep 17 00:00:00 2001 From: Timo Reents Date: Thu, 16 May 2024 10:25:02 +0200 Subject: [PATCH] Add warning to other workflows In addition to the previous changes to the `pw` `WorkChain`s, this commit adds a warning to all the other `WorkChain`s that provide the `get_builder_from_protcol` method. --- src/aiida_quantumespresso/workflows/pdos.py | 3 +++ src/aiida_quantumespresso/workflows/ph/base.py | 10 ++++++++++ src/aiida_quantumespresso/workflows/xps.py | 3 +++ src/aiida_quantumespresso/workflows/xspectra/base.py | 11 +++++++++++ src/aiida_quantumespresso/workflows/xspectra/core.py | 3 +++ .../workflows/xspectra/crystal.py | 3 +++ 6 files changed, 33 insertions(+) diff --git a/src/aiida_quantumespresso/workflows/pdos.py b/src/aiida_quantumespresso/workflows/pdos.py index 311d8237f..21f9d58bb 100644 --- a/src/aiida_quantumespresso/workflows/pdos.py +++ b/src/aiida_quantumespresso/workflows/pdos.py @@ -319,6 +319,9 @@ def get_builder_from_protocol( cls, pw_code, dos_code, projwfc_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 pw_code: the ``Code`` instance configured for the ``quantumespresso.pw`` plugin. :param dos_code: the ``Code`` instance configured for the ``quantumespresso.dos`` plugin. diff --git a/src/aiida_quantumespresso/workflows/ph/base.py b/src/aiida_quantumespresso/workflows/ph/base.py index a1ad3def8..db8518ae7 100644 --- a/src/aiida_quantumespresso/workflows/ph/base.py +++ b/src/aiida_quantumespresso/workflows/ph/base.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- """Workchain to run a Quantum ESPRESSO ph.x calculation with automated error handling and restarts.""" from typing import Mapping +import warnings from aiida import orm from aiida.common import AttributeDict @@ -96,6 +97,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.ph`` plugin. :param protocol: protocol to use, if not specified, the default will be used. @@ -122,6 +126,12 @@ def get_builder_from_protocol( inputs['ph']['parameters']['INPUTPH']['epsil'] = True metadata = inputs['ph']['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['ph']['metadata']['options'], options) diff --git a/src/aiida_quantumespresso/workflows/xps.py b/src/aiida_quantumespresso/workflows/xps.py index ed4fdc01b..fb9b23c7e 100644 --- a/src/aiida_quantumespresso/workflows/xps.py +++ b/src/aiida_quantumespresso/workflows/xps.py @@ -380,6 +380,9 @@ def get_builder_from_protocol( structure_preparation_settings=None, correction_energies=None, **kwargs ): # pylint: disable=too-many-statements """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/xspectra/base.py b/src/aiida_quantumespresso/workflows/xspectra/base.py index 59cea6a00..8ef7c422d 100644 --- a/src/aiida_quantumespresso/workflows/xspectra/base.py +++ b/src/aiida_quantumespresso/workflows/xspectra/base.py @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- """Workchain to run a Quantum ESPRESSO xspectra.x calculation with automated error handling and restarts.""" +import warnings + from aiida import orm from aiida.common import AttributeDict from aiida.common.lang import type_check @@ -78,6 +80,9 @@ def get_builder_from_protocol( cls, code, core_wfc_data, parent_folder, abs_atom_marker='X', protocol=None, overrides=None, options=None, **_ ): """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.xspectra`` plugin. :param core_wfc_data: a ``SinglefileData`` object for the initial-state core @@ -105,6 +110,12 @@ def get_builder_from_protocol( metadata = inputs['xspectra']['metadata'] parameters = inputs['xspectra']['parameters'] + + 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['xspectra']['metadata']['options'], options) diff --git a/src/aiida_quantumespresso/workflows/xspectra/core.py b/src/aiida_quantumespresso/workflows/xspectra/core.py index 377ea378c..1efcb266e 100644 --- a/src/aiida_quantumespresso/workflows/xspectra/core.py +++ b/src/aiida_quantumespresso/workflows/xspectra/core.py @@ -305,6 +305,9 @@ 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 pw_code: the ``Code`` instance configured for the ``quantumespresso.pw`` plugin. diff --git a/src/aiida_quantumespresso/workflows/xspectra/crystal.py b/src/aiida_quantumespresso/workflows/xspectra/crystal.py index 1d56a50f9..c6a8bca16 100644 --- a/src/aiida_quantumespresso/workflows/xspectra/crystal.py +++ b/src/aiida_quantumespresso/workflows/xspectra/crystal.py @@ -267,6 +267,9 @@ def get_builder_from_protocol( # pylint: disable=too-many-statements options=None, **kwargs ): # pylint: enable:too-many-statments """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 pw_code: the ``Code`` instance configured for the ``quantumespresso.pw`` plugin.