Skip to content

Commit 50a3dee

Browse files
Sebastiaan Hubersphuber
authored andcommitted
Dependencies: Update requirement aiida-core~=2.1
1 parent c08c3f2 commit 50a3dee

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+230
-203
lines changed

.github/workflows/cd.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
- name: Install Python
3636
uses: actions/setup-python@v4
3737
with:
38-
python-version: '3.8'
38+
python-version: '3.9'
3939
cache: 'pip'
4040
cache-dependency-path: pyproject.toml
4141

@@ -56,7 +56,7 @@ jobs:
5656

5757
strategy:
5858
matrix:
59-
python-version: ['3.8', '3.9']
59+
python-version: ['3.9']
6060

6161
services:
6262
rabbitmq:
@@ -78,7 +78,7 @@ jobs:
7878
run: pip install -U pip wheel
7979

8080
- name: Install Python package and dependencies
81-
run: pip install -e .[tests] && reentry scan
81+
run: pip install -e .[tests]
8282

8383
- name: Run pytest
8484
run: pytest -sv tests

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- name: Install Python
1515
uses: actions/setup-python@v4
1616
with:
17-
python-version: '3.8'
17+
python-version: '3.9'
1818
cache: 'pip'
1919
cache-dependency-path: pyproject.toml
2020

@@ -34,7 +34,7 @@ jobs:
3434

3535
strategy:
3636
matrix:
37-
python-version: ['3.8', '3.9']
37+
python-version: ['3.9']
3838

3939
services:
4040
rabbitmq:
@@ -56,7 +56,7 @@ jobs:
5656
run: pip install -U pip wheel
5757

5858
- name: Install Python package and dependencies
59-
run: pip install -e .[tests] && reentry scan
59+
run: pip install -e .[tests]
6060

6161
- name: Run pytest
6262
env:

aiida_common_workflows/cli/options.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,15 @@ def convert(self, value, param, ctx):
105105
f'file `{value}` could not be parsed into a `StructureData`: {exception}'
106106
) from exception
107107

108-
duplicate = QueryBuilder().append(StructureData, filters={'extras._aiida_hash': structure._get_hash()}).first() # pylint: disable=protected-access
108+
duplicate = QueryBuilder().append(
109+
StructureData,
110+
filters={
111+
'extras._aiida_hash': structure.base.caching._get_hash() # pylint: disable=protected-access
112+
}
113+
).first()
109114

110115
if duplicate:
111-
return duplicate[0]
116+
return duplicate[0] # pylint: disable=unsubscriptable-object
112117

113118
return structure
114119

aiida_common_workflows/cli/plot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def cmd_plot_eos(workflow, precisions, print_table, output_file):
3434
echo.echo_critical(
3535
f'node {workflow.__class__.__name__}<{workflow.pk}> does not correspond to an EquationOfStateWorkChain.'
3636
)
37-
outputs = workflow.get_outgoing(link_type=LinkType.RETURN).nested()
37+
outputs = workflow.base.links.get_outgoing(link_type=LinkType.RETURN).nested()
3838

3939
missing_outputs = tuple(output for output in ('structures', 'total_energies') if output not in outputs)
4040
if missing_outputs:
@@ -107,7 +107,7 @@ def cmd_plot_dissociation_curve(workflow, precisions, print_table, output_file):
107107
echo.echo_critical(
108108
f'node {workflow.__class__.__name__}<{workflow.pk}> does not correspond to a DissociationCurveWorkChain.'
109109
)
110-
outputs = workflow.get_outgoing(link_type=LinkType.RETURN).nested()
110+
outputs = workflow.base.links.get_outgoing(link_type=LinkType.RETURN).nested()
111111

112112
missing_outputs = tuple(output for output in ('distances', 'total_energies') if output not in outputs)
113113
if missing_outputs:

aiida_common_workflows/cli/root.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# -*- coding: utf-8 -*-
22
"""Command line interface ``acwf``."""
3+
from aiida.cmdline.groups import VerdiCommandGroup
34
from aiida.cmdline.params import options, types
45
import click
56

67

7-
@click.group('acwf', context_settings={'help_option_names': ['-h', '--help']})
8-
@options.PROFILE(type=types.ProfileParamType(load_profile=True))
9-
def cmd_root(profile): # pylint: disable=unused-argument
8+
@click.group('acwf', cls=VerdiCommandGroup, context_settings={'help_option_names': ['-h', '--help']})
9+
@options.PROFILE(type=types.ProfileParamType(load_profile=True), expose_value=False)
10+
def cmd_root():
1011
"""CLI for the ``aiida-common-workflows`` plugin."""

aiida_common_workflows/cli/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def echo_process_results(node):
1616
from aiida.common.links import LinkType
1717

1818
class_name = node.process_class.__name__
19-
outputs = node.get_outgoing(link_type=(LinkType.CREATE, LinkType.RETURN)).all()
19+
outputs = node.base.links.get_outgoing(link_type=(LinkType.CREATE, LinkType.RETURN)).all()
2020

2121
if node.is_finished and node.exit_message:
2222
state = f'{node.process_state.value} [{node.exit_status}] `{node.exit_message}`'
@@ -78,13 +78,13 @@ def get_code_from_list_or_database(codes, entry_point: str):
7878
:param entry_point: calculation job entry point name.
7979
:return: a ``Code`` instance configured for the given entry point or ``None``.
8080
"""
81-
from aiida.orm import Code, QueryBuilder
81+
from aiida.orm import InstalledCode, QueryBuilder
8282

8383
for entry in codes:
84-
if entry.get_attribute('input_plugin') == entry_point:
84+
if entry.default_calc_job_plugin == entry_point:
8585
return entry
8686

87-
result = QueryBuilder().append(Code, filters={'attributes.input_plugin': entry_point}).first()
87+
result = QueryBuilder().append(InstalledCode, filters={'attributes.input_plugin': entry_point}).first()
8888

8989
if result is not None:
9090
return result[0]

aiida_common_workflows/generators/ports.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# -*- coding: utf-8 -*-
22
"""Modules with resources to define specific port types for input generator specifications."""
3+
from __future__ import annotations
4+
35
import typing as t
46

57
from aiida.engine import InputPort
@@ -30,7 +32,7 @@ def __init__(self, choices: t.Sequence[t.Any]):
3032
"""
3133
valid_types = tuple({type(choice) for choice in choices})
3234
self.choices: t.Sequence[t.Any] = choices
33-
self.valid_type: t.Tuple[t.Any] = valid_types if len(valid_types) > 1 else valid_types[0]
35+
self.valid_type: tuple[t.Any] = valid_types if len(valid_types) > 1 else valid_types[0]
3436

3537

3638
class InputGeneratorPort(InputPort):
@@ -45,7 +47,7 @@ def __init__(self, *args, valid_type=None, **kwargs) -> None:
4547
self.valid_type = valid_type
4648

4749
@Port.valid_type.setter
48-
def valid_type(self, valid_type: t.Optional[t.Any]) -> None:
50+
def valid_type(self, valid_type: t.Any | None) -> None:
4951
"""Set the valid value type for this port.
5052
5153
:param valid_type: the value valid type.
@@ -60,15 +62,15 @@ def valid_type(self, valid_type: t.Optional[t.Any]) -> None:
6062

6163
self._valid_type = valid_type
6264

63-
def validate(self, value: t.Any, breadcrumbs: t.Sequence[str] = ()) -> t.Optional[PortValidationError]:
65+
def validate(self, value: t.Any, breadcrumbs: t.Sequence[str] = ()) -> PortValidationError | None:
6466
"""Validate the value by calling the super followed by checking it against the choices if defined."""
6567
result = super().validate(value, breadcrumbs)
6668

6769
if result is not None:
6870
return result
6971

70-
if self.code_entry_point is not None and value.get_input_plugin_name() != self.code_entry_point:
71-
return f'invalid entry point `{value.get_input_plugin_name()}` for `Code{value}`.'
72+
if self.code_entry_point is not None and value.default_calc_job_plugin != self.code_entry_point:
73+
return f'invalid entry point `{value.default_calc_job_plugin}` for `Code{value}`.'
7274

7375
if value is not UNSPECIFIED and self.choices is not None and value not in self.choices:
7476
choices = [str(value) for value in self.choices]

aiida_common_workflows/generators/spec.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# -*- coding: utf-8 -*-
22
"""Class to define the specification of an input generator."""
3+
from __future__ import annotations
4+
35
import typing as t
46

57
from aiida.engine import PortNamespace
@@ -24,8 +26,7 @@ def namespace_separator(self) -> str:
2426
return self.PORT_NAMESPACE_TYPE.NAMESPACE_SEPARATOR
2527

2628
def _create_port(
27-
self, port_namespace: PortNamespace, port_class: t.Union[InputGeneratorPort, PortNamespace], name: str,
28-
**kwargs: t.Any
29+
self, port_namespace: PortNamespace, port_class: InputGeneratorPort | PortNamespace, name: str, **kwargs: t.Any
2930
) -> None:
3031
"""Create a new port of a given class and name in a given namespace.
3132

aiida_common_workflows/workflows/bands/generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def define(cls, spec):
2525
super().define(spec)
2626
spec.input(
2727
'bands_kpoints',
28-
valid_type=plugins.DataFactory('array.kpoints'),
28+
valid_type=plugins.DataFactory('core.array.kpoints'),
2929
required=True,
3030
help='The full list of kpoints where to calculate bands, in (direct) coordinates of the reciprocal space.'
3131
)

aiida_common_workflows/workflows/bands/siesta/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
from .generator import *
55
from .workchain import *
66

7-
__all__ = (generator.__all__ + workchain.__all__)
7+
__all__ = generator.__all__ + workchain.__all__

aiida_common_workflows/workflows/dissociation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ def set_distance(molecule: orm.StructureData, distance: orm.Float) -> orm.Struct
9797
versor_diff = vector_diff / np.linalg.norm(vector_diff)
9898
new_molecule = molecule.clone()
9999
new_position = (distance.value * versor_diff) / 2
100-
new_molecule.attributes['sites'][0]['position'] = -new_position
101-
new_molecule.attributes['sites'][1]['position'] = new_position
100+
new_molecule.base.attributes.get('sites')[0]['position'] = -new_position
101+
new_molecule.base.attributes.get('sites')[1]['position'] = new_position
102102
return new_molecule
103103

104104

aiida_common_workflows/workflows/relax/abinit/extractors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ def get_ts_energy(common_relax_workchain: AbinitCommonRelaxWorkChain) -> float:
2424
if common_relax_workchain.process_class != AbinitCommonRelaxWorkChain:
2525
return ValueError('The input workchain is not a `AbinitCommonRelaxWorkChain`')
2626

27-
abinit_base_wc = common_relax_workchain.get_outgoing(link_type=LinkType.CALL_WORK).one().node
27+
abinit_base_wc = common_relax_workchain.base.links.get_outgoing(link_type=LinkType.CALL_WORK).one().node
2828
return -abinit_base_wc.outputs.output_parameters['e_entropy']

aiida_common_workflows/workflows/relax/abinit/generator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
__all__ = ('AbinitCommonRelaxInputGenerator',)
2121

22-
StructureData = plugins.DataFactory('structure')
22+
StructureData = plugins.DataFactory('core.structure')
2323

2424

2525
class AbinitCommonRelaxInputGenerator(CommonRelaxInputGenerator):
@@ -34,7 +34,7 @@ def __init__(self, *args, **kwargs):
3434

3535
def _initialize_protocols(self):
3636
"""Initialize the protocols class attribute by parsing them from the configuration file."""
37-
with open(str(pathlib.Path(__file__).parent / 'protocol.yml')) as handle:
37+
with open(str(pathlib.Path(__file__).parent / 'protocol.yml'), encoding='utf-8') as handle:
3838
self._protocols = yaml.safe_load(handle)
3939

4040
@classmethod
@@ -76,7 +76,7 @@ def _construct_builder(self, **kwargs) -> engine.ProcessBuilder:
7676

7777
pseudo_family_label = protocol.pop('pseudo_family')
7878
try:
79-
pseudo_family = orm.Group.objects.get(label=pseudo_family_label)
79+
pseudo_family = orm.Group.collection.get(label=pseudo_family_label)
8080
except exceptions.NotExistent as exception:
8181
raise ValueError(
8282
f'required pseudo family `{pseudo_family_label}` is not installed. '

aiida_common_workflows/workflows/relax/abinit/workchain.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,22 @@
1818
def get_stress(parameters):
1919
"""Return the stress array from the given parameters node."""
2020
stress = orm.ArrayData()
21-
stress.set_array(name='stress', array=np.array(parameters.get_attribute('cart_stress_tensor')) * GPA_TO_EV_A3)
21+
stress.set_array(name='stress', array=np.array(parameters.base.attributes.get('cart_stress_tensor')) * GPA_TO_EV_A3)
2222
return stress
2323

2424

2525
@calcfunction
2626
def get_forces(parameters):
2727
"""Return the forces array from the given parameters node."""
2828
forces = orm.ArrayData()
29-
forces.set_array(name='forces', array=np.array(parameters.get_attribute('forces')))
29+
forces.set_array(name='forces', array=np.array(parameters.base.attributes.get('forces')))
3030
return forces
3131

3232

3333
@calcfunction
3434
def get_total_energy(parameters):
3535
"""Return the total energy from the given parameters node."""
36-
return orm.Float(parameters.get_attribute('energy'))
36+
return orm.Float(parameters.base.attributes.get('energy'))
3737

3838

3939
@calcfunction

aiida_common_workflows/workflows/relax/bigdft/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
from .generator import *
55
from .workchain import *
66

7-
__all__ = (generator.__all__ + workchain.__all__)
7+
__all__ = generator.__all__ + workchain.__all__

aiida_common_workflows/workflows/relax/bigdft/generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
__all__ = ('BigDftCommonRelaxInputGenerator',)
1111

1212
BigDFTParameters = plugins.DataFactory('bigdft')
13-
StructureData = plugins.DataFactory('structure')
13+
StructureData = plugins.DataFactory('core.structure')
1414

1515

1616
class BigDftCommonRelaxInputGenerator(CommonRelaxInputGenerator):

aiida_common_workflows/workflows/relax/castep/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
from .generator import *
55
from .workchain import *
66

7-
__all__ = (generator.__all__ + workchain.__all__)
7+
__all__ = generator.__all__ + workchain.__all__

aiida_common_workflows/workflows/relax/castep/extractors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def get_ts_energy(common_relax_workchain):
2828
if common_relax_workchain.process_class != CastepCommonRelaxWorkChain:
2929
return ValueError('The input workchain is not a `CastepCommonRelaxWorkChain`')
3030

31-
castep_base_wc = common_relax_workchain.get_outgoing(link_type=LinkType.CALL_WORK).one().node
31+
castep_base_wc = common_relax_workchain.base.links.get_outgoing(link_type=LinkType.CALL_WORK).one().node
3232
e_ks = castep_base_wc.outputs.output_parameters['total energy']
3333
free_e = castep_base_wc.outputs.output_parameters['free energy']
3434

aiida_common_workflows/workflows/relax/castep/generator.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
__all__ = ('CastepCommonRelaxInputGenerator',)
2424

25-
StructureData = plugins.DataFactory('structure') # pylint: disable=invalid-name
25+
StructureData = plugins.DataFactory('core.structure') # pylint: disable=invalid-name
2626

2727

2828
class CastepCommonRelaxInputGenerator(CommonRelaxInputGenerator):
@@ -37,7 +37,7 @@ def __init__(self, *args, **kwargs):
3737

3838
def _initialize_protocols(self):
3939
"""Initialize the protocols class attribute by parsing them from the configuration file."""
40-
with open(str(pathlib.Path(__file__).parent / 'protocol.yml')) as handle:
40+
with open(str(pathlib.Path(__file__).parent / 'protocol.yml'), encoding='utf-8') as handle:
4141
self._protocols = yaml.safe_load(handle)
4242

4343
@classmethod
@@ -170,7 +170,7 @@ def _construct_builder(self, **kwargs) -> engine.ProcessBuilder:
170170
# this is because the small basis set will give rise to errors in EOS / variable volume
171171
# relaxation even with the "fine" option
172172
if 'cut_off_energy' not in protocol['relax']['base']['calc']['parameters']:
173-
with open(str(pathlib.Path(__file__).parent / 'soft_elements.yml')) as fhandle:
173+
with open(str(pathlib.Path(__file__).parent / 'soft_elements.yml'), encoding='utf-8') as fhandle:
174174
soft_elements = yaml.safe_load(fhandle)
175175
symbols = [kind.symbol for kind in structure.kinds]
176176
if all(sym in soft_elements for sym in symbols):
@@ -256,13 +256,11 @@ def generate_inputs(
256256
if isinstance(family_name, orm.Str):
257257
family_name = family_name.value
258258
try:
259-
otfg_family = OTFGGroup.objects.get(label=family_name)
259+
otfg_family = OTFGGroup.collection.get(label=family_name)
260260
except exceptions.NotExistent as exc:
261-
raise ValueError(
262-
'protocol `{}` requires the `{}` `pseudos family` but could not be found.'.format(
263-
protocol['name'], protocol['relax']['base']['pseudos_family']
264-
)
265-
) from exc
261+
name = protocol['name']
262+
family = protocol['relax']['base']['pseudos_family']
263+
raise ValueError(f'protocol `{name}` requires the `{family}` `pseudos family` but could not be found.') from exc
266264

267265
CastepCalculation = plugins.CalculationFactory('castep.castep') # pylint: disable=invalid-name
268266
CastepBaseWorkChain = plugins.WorkflowFactory('castep.base') # pylint: disable=invalid-name
@@ -426,7 +424,7 @@ def ensure_otfg_family(family_name, force_update=False):
426424
if isinstance(family_name, orm.Str):
427425
family_name = family_name.value
428426
try:
429-
OTFGGroup.objects.get(label=family_name)
427+
OTFGGroup.collection.get(label=family_name)
430428
except NotExistent:
431429
has_family = False
432430
else:
@@ -441,7 +439,7 @@ def ensure_otfg_family(family_name, force_update=False):
441439

442440
# Not an known family - check if it in the additional settings list
443441
# Load configuration from the settings
444-
with open(str(pathlib.Path(__file__).parent / 'additional_otfg_families.yml')) as handle:
442+
with open(str(pathlib.Path(__file__).parent / 'additional_otfg_families.yml'), encoding='utf-8') as handle:
445443
additional = yaml.safe_load(handle)
446444

447445
if family_name in additional:

aiida_common_workflows/workflows/relax/castep/workchain.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def get_free_energy(parameters):
5353
Return the free energy from the given parameters node.
5454
The free energy reported by CASTEP is the one that is consistent with the forces.
5555
"""
56-
return orm.Float(parameters.get_attribute('free_energy'))
56+
return orm.Float(parameters.base.attributes.get('free_energy'))
5757

5858

5959
@calcfunction
@@ -62,7 +62,7 @@ def get_total_magnetization(parameters):
6262
Return the free energy from the given parameters node.
6363
The free energy reported by CASTEP is the one that is consistent with the forces.
6464
"""
65-
return orm.Float(parameters.get_attribute('spin_density'))
65+
return orm.Float(parameters.base.attributes.get('spin_density'))
6666

6767

6868
class CastepCommonRelaxWorkChain(CommonRelaxWorkChain):

aiida_common_workflows/workflows/relax/cp2k/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
from .generator import *
55
from .workchain import *
66

7-
__all__ = (generator.__all__ + workchain.__all__)
7+
__all__ = generator.__all__ + workchain.__all__

0 commit comments

Comments
 (0)