Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First steps to make protocols scheduler agnostic #1011

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions docs/source/howto/workflows/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@

# Workflows

## Default parameters

The AiiDA Quantum ESPRESSO plugin comes with a set of tested protocols. These protocols define default input parameters for different levels of precision. This concept enables the initialization of a pre-populated `builder` for most of the different `WorkChain`s, which can be obtained by calling the `get_builder_from_protocol` method.

The following example shows the working principle for the `PwBaseWorkChain`:

```
# code and structure are the mandatory input arguments

builder = PwBaseWorkChain.get_builder_from_protocol(
code=pw_code, # load your pw-code
structure=structure, # provide your input structure here
)

```
We refer to the documentation of the {{ get_builder_from_protocol }} method for further details about additional default input arguments.




```{toctree}
:maxdepth: 1

Expand Down
3 changes: 3 additions & 0 deletions src/aiida_quantumespresso/workflows/pdos.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,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 pw_code: the ``Code`` instance configured for the ``quantumespresso.pw`` plugin.
:param dos_code: the ``Code`` instance configured for the ``quantumespresso.dos`` plugin.
:param projwfc_code: the ``Code`` instance configured for the ``quantumespresso.projwfc`` 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 @@ -97,6 +98,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.
:param overrides: optional dictionary of inputs to override the defaults of the protocol.
Expand All @@ -123,6 +127,12 @@ def get_builder_from_protocol(

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/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
3 changes: 3 additions & 0 deletions src/aiida_quantumespresso/workflows/xps.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,9 @@ def get_builder_from_protocol(
): # 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.
:param pseudos: the core-hole pseudopotential pairs (ground-state and
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 @@ -79,6 +81,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.xspectra`` plugin.
:param core_wfc_data: a ``SinglefileData`` object for the initial-state core
wavefunction, normally derived from upf2plotcore.sh, required
Expand Down Expand Up @@ -106,6 +111,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 @@ -306,6 +306,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 pw_code: the ``Code`` instance configured for the ``quantumespresso.pw``
plugin.
:param xs_code: the ``Code`` instance configured for the
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 @@ -268,6 +268,9 @@ def get_builder_from_protocol( # pylint: disable=too-many-statements
): # 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.
:param xs_code: the ``Code`` instance configured for the
Expand Down