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 May 16, 2024
1 parent 210c40b commit 0566c7a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/aiida_quantumespresso/workflows/pw/bands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
11 changes: 11 additions & 0 deletions src/aiida_quantumespresso/workflows/pw/base.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)

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

0 comments on commit 0566c7a

Please sign in to comment.