Skip to content

Commit

Permalink
PwBaseWorkChain: deprecate the pseudo_family input
Browse files Browse the repository at this point in the history
The use of a `pseudo_family`, which has to be passed in as a `Str` node
to represent the name of a `Group`, is not robust with respect to the
provenance. Since groups are mutable, rerunning a workchain that used
the `pseudo_family` to determine what pseudos to run, can lead to a
rerun using different pseudos. This input exists for historical reasons
because it made the usage of the workflows easier for users, since they
wouldn't have to build the mapping of pseudos themselves, but with the
advent of `aiida-pseudo` and the input generators, this is no longer an
issue and it is preferable to directly pass the pseudos into the
`pseudos` input namespace.

Also deprecate the functions in `utils.pseudopotential`, one of which is
not even used currently, and the other two which will be obsolete as
they are replaced by method directly integrated into the pseudo family
groups.
  • Loading branch information
sphuber committed Oct 29, 2020
1 parent ced373e commit cf79742
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
8 changes: 8 additions & 0 deletions aiida_quantumespresso/utils/pseudopotential.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-
"""Utilities for pseudo potentials."""
import warnings
from aiida.common.warnings import AiidaDeprecationWarning
from aiida.orm.nodes.data.upf import UpfData, get_pseudos_from_structure


Expand All @@ -26,6 +28,8 @@ def validate_and_prepare_pseudos_inputs(structure, pseudos=None, pseudo_family=N
"""
from aiida.orm import Str

warnings.warn('this function is deprecated and will be removed in `v4.0.0`.', AiidaDeprecationWarning)

if pseudos and pseudo_family:
raise ValueError('you cannot specify both "pseudos" and "pseudo_family"')
elif pseudos is None and pseudo_family is None:
Expand Down Expand Up @@ -55,6 +59,8 @@ def get_pseudos_of_calc(calc):
"""
from aiida.common.links import LinkType

warnings.warn('this function is deprecated and will be removed in `v4.0.0`.', AiidaDeprecationWarning)

pseudos = {}
# I create here a dictionary that associates each kind name to a pseudo
inputs = calc.get_incoming(link_type=LinkType.INPUT_CALC)
Expand Down Expand Up @@ -89,6 +95,8 @@ def get_pseudos_from_dict(structure, pseudos_uuids):
from aiida.common import NotExistent
from aiida.orm import load_node

warnings.warn('this function is deprecated and will be removed in `v4.0.0`.', AiidaDeprecationWarning)

pseudo_list = {}
for kind in structure.kinds:
symbol = kind.symbol
Expand Down
16 changes: 12 additions & 4 deletions aiida_quantumespresso/workflows/pw/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@
PwCalculation = CalculationFactory('quantumespresso.pw')


def validate_pseudo_family(value, _):
"""Validate the `pseudo_family` input."""
if value is not None:
import warnings
from aiida.common.warnings import AiidaDeprecationWarning
warnings.warn('`pseudo_family` is deprecated, use `pw.pseudos` instead.', AiidaDeprecationWarning)


class PwBaseWorkChain(BaseRestartWorkChain):
"""Workchain to run a Quantum ESPRESSO pw.x calculation with automated error handling and restarts."""

Expand Down Expand Up @@ -48,10 +56,10 @@ def define(cls, spec):
help='Optional input when constructing the k-points based on a desired `kpoints_distance`. Setting this to '
'`True` will force the k-point mesh to have an even number of points along each lattice vector except '
'for any non-periodic directions.')
spec.input('pseudo_family', valid_type=orm.Str, required=False,
help='An alternative to specifying the pseudo potentials manually in `pseudos`: one can specify the name '
'of an existing pseudo potential family and the work chain will generate the pseudos automatically '
'based on the input structure.')
spec.input('pseudo_family', valid_type=orm.Str, required=False, validator=validate_pseudo_family,
help='[Deprecated: use `pw.pseudos` instead] An alternative to specifying the pseudo potentials manually in'
' `pseudos`: one can specify the name of an existing pseudo potential family and the work chain will '
'generate the pseudos automatically based on the input structure.')
spec.input('automatic_parallelization', valid_type=orm.Dict, required=False,
help='When defined, the work chain will first launch an initialization calculation to determine the '
'dimensions of the problem, and based on this it will try to set optimal parallelization flags.')
Expand Down

0 comments on commit cf79742

Please sign in to comment.