Skip to content

Commit

Permalink
pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
unkcpz committed Nov 4, 2023
1 parent 0806377 commit 706ae68
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ COPY scripts/60-pseudo-code-setup.sh /etc/init/run-before-daemon-start/
RUN mkdir -p /opt/examples
COPY _static/ /opt/examples

USER ${SYSTEM_UID}
USER ${SYSTEM_UID}
2 changes: 1 addition & 1 deletion .docker/docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ target "aiida-quantumespresso" {
args = {
"QE_VERSION" = "${QE_VERSION}"
}
}
}
2 changes: 1 addition & 1 deletion .docker/scripts/60-pseudo-code-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ for code_name in pw ph; do
done

# Import example structures
verdi data core.structure import ase /opt/examples/Si.cif
verdi data core.structure import ase /opt/examples/Si.cif
21 changes: 10 additions & 11 deletions .docker/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,19 @@ def docker_compose(docker_services):
# pylint: disable=protected-access
return docker_services._docker_compose


def is_container_ready(dodkec_compose):
output = dodkec_compose.execute('exec -T aiida verdi status').decode().strip()
return 'Connected to RabbitMQ' in output and 'Daemon is running' in output


@pytest.fixture(scope='session', autouse=True)
def _docker_service_wait(docker_services):
"""Container startup wait."""
docker_compose = docker_services._docker_compose

docker_services.wait_until_responsive(
timeout=120.0, pause=0.1, check=lambda: is_container_ready(docker_compose)
)

docker_services.wait_until_responsive(timeout=120.0, pause=0.1, check=lambda: is_container_ready(docker_compose))


@pytest.fixture
def container_user():
Expand All @@ -46,16 +47,14 @@ def execute(command, user=None, **kwargs):

return execute


@pytest.fixture
def qe_version(aiida_exec):
info = json.loads(
aiida_exec(
"mamba list -n base --json --full-name qe"
).decode()
)[0]
info = json.loads(aiida_exec('mamba list -n base --json --full-name qe').decode())[0]
return info['version']


@pytest.fixture
def sssp_version(aiida_exec):
output = aiida_exec("aiida-pseudo list").decode().strip()
return re.search(r"SSSP/(\d+\.\d+)/PBE/efficiency", output).group(1)
output = aiida_exec('aiida-pseudo list').decode().strip()
return re.search(r'SSSP/(\d+\.\d+)/PBE/efficiency', output).group(1)
21 changes: 12 additions & 9 deletions .docker/tests/test_aiida.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
# pylint: disable=missing-docstring


def test_verdi_status(aiida_exec, container_user):
output = aiida_exec('verdi status', user=container_user).decode().strip()
assert 'Connected to RabbitMQ' in output
Expand All @@ -13,18 +14,20 @@ def test_verdi_status(aiida_exec, container_user):
def test_computer_setup_success(aiida_exec, container_user):
output = aiida_exec('verdi computer test localhost', user=container_user).decode().strip()

assert "Success" in output
assert "Failed" not in output
assert 'Success' in output
assert 'Failed' not in output


def test_run_real_pw_computation(aiida_exec, container_user, qe_version, sssp_version):
import re

output = aiida_exec("verdi data core.structure import ase /opt/examples/Si.cif", user=container_user).decode().strip()

# Find pk
pk = re.search(r"PK = (\d+)", output).group(1)

cmd = f"aiida-quantumespresso calculation launch pw -X pw-{qe_version}@localhost -F SSSP/{sssp_version}/PBE/efficiency -S {pk} -k 1 1 1"
output = aiida_exec('verdi data core.structure import ase /opt/examples/Si.cif',
user=container_user).decode().strip()

# Find pk
pk = re.search(r'PK = (\d+)', output).group(1)

cmd = f'aiida-quantumespresso calculation launch pw -X pw-{qe_version}@localhost -F SSSP/{sssp_version}/PBE/efficiency -S {pk} -k 1 1 1'
output = aiida_exec(cmd, user=container_user).decode().strip()

assert "terminated with state: finished [0]" in output
assert 'terminated with state: finished [0]' in output
10 changes: 5 additions & 5 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ on:
- "docs/**"
- "tests/**"
push:
#branches:
# - main
#tags:
# - "v*"
branches:
- main
tags:
- "v*"
paths-ignore:
- "docs/**"
- "tests/**"
Expand Down Expand Up @@ -43,7 +43,7 @@ jobs:
pip install --upgrade pip
pip install --upgrade -r requirements.txt
- name: Build image
- name: Build image
run: docker buildx bake -f docker-bake.hcl --set *.platform=linux/amd64 --load
env:
# Full logs for CI build
Expand Down

0 comments on commit 706ae68

Please sign in to comment.