Skip to content

Commit

Permalink
Add warning to other workflows
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
t-reents committed May 16, 2024
1 parent 0566c7a commit e5f1148
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/aiida_quantumespresso/workflows/pdos.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 10 additions & 0 deletions src/aiida_quantumespresso/workflows/ph/base.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions src/aiida_quantumespresso/workflows/xps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
11 changes: 11 additions & 0 deletions src/aiida_quantumespresso/workflows/xspectra/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 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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions src/aiida_quantumespresso/workflows/xspectra/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions src/aiida_quantumespresso/workflows/xspectra/crystal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit e5f1148

Please sign in to comment.