-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add plugin specific docker image (#230)
The image of the aiida-sssp-workflow is available at `ghcr.io/unkcpz/aiida-sssp-workflow` to have a pre-installed plugin and aiida environment.
- Loading branch information
Showing
9 changed files
with
18,864 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
FROM ghcr.io/aiidateam/aiida-core-with-services:edge | ||
|
||
USER root | ||
|
||
ARG QE_VERSION | ||
ENV QE_VERSION ${QE_VERSION} | ||
|
||
# Install aiida-quantumespresso from source code | ||
COPY --from=src . /tmp/aiida-sssp-workflow | ||
RUN pip install /tmp/aiida-sssp-workflow --no-cache-dir && \ | ||
rm -rf /tmp/aiida-sssp-workflow | ||
|
||
# Install quantum espresso from conda (the latest version) | ||
RUN mamba install -y -c conda-forge qe=${QE_VERSION} && \ | ||
mamba clean --all -f -y && \ | ||
fix-permissions "${CONDA_DIR}" && \ | ||
fix-permissions "/home/${SYSTEM_USER}" | ||
|
||
COPY scripts/60-code-setup.sh /etc/init/run-before-daemon-start/ | ||
|
||
# Static example upf files | ||
RUN mkdir -p /opt/examples | ||
COPY _static/ /opt/examples | ||
|
||
USER ${SYSTEM_UID} |
18,586 changes: 18,586 additions & 0 deletions
18,586
.docker/_static/Si.paw.z_4.ld1.psl.v1.0.0-high.upf
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# docker-bake.hcl | ||
variable "ORGANIZATION" { | ||
default = "unkcpz" | ||
} | ||
|
||
variable "REGISTRY" { | ||
default = "docker.io/" | ||
} | ||
|
||
variable "PLATFORMS" { | ||
default = ["linux/amd64"] | ||
} | ||
|
||
variable "QE_VERSION" { | ||
default = "7.2" | ||
} | ||
|
||
function "tags" { | ||
params = [image] | ||
result = [ | ||
"${REGISTRY}${ORGANIZATION}/${image}:newly-baked" | ||
] | ||
} | ||
|
||
group "default" { | ||
targets = ["aiida-sssp-workflow"] | ||
} | ||
|
||
target "aiida-sssp-workflow" { | ||
tags = tags("aiida-sssp-workflow") | ||
contexts = { | ||
src = ".." | ||
} | ||
platforms = "${PLATFORMS}" | ||
args = { | ||
"QE_VERSION" = "${QE_VERSION}" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
version: '3.4' | ||
|
||
services: | ||
|
||
aiida: | ||
image: ${REGISTRY:-}${BASE_IMAGE:-unkcpz/aiida-sssp-workflow}:${TAG:-latest} | ||
environment: | ||
TZ: Europe/Zurich | ||
SETUP_DEFAULT_AIIDA_PROFILE: 'true' | ||
#volumes: | ||
# - aiida-home-folder:/home/aiida | ||
|
||
volumes: | ||
aiida-home-folder: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
docker | ||
pre-commit | ||
pytest | ||
requests | ||
tabulate | ||
pytest-docker | ||
docker-compose | ||
pyyaml<=5.3.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
|
||
# If lock file exists, then we have already run this script | ||
if [ -f ${HOME}/.lock_code_setup ]; then | ||
exit 0 | ||
else | ||
touch ${HOME}/.lock_code_setup | ||
fi | ||
|
||
# Loop over executables to set up | ||
for code_name in pw ph; do | ||
# Set up caching | ||
verdi config set -a caching.enabled_for aiida.calculations:quantumespresso.${code_name} | ||
# Set up code | ||
verdi code create core.code.installed \ | ||
--non-interactive \ | ||
--label ${code_name}-${QE_VERSION} \ | ||
--description "${code_name}.x code on localhost" \ | ||
--default-calc-job-plugin quantumespresso.${code_name} \ | ||
--computer localhost --prepend-text 'eval "$(conda shell.posix hook)"\nconda activate base\nexport OMP_NUM_THREADS=1' \ | ||
--filepath-executable ${code_name}.x | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# -*- coding: utf-8 -*- | ||
# pylint: disable=missing-docstring, redefined-outer-name | ||
import pytest | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def docker_compose_file(pytestconfig): # pylint: disable=unused-argument | ||
return f"docker-compose.aiida-sssp-workflow.yml" | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def docker_compose(docker_services): | ||
# pylint: disable=protected-access | ||
return docker_services._docker_compose | ||
|
||
|
||
def is_container_ready(docker_compose): | ||
output = ( | ||
docker_compose.execute("exec -T aiida verdi status || true").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) | ||
) | ||
|
||
|
||
@pytest.fixture | ||
def container_user(): | ||
return "aiida" | ||
|
||
|
||
@pytest.fixture | ||
def aiida_exec(docker_compose): | ||
def execute(command, user=None, **kwargs): | ||
if user: | ||
command = f"exec -T --user={user} aiida {command}" | ||
else: | ||
command = f"exec -T aiida {command}" | ||
return docker_compose.execute(command, **kwargs) | ||
|
||
return execute |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# -*- 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 | ||
assert "Daemon is running" in output | ||
|
||
# check that we have suppressed the warnings | ||
assert "Warning" not in output | ||
|
||
|
||
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 | ||
|
||
|
||
# slow | ||
def test_run_real_sssp_measure_precision_verification(aiida_exec, container_user): | ||
cmd = "aiida-sssp-workflow launch --property measure.precision --pw-code pw-7.2@localhost --ecutwfc 30 --ecutrho 240 --protocol test --configuration BCC --withmpi True --num-mpiprocs 1 --npool 1 --no-daemon -- /opt/examples/Si.paw.z_4.ld1.psl.v1.0.0-high.upf" | ||
|
||
output = aiida_exec(cmd, user=container_user).decode().strip() | ||
|
||
assert "Success: calculated on property: measure.precision" in output | ||
|
||
|
||
# slow | ||
def test_run_real_sssp_convergence_verification(aiida_exec, container_user): | ||
cmd = "aiida-sssp-workflow launch --property convergence --pw-code pw-7.2@localhost --ph-code ph-7.2@localhost --protocol test --cutoff-control test --criteria efficiency --withmpi True --num-mpiprocs 2 --npool 1 --no-daemon -- /opt/examples/Si.paw.z_4.ld1.psl.v1.0.0-high.upf" | ||
|
||
output = aiida_exec(cmd, user=container_user).decode().strip() | ||
|
||
assert "Success" in output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
--- | ||
name: Build, test and push Docker Images | ||
|
||
on: | ||
pull_request: | ||
paths-ignore: | ||
- "docs/**" | ||
- "tests/**" | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- "v*" | ||
paths-ignore: | ||
- "docs/**" | ||
- "tests/**" | ||
workflow_dispatch: | ||
|
||
# https://docs.github.com/en/actions/using-jobs/using-concurrency | ||
concurrency: | ||
# only cancel in-progress jobs or runs for the current workflow - matches against branch & tags | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
amd64-build: | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
shell: bash | ||
working-directory: .docker | ||
|
||
steps: | ||
- name: Checkout Repo ⚡️ | ||
uses: actions/checkout@v3 | ||
- name: Set Up Python 🐍 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.x | ||
|
||
- name: Install Dev Dependencies 📦 | ||
run: | | ||
pip install --upgrade pip | ||
pip install --upgrade -r requirements.txt | ||
- name: Build image | ||
run: docker buildx bake -f docker-bake.hcl --set *.platform=linux/amd64 --load | ||
env: | ||
# Full logs for CI build | ||
BUILDKIT_PROGRESS: plain | ||
|
||
- name: Run tests ✅ | ||
run: TAG=newly-baked python -m pytest -s tests | ||
|
||
- name: Docker meta 📝 | ||
if: always() | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: | | ||
name=ghcr.io/unkcpz/aiida-sssp-workflow | ||
tags: | | ||
type=edge,enable={{is_default_branch}} | ||
type=sha,enable=${{ github.ref_type != 'tag' }} | ||
type=ref,event=pr | ||
type=match,pattern=v(\d+\.\d+.\d+),group=1 | ||
type=raw,value={{tag}},enable=${{ startsWith(github.ref, 'refs/tags/v') }} | ||
- name: Login to Container Registry 🔑 | ||
if: always() | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ secrets.GHCR_USERNAME }} | ||
password: ${{ secrets.GHCR_TOKEN }} | ||
|
||
- name: Set tags for image and push 🏷️📤💾 | ||
if: always() | ||
run: | | ||
declare -a arr=(${{ steps.meta.outputs.tags }}) | ||
for tag in "${arr[@]}"; do | ||
docker tag unkcpz/aiida-sssp-workflow:newly-baked ${tag} | ||
docker push ${tag} | ||
done |