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

Containerization of Environ build #9

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b3f62cd
Bring back parallel gather in get_dvtot
olivieroandreussi Jun 21, 2024
e5af4e4
Update README.md
olivieroandreussi Jun 21, 2024
90ed29d
Write Dockerfile
lattice737 Jun 24, 2024
59dea32
Update Dockerfile
lattice737 Jun 24, 2024
ca78f8e
Develop build action as production-grade build test
lattice737 Jun 25, 2024
3fa3951
Unset tests flag in Dockerfile
lattice737 Jun 25, 2024
9b32d23
Update ci.yml
lattice737 Jun 25, 2024
4a2dcbd
Add print statements
lattice737 Jun 25, 2024
d6680da
Remove sed, add needs
lattice737 Jun 25, 2024
3381acb
Update builderx version
lattice737 Jun 25, 2024
dba1406
Add buildx setup step, fix buildx push ref
lattice737 Jun 25, 2024
ba5a74b
Debug bad image reference
lattice737 Jun 25, 2024
91f6034
Correct exec flags
lattice737 Jun 25, 2024
3681e21
Refactor ci
lattice737 Jun 25, 2024
dc58012
Remove exec interactivity
lattice737 Jun 25, 2024
d17d133
Use run-action to run tests
lattice737 Jun 25, 2024
61833ac
Add ompi env variables to test job
lattice737 Jun 25, 2024
7c1e702
Use env for OMPI vars, set fail exit code condition
lattice737 Jun 25, 2024
4cef6e8
Set ompi vars inline, add fi
lattice737 Jun 25, 2024
da6b144
Use -e flags, exit status 1 for any failed tests
lattice737 Jun 25, 2024
7300b50
Set env variables inline, grep silently
lattice737 Jun 25, 2024
f9a099a
Set env variables for step and command
lattice737 Jun 25, 2024
7b579c9
Run tests serially
lattice737 Jun 25, 2024
f647c8b
Display env variables
lattice737 Jun 25, 2024
a6bd521
Use root flag with mpirun
lattice737 Jun 25, 2024
37b7df8
Run tests serially for now
lattice737 Jun 25, 2024
27f9118
Configure ci triggers--merges, pushes to master, develop
lattice737 Jun 25, 2024
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
46 changes: 46 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: CI
on:
push:
branches:
- master
- develop
pull_request:

jobs:
compile:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: Dockerfile
sparse-checkout-cone-mode: false
- uses: docker/setup-buildx-action@v3
- name: Build image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
tags: environ
outputs: type=docker,dest=/tmp/environ.tar
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: environ
path: /tmp/environ.tar
test:
# if-condition source: https://github.com/orgs/community/discussions/25692#discussioncomment-3248764
if: github.event_name == 'pull_request' || (github.event_name == 'push' && (contains(github.ref, '/heads/master') || contains(github.ref, '/tags/v')))
needs: compile
runs-on: ubuntu-22.04
steps:
- uses: actions/download-artifact@v2
with:
name: environ
path: /tmp
- name: Load image
run: docker load --input /tmp/environ.tar
- name: Run tests
uses: addnab/docker-run-action@v3
with:
image: environ:latest
run: sh -c "env && cd /app/q-e/Environ/tests && make --ignore-errors run-tests | tee /app/tests.log && if grep -q **FAILED** /app/tests.log; then exit 1; fi"
105 changes: 105 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Use containerized installation
# 0) Install Docker (https://docs.docker.com/engine/install/) or Docker Desktop (https://www.docker.com/products/docker-desktop/)
# 1) Clone repo: git clone https://github.com/environ-developers/Environ.git && cd Environ
# 2) Build image: docker build -t environ-sandbox . && docker image ls
# 3) Run container: docker run -i -p 8000:80 environ-sandbox && docker ps
# 4) Access container:
# a) Docker Desktop
# b) CLI: docker exec -it <container ID> bash
# 5) Review test and/or example logs:
# a) cat /app/tests.log
# b) cat /app/examples.log

# Configure sandbox -- compiler, dependencies, openmpi, python

FROM ubuntu:22.04
RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get install --assume-yes --no-install-recommends \
autoconf \
bc \
build-essential \
ca-certificates \
gfortran \
git-all \
libblas3 \
libc6 \
libelpa17 \
libfftw3-dev \
libgcc-s1 \
liblapack-dev \
libopenmpi-dev \
libscalapack-openmpi-dev \
python3 \
pipx \
wget
#RUN pipx install Cython numpy ase matplotlib pandas notebook --include-deps
WORKDIR /app

# Set environment variables
# N number of processors
# QE_VERSION Quantum ESPRESSO source version
# QE_CONFIG Quantum ESPRESSO configuration options
# ENVIRON_CONFIG Environ configuration options
# DOWNLOAD_EFFICIENCY download efficiency SSSP pseudopotential during build
# DOWNLOAD_PRECISION download precision SSSP pseudopotential during build
# RUN_TESTS run tests during build
# RUN_EXAMPLES run examples during build
# BIN_DIR absolute path to binary directory (QE variable)
# PSEUDO_DIR absolute path to pseudopotential directory (QE variable)
# TMP_DIR absolute path of placeholder directory (QE variable)
# OMPI_ALLOW_RUN_AS_ROOT root-level execution permission (MPI variable)
# OMPI_ALLOW_RUN_AS_ROOT_CONFIRM root-level execution confirmation (MPI variable)
ENV N=4 \
QE_VERSION=qe-7.2 \
QE_CONFIG="--enable-parallel --with-environ=/app/q-e/Environ" \
ENVIRON_CONFIG="--with-qe=/app/q-e" \
DOWNLOAD_EFFICIENCY=0 \
DOWNLOAD_PRECISION=0 \
RUN_TESTS=0 \
RUN_EXAMPLES=0 \
BIN_DIR="/app/q-e/bin" \
PSEUDO_DIR="/app/q-e/pseudo" \
TMP_DIR="/app" \
OMPI_ALLOW_RUN_AS_ROOT=1 \
OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1

# Compile & install QE with Environ

RUN git clone https://github.com/QEF/q-e.git
WORKDIR /app/q-e
RUN git checkout $QE_VERSION && git clone https://github.com/environ-developers/Environ.git
RUN grep -rl .*NETWORK_PSEUDO=http:.* | xargs sed -i "s/NETWORK_PSEUDO=http:/NETWORK_PSEUDO=https:/"
RUN grep -rl .*NETWORK_PSEUDO=https:\/\/www.quantum-espresso.org\/wp-content\/uploads\/upf_files\/.* | xargs sed -i "s/NETWORK_PSEUDO=https:\/\/www.quantum-espresso.org\/wp-content\/uploads\/upf_files\//NETWORK_PSEUDO=https:\/\/pseudopotentials.quantum-espresso.org\/upf_files\//"
WORKDIR /app/q-e/Environ
RUN ./configure $ENVIRON_CONFIG && make -j $N compile
WORKDIR /app/q-e
RUN ./configure $QE_CONFIG && make -j $N pw
RUN export PATH="$BIN_DIR:$PATH"
WORKDIR /app

# Download SSSP pseudopotentials

ENV EFFICIENCY_TARBALL="https://archive.materialscloud.org/record/file?record_id=1732&filename=SSSP_1.3.0_PBE_efficiency.tar.gz"
ENV PRECISION_TARBALL="https://archive.materialscloud.org/record/file?record_id=1732&filename=SSSP_1.3.0_PBE_precision.tar.gz"
RUN if [ "$DOWNLOAD_EFFICIENCY" = "1" ]; then \
wget $EFFICIENCY_TARBALL --output-document=efficiency.tar.gz && \
tar -xvzf efficiency.tar.gz -C /app/q-e/pseudo && \
rm efficiency.tar.gz; fi
RUN if [ "$DOWNLOAD_PRECISION" = "1" ]; then \
wget $PRECISION_TARBALL --output-document=precision.tar.gz && \
tar -xvzf precision.tar.gz -C /app/q-e/pseudo && \
rm precision.tar.gz; fi

# Run Environ tests and examples

WORKDIR /app/q-e/Environ/tests
RUN if [ "$RUN_TESTS" = "1" ]; then \
make --ignore-errors run-tests-parallel | tee /app/tests.log; fi
WORKDIR /app/q-e/Environ/examples/qe/pw
RUN if [ "$RUN_EXAMPLES" = "1" ]; then \
./run_all.sh | tee /app/examples.log; fi
WORKDIR /app

# Run shell

CMD bash
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Copyright (C) 2018-2022 ENVIRON (www.quantum-environ.org)
# Copyright (C) 2018-2024 ENVIRON (www.quantum-environ.org)

### This file is part of Environ version 3.0
### This file is part of Environ version 3.1

Environ 3.0 is free software: you can redistribute it and/or modify
Environ 3.1 is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

Environ 3.0 is distributed in the hope that it will be useful,
Environ 3.1 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more detail, either the file
Expand All @@ -20,13 +20,13 @@

| Name | Institution |
| ------------------ | --------------------------------------------------------------- |
| Oliviero Andreussi | Department of Physics, University of North Texas |
| Oliviero Andreussi | Department of Chemistry and Biochemistry, Boise State University|
| Francesco Nattino | THEOS and NCCR-MARVEL, Ecole Polytechnique Federale de Lausanne |
| Iurii Timrov | THEOS and NCCR-MARVEL, Ecole Polytechnique Federale de Lausanne |
| Iurii Timrov | PSI Zurich and NCCR-MARVEL |
| Ismaila Dabo | Department of Materials Science and Engineering, Penn State |
| Nicola Marzari | THEOS and NCCR-MARVEL, Ecole Polytechnique Federale de Lausanne |
| Quinn Campbell | Sandia National Labs |
| Edan Bainglass | Department of Physics, University of North Texas |
| Edan Bainglass | PSI Zurich and NCCR-MARVEL |
| Matthew Truscott | Department of Physics, University of North Texas |
| Gabriel Medrano | Department of Physics, University of North Texas |

Expand All @@ -50,7 +50,7 @@

http://www.quantum-espresso.org/

# QE + Environ 3.0 Installation
# QE + Environ 3.1 Installation

The following instructions refer to Environ 3.0 installed on QE >= 7.1
For previous versions, please refer to the instructions on the website:
Expand Down Expand Up @@ -111,7 +111,7 @@ If using cmake, modify the ESPRESSO_ROOT variable in the following files to refl

#

# Uninstall Environ 3.0
# Uninstall Environ 3.1

From Environ root:

Expand Down
29 changes: 25 additions & 4 deletions src/main.f90
Original file line number Diff line number Diff line change
Expand Up @@ -717,24 +717,45 @@ END FUNCTION get_vzero
!>
!!
!------------------------------------------------------------------------------------
FUNCTION get_dvtot(this, nnr) RESULT(dvtot)
FUNCTION get_dvtot(this, nnr, gather) RESULT(dvtot)
!--------------------------------------------------------------------------------
!
INTEGER, INTENT(IN) :: nnr
LOGICAL, INTENT(IN), OPTIONAL :: gather
CLASS(environ_main), INTENT(IN) :: this
!
REAL(DP) :: dvtot(nnr)
!
LOGICAL :: use_gather
CHARACTER(LEN=80) :: routine = 'get_dvtot'
!
!--------------------------------------------------------------------------------
!
IF (nnr /= this%dvtot%cell%nnr) &
CALL io%error(routine, "Mismatch in grid size", 1)
use_gather = .FALSE.
IF (PRESENT(gather)) use_gather = gather
!
IF (.NOT.use_gather .AND. nnr /= this%dvtot%cell%nnr) THEN
CALL io%error(routine, "Mismatch in local grid size", 1)
ELSE IF (use_gather .AND. nnr /= this%dvtot%cell%nnt) THEN
CALL io%error(routine, "Mismatch in global grid size", 1)
ENDIF
!
!--------------------------------------------------------------------------------
!
dvtot = this%dvtot%of_r
IF (use_gather) THEN
#if defined(__MPI)
dvtot = 0.D0
!
CALL env_gather_grid(this%setup%system_cell%dfft, this%dvtot%of_r, dvtot)
!
CALL env_mp_sum(dvtot, this%setup%system_cell%dfft%comm)
!
#else
dvtot = this%dvtot%of_r
#endif
ELSE
dvtot = this%dvtot%of_r
END IF
!
!--------------------------------------------------------------------------------
END FUNCTION get_dvtot
Expand Down