Skip to content

Commit

Permalink
First steps to make protocols scheduler agnostic.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
t-reents committed Feb 19, 2024
1 parent d645069 commit 844efbb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/aiida_quantumespresso/workflows/pw/bands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
11 changes: 10 additions & 1 deletion src/aiida_quantumespresso/workflows/pw/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/aiida_quantumespresso/workflows/pw/relax.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 844efbb

Please sign in to comment.