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

Dependencies: update the aiida-pseudo requirements #609

Merged
merged 1 commit into from
Nov 17, 2020
Merged
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
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ good-names = [
'i',
'j',
'k',
'SsspFamily',
'StructureData',
'UpfData',
'HpCalculation',
'PwCalculation',
Expand Down
2 changes: 1 addition & 1 deletion setup.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
},
"install_requires": [
"aiida_core[atomic_tools]~=1.4,>=1.4.2",
"aiida-pseudo~=0.1",
"aiida-pseudo~=0.3",
"packaging",
"qe-tools~=2.0rc1",
"xmlschema~=1.2,>=1.2.5",
Expand Down
8 changes: 2 additions & 6 deletions tests/cli/calculations/test_cp.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
# -*- coding: utf-8 -*-
"""Tests for the ``calculation launch cp`` command."""
import pytest

from aiida_quantumespresso.cli.calculations.cp import launch_calculation


@pytest.mark.usefixtures('clear_database_before_test')
def test_command_base(run_cli_process_launch_command, fixture_code, generate_upf_family):
def test_command_base(run_cli_process_launch_command, fixture_code, sssp):
"""Test invoking the calculation launch command with only required inputs."""
code = fixture_code('quantumespresso.cp').store()
family = generate_upf_family()
options = ['-X', code.full_label, '-F', family.label]
options = ['-X', code.full_label, '-F', sssp.label]
run_cli_process_launch_command(launch_calculation, options=options)
3 changes: 0 additions & 3 deletions tests/cli/calculations/test_dos.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# -*- coding: utf-8 -*-
"""Tests for the ``calculation launch dos`` command."""
import pytest

from aiida_quantumespresso.cli.calculations.dos import launch_calculation


@pytest.mark.usefixtures('clear_database_before_test')
def test_command_base(run_cli_process_launch_command, fixture_code, generate_calc_job_node):
"""Test invoking the calculation launch command with only required inputs."""
code = fixture_code('quantumespresso.dos').store()
Expand Down
3 changes: 0 additions & 3 deletions tests/cli/calculations/test_epw.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# -*- coding: utf-8 -*-
"""Tests for the ``calculation launch epw`` command."""
import pytest

from aiida_quantumespresso.cli.calculations.epw import launch_calculation


@pytest.mark.usefixtures('clear_database_before_test')
def test_command_base(run_cli_process_launch_command, fixture_code, generate_calc_job_node):
"""Test invoking the calculation launch command with only required inputs."""
code = fixture_code('quantumespresso.epw').store()
Expand Down
3 changes: 0 additions & 3 deletions tests/cli/calculations/test_matdyn.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# -*- coding: utf-8 -*-
"""Tests for the ``calculation launch matdyn`` command."""
import pytest

from aiida_quantumespresso.cli.calculations.matdyn import launch_calculation


@pytest.mark.usefixtures('clear_database_before_test')
def test_command_base(run_cli_process_launch_command, fixture_code, generate_force_constants_data):
"""Test invoking the calculation launch command with only required inputs."""
code = fixture_code('quantumespresso.matdyn').store()
Expand Down
8 changes: 2 additions & 6 deletions tests/cli/calculations/test_neb.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
# -*- coding: utf-8 -*-
"""Tests for the ``calculation launch neb`` command."""
import pytest

from aiida_quantumespresso.cli.calculations.neb import launch_calculation


@pytest.mark.usefixtures('clear_database_before_test')
def test_command_base(run_cli_process_launch_command, fixture_code, generate_upf_family, generate_structure):
def test_command_base(run_cli_process_launch_command, fixture_code, sssp, generate_structure):
"""Test invoking the calculation launch command with only required inputs."""
code = fixture_code('quantumespresso.neb').store()
family = generate_upf_family()
structures = [generate_structure().store().pk, generate_structure().store().pk]
options = ['-X', code.full_label, '-F', family.label, '-s'] + structures
options = ['-X', code.full_label, '-F', sssp.label, '-s'] + structures
run_cli_process_launch_command(launch_calculation, options=options)
3 changes: 0 additions & 3 deletions tests/cli/calculations/test_ph.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# -*- coding: utf-8 -*-
"""Tests for the ``calculation launch ph`` command."""
import pytest

from aiida_quantumespresso.cli.calculations.ph import launch_calculation


@pytest.mark.usefixtures('clear_database_before_test')
def test_command_base(run_cli_process_launch_command, fixture_code, generate_calc_job_node):
"""Test invoking the calculation launch command with only required inputs."""
code = fixture_code('quantumespresso.ph').store()
Expand Down
3 changes: 0 additions & 3 deletions tests/cli/calculations/test_pp.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# -*- coding: utf-8 -*-
"""Tests for the ``calculation launch pp`` command."""
import pytest

from aiida_quantumespresso.cli.calculations.pp import launch_calculation


@pytest.mark.usefixtures('clear_database_before_test')
def test_command_base(run_cli_process_launch_command, fixture_code, generate_calc_job_node):
"""Test invoking the calculation launch command with only required inputs."""
code = fixture_code('quantumespresso.pp').store()
Expand Down
3 changes: 0 additions & 3 deletions tests/cli/calculations/test_projwfc.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# -*- coding: utf-8 -*-
"""Tests for the ``calculation launch projwfc`` command."""
import pytest

from aiida_quantumespresso.cli.calculations.projwfc import launch_calculation


@pytest.mark.usefixtures('clear_database_before_test')
def test_command_base(run_cli_process_launch_command, fixture_code, generate_calc_job_node):
"""Test invoking the calculation launch command with only required inputs."""
code = fixture_code('quantumespresso.projwfc').store()
Expand Down
8 changes: 2 additions & 6 deletions tests/cli/calculations/test_pw.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
# -*- coding: utf-8 -*-
"""Tests for the ``calculation launch pw`` command."""
import pytest

from aiida_quantumespresso.cli.calculations.pw import launch_calculation


@pytest.mark.usefixtures('clear_database_before_test')
def test_command_base(run_cli_process_launch_command, fixture_code, generate_upf_family):
def test_command_base(run_cli_process_launch_command, fixture_code, sssp):
"""Test invoking the calculation launch command with only required inputs."""
code = fixture_code('quantumespresso.pw').store()
family = generate_upf_family()
options = ['-X', code.full_label, '-F', family.label]
options = ['-X', code.full_label, '-F', sssp.label]
run_cli_process_launch_command(launch_calculation, options=options)
2 changes: 0 additions & 2 deletions tests/cli/calculations/test_pw2wannier90.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
"""Tests for the ``calculation launch pw2wannier90`` command."""
import io

import pytest
from aiida.orm import SinglefileData

from aiida_quantumespresso.cli.calculations.pw2wannier90 import launch_calculation


@pytest.mark.usefixtures('clear_database_before_test')
def test_command_base(run_cli_process_launch_command, fixture_code, generate_calc_job_node):
"""Test invoking the calculation launch command with only required inputs."""
code = fixture_code('quantumespresso.pw2wannier90').store()
Expand Down
3 changes: 0 additions & 3 deletions tests/cli/calculations/test_q2r.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# -*- coding: utf-8 -*-
"""Tests for the ``calculation launch q2r`` command."""
import pytest

from aiida_quantumespresso.cli.calculations.q2r import launch_calculation


@pytest.mark.usefixtures('clear_database_before_test')
def test_command_base(run_cli_process_launch_command, fixture_code, generate_calc_job_node):
"""Test invoking the calculation launch command with only required inputs."""
code = fixture_code('quantumespresso.q2r').store()
Expand Down
8 changes: 2 additions & 6 deletions tests/cli/workflows/pw/test_bands.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
# -*- coding: utf-8 -*-
"""Tests for the ``workflow launch pw-bands`` command."""
import pytest

from aiida_quantumespresso.cli.workflows.pw.bands import launch_workflow


@pytest.mark.usefixtures('clear_database_before_test')
def test_command_base(run_cli_process_launch_command, fixture_code, generate_upf_family, generate_structure):
def test_command_base(run_cli_process_launch_command, fixture_code, sssp, generate_structure):
"""Test invoking the workflow launch command with only required inputs."""
code = fixture_code('quantumespresso.pw').store()
family = generate_upf_family()
options = ['-X', code.full_label, '-F', family.label, '-S', generate_structure().store().pk]
options = ['-X', code.full_label, '-F', sssp.label, '-S', generate_structure().store().pk]
run_cli_process_launch_command(launch_workflow, options=options)
8 changes: 2 additions & 6 deletions tests/cli/workflows/pw/test_base.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
# -*- coding: utf-8 -*-
"""Tests for the ``workflow launch pw-base`` command."""
import pytest

from aiida_quantumespresso.cli.workflows.pw.base import launch_workflow


@pytest.mark.usefixtures('clear_database_before_test')
def test_command_base(run_cli_process_launch_command, fixture_code, generate_upf_family):
def test_command_base(run_cli_process_launch_command, fixture_code, sssp):
"""Test invoking the workflow launch command with only required inputs."""
code = fixture_code('quantumespresso.pw').store()
family = generate_upf_family()
options = ['-X', code.full_label, '-F', family.label]
options = ['-X', code.full_label, '-F', sssp.label]
run_cli_process_launch_command(launch_workflow, options=options)
8 changes: 2 additions & 6 deletions tests/cli/workflows/pw/test_relax.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
# -*- coding: utf-8 -*-
"""Tests for the ``workflow launch pw-relax`` command."""
import pytest

from aiida_quantumespresso.cli.workflows.pw.relax import launch_workflow


@pytest.mark.usefixtures('clear_database_before_test')
def test_command_base(run_cli_process_launch_command, fixture_code, generate_upf_family, generate_structure):
def test_command_base(run_cli_process_launch_command, fixture_code, generate_structure, sssp):
"""Test invoking the workflow launch command with only required inputs."""
code = fixture_code('quantumespresso.pw').store()
family = generate_upf_family()
options = ['-X', code.full_label, '-F', family.label, '-S', generate_structure().store().pk]
options = ['-X', code.full_label, '-F', sssp.label, '-S', generate_structure().store().pk]
run_cli_process_launch_command(launch_workflow, options=options)
3 changes: 0 additions & 3 deletions tests/cli/workflows/test_matdyn.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# -*- coding: utf-8 -*-
"""Tests for the ``calculation launch matdyn`` command."""
import pytest

from aiida_quantumespresso.cli.calculations.matdyn import launch_calculation


@pytest.mark.usefixtures('clear_database_before_test')
def test_command_base(run_cli_process_launch_command, fixture_code, generate_force_constants_data):
"""Test invoking the calculation launch command with only required inputs."""
code = fixture_code('quantumespresso.matdyn').store()
Expand Down
3 changes: 0 additions & 3 deletions tests/cli/workflows/test_ph.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# -*- coding: utf-8 -*-
"""Tests for the ``calculation launch ph`` command."""
import pytest

from aiida_quantumespresso.cli.calculations.ph import launch_calculation


@pytest.mark.usefixtures('clear_database_before_test')
def test_command_base(run_cli_process_launch_command, fixture_code, generate_calc_job_node):
"""Test invoking the calculation launch command with only required inputs."""
code = fixture_code('quantumespresso.ph').store()
Expand Down
2 changes: 0 additions & 2 deletions tests/cli/workflows/test_q2r.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# -*- coding: utf-8 -*-
"""Tests for the ``calculation launch q2r`` command."""
import pytest

from aiida_quantumespresso.cli.calculations.q2r import launch_calculation


@pytest.mark.usefixtures('clear_database_before_test')
def test_command_base(run_cli_process_launch_command, fixture_code, generate_calc_job_node):
"""Test invoking the calculation launch command with only required inputs."""
code = fixture_code('quantumespresso.q2r').store()
Expand Down
53 changes: 50 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import collections
import os
import shutil
import tempfile

import pytest

Expand Down Expand Up @@ -48,12 +49,57 @@ def fixture_code(fixture_localhost):
"""Return a `Code` instance configured to run calculations of given entry point on localhost `Computer`."""

def _fixture_code(entry_point_name):
from aiida.common import exceptions
from aiida.orm import Code
return Code(input_plugin_name=entry_point_name, remote_computer_exec=[fixture_localhost, '/bin/true'])

label = f'test.{entry_point_name}'

try:
return Code.objects.get(label=label) # pylint: disable=no-member
except exceptions.NotExistent:
return Code(
label=label,
input_plugin_name=entry_point_name,
remote_computer_exec=[fixture_localhost, '/bin/true'],
)

return _fixture_code


@pytest.fixture(scope='session', autouse=True)
def sssp(aiida_profile, generate_upf_data):
"""Create an SSSP pseudo potential family from scratch."""
from aiida.common.constants import elements
from aiida.plugins import GroupFactory

aiida_profile.reset_db()

SsspFamily = GroupFactory('pseudo.family.sssp')

cutoffs = {'standard': {}}

with tempfile.TemporaryDirectory() as dirpath:
for values in elements.values():

element = values['symbol']
upf = generate_upf_data(element)
filename = os.path.join(dirpath, f'{element}.upf')

with open(filename, 'w+b') as handle:
with upf.open(mode='rb') as source:
handle.write(source.read())
handle.flush()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just out of curiosity: why do we flush the file handle here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to make sure it is written to disk, but I think it is not actually necessary here, since by the time the file will be used, it is outside of this context manager, the closing of which should guarantee the flushing as well.


cutoffs['standard'][element] = {'cutoff_wfc': 30., 'cutoff_rho': 240.}

label = 'SSSP/1.1/PBE/efficiency'
family = SsspFamily.create_from_folder(dirpath, label)

family.set_cutoffs(cutoffs)

return family


@pytest.fixture
def generate_calc_job():
"""Fixture to construct a new `CalcJob` instance and call `prepare_for_submission` for testing `CalcJob` classes.
Expand Down Expand Up @@ -197,7 +243,8 @@ def _generate_upf_data(element):
from aiida_pseudo.data.pseudo import UpfData

with open(tmp_path_factory.mktemp('pseudos') / f'{element}.upf', 'w+b') as handle:
handle.write(f'<UPF version="2.0.1"><PP_HEADER element="{element}"/></UPF>\n'.encode('utf-8'))
content = f'<UPF version="2.0.1"><PP_HEADER\nelement="{element}"\nz_valence="1.0"\n/></UPF>\n'
handle.write(content.encode('utf-8'))
handle.flush()
return UpfData(file=handle)

Expand Down Expand Up @@ -226,7 +273,7 @@ def _generate_upf_family(label='family', elements=('Si',)):
cutoffs[element] = {'cutoff_wfc': 1.0, 'cutoff_rho': 2.0}

family = UpfFamily.create_from_folder(str(tmp_path), label)
family.set_cutoffs(cutoffs)
family.set_cutoffs({'standard': cutoffs})

return family

Expand Down
5 changes: 4 additions & 1 deletion tests/fixtures/pseudos/Si.upf
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
<UPF version="2.0.1"><PP_HEADER element="Si"/></UPF>
<UPF version="2.0.1"><PP_HEADER
element="Si"
z_valence="1.0"
/></UPF>