Skip to content

Commit

Permalink
First round of review
Browse files Browse the repository at this point in the history
  • Loading branch information
mbercx committed Oct 10, 2022
1 parent e22b5e7 commit 54028cc
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
4 changes: 2 additions & 2 deletions docs/source/design.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ A pseudopotential family is only considered to be *established* when it has a co

Only a pseudopotential family that is *established* will receive support for automated installs with its own class (e.g. :py:class:`~aiida_pseudo.groups.family.SsspFamily`/:py:class:`~aiida_pseudo.groups.family.PseudoDojoFamily`) and command line interface (CLI) commands (e.g. ``install sssp``/``install pseudo-dojo``).
To make sure these families represent the official ones, they can only be installed with their supported CLI commands, and there are strict checks on the format of these files to make sure they correspond to the official ones.
Based on the same principle of preserving the integrity of these established pseudopotentials, the ``family cutoffs set`` command can not be used to set the recommended cutoffs of an established family.
Based on the same principle of preserving the integrity of these established pseudopotentials, the ``family cutoffs set`` command cannot be used to set the recommended cutoffs of an established family.

If users want to install the a set of *non-established* pseudopotentials and configure their recommended cutoffs, they have to install them from the archive using ``install family`` as a :py:class:`~aiida_pseudo.groups.family.CutoffsPseudoPotentialFamily` as described in the :ref:`corresponding how-to section <how-to:install_archive>`.
To install a set of *non-established* pseudopotentials and configure their recommended cutoffs, install them from the archive using ``install family`` as a :py:class:`~aiida_pseudo.groups.family.CutoffsPseudoPotentialFamily` as described in the :ref:`corresponding how-to section <how-to:install_archive>`.

Recommended cutoffs
===================
Expand Down
2 changes: 1 addition & 1 deletion src/aiida_pseudo/cli/family.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def cmd_family_cutoffs():

@cmd_family_cutoffs.command('set')
@arguments.PSEUDO_POTENTIAL_FAMILY(
type=types.PseudoPotentialFamilyParam(exclude=('pseudo.family.sssp', 'pseudo.family.pseudo_dojo'))
type=types.PseudoPotentialFamilyParam(blacklist=('pseudo.family.sssp', 'pseudo.family.pseudo_dojo'))
)
@click.argument('cutoffs', type=click.File(mode='rb'))
@options.STRINGENCY(required=True)
Expand Down
2 changes: 1 addition & 1 deletion src/aiida_pseudo/cli/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def cmd_install():
@options_core.DESCRIPTION(help='Description for the family.')
@options.ARCHIVE_FORMAT()
@options.FAMILY_TYPE(
type=types.PseudoPotentialFamilyTypeParam(exclude=('pseudo.family.sssp', 'pseudo.family.pseudo_dojo'))
type=types.PseudoPotentialFamilyTypeParam(blacklist=('pseudo.family.sssp', 'pseudo.family.pseudo_dojo'))
)
@options.PSEUDO_TYPE()
@options.TRACEBACK()
Expand Down
23 changes: 12 additions & 11 deletions src/aiida_pseudo/cli/params/types.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# -*- coding: utf-8 -*-
# pylint: disable=no-self-use
"""Custom parameter types for command line interface commands."""
from __future__ import annotations

import pathlib
import typing

from aiida.cmdline.params.types import GroupParamType
import click
Expand Down Expand Up @@ -59,13 +60,13 @@ class PseudoPotentialFamilyParam(GroupParamType):

name = 'pseudo_family'

def __init__(self, exclude: typing.Optional[typing.List[str]] = None, **kwargs):
def __init__(self, blacklist: list[str] | None = None, **kwargs):
"""Construct the parameter.
:param exclude: an optional list of values that should be considered invalid and will raise ``BadParameter``.
:param blacklist: an optional list of values that should be considered invalid and will raise ``BadParameter``.
"""
super().__init__(**kwargs)
self.exclude = exclude
self.blacklist = blacklist

def convert(self, value, param, ctx):
"""Convert the entry point name to the corresponding class.
Expand All @@ -76,7 +77,7 @@ def convert(self, value, param, ctx):
"""
family = super().convert(value, param, ctx)

if self.exclude and family.type_string in self.exclude:
if self.blacklist and family.type_string in self.blacklist:
self.fail(f'The value `{family}` is not allowed for this parameter.', param, ctx)
return family

Expand All @@ -86,13 +87,13 @@ class PseudoPotentialFamilyTypeParam(click.ParamType):

name = 'pseudo_family_type'

def __init__(self, exclude: typing.Optional[typing.List[str]] = None, **kwargs):
def __init__(self, blacklist: list[str] | None = None, **kwargs):
"""Construct the parameter.
:param exclude: an optional list of values that should be considered invalid and will raise ``BadParameter``.
:param blacklist: an optional list of values that should be considered invalid and will raise ``BadParameter``.
"""
super().__init__(**kwargs)
self.exclude = exclude
self.blacklist = blacklist

def convert(self, value, _, __):
"""Convert the entry point name to the corresponding class.
Expand All @@ -112,7 +113,7 @@ def convert(self, value, _, __):
except exceptions.EntryPointError as exception:
raise click.BadParameter(f'`{value}` is not an existing group plugin.') from exception

if self.exclude and value in self.exclude:
if self.blacklist and value in self.blacklist:
raise click.BadParameter(f'`{value}` is not an accepted value for this option.')

if not issubclass(family_type, PseudoPotentialFamily):
Expand All @@ -137,7 +138,7 @@ class PathOrUrl(click.Path):

name = 'PathOrUrl'

def convert(self, value, param, ctx) -> typing.Union[pathlib.Path, bytes]:
def convert(self, value, param, ctx) -> pathlib.Path | bytes:
"""Convert the string value to the desired value.
If the ``value`` corresponds to a valid path on the local filesystem, return it as a ``pathlib.Path`` instance.
Expand All @@ -161,7 +162,7 @@ class UnitParamType(click.ParamType):

name = 'unit'

def __init__(self, quantity: typing.Optional[typing.List[str]] = None, **kwargs):
def __init__(self, quantity: list[str] | None = None, **kwargs):
"""Construct the parameter.
:param quantity: The corresponding quantity of the unit.
Expand Down

0 comments on commit 54028cc

Please sign in to comment.