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

Run make check and make check-short targests (Dev-build) #56

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 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
20 changes: 20 additions & 0 deletions .github/workflows/spack-dev-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: spack-dev-build

on:
pull_request:
branches: [ main ]
workflow_dispatch:
schedule:
- cron: '0 12 1 * *' # 12:00 UTC on the 1st of every month and on manual dispatch

jobs:

build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Build the Docker image with make checks
run: make spack-dev-build

135 changes: 135 additions & 0 deletions Docker-dev-build
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
FROM debian:bullseye

# # which spack version are we using now? Default is develop
# # but other strings can be given to the docker build command
# # (for example docker build --build-arg SPACK_VERSION=v0.16.2)
ARG SPACK_VERSION=develop
ARG OCT_VERSION=12.1
RUN echo "Building with spack version ${SPACK_VERSION}"

# Any extra packages to be installed in the host
ARG EXTRA_PACKAGES
RUN echo "Installing EXTRA_PACKAGES ${EXTRA_PACKAGES} on container host"

# general environment for docker
ENV SPACK_ROOT=/home/user/spack \
SPACK=/home/user/spack/bin/spack \
FORCE_UNSAFE_CONFIGURE=1

RUN apt-get -y update
# Convenience tools, if desired for debugging etc
# RUN apt-get -y install wget time nano vim emacs git

# From https://github.com/ax3l/dockerfiles/blob/master/spack/base/Dockerfile:
# install minimal spack dependencies
RUN apt-get install -y --no-install-recommends \
autoconf \
build-essential \
ca-certificates \
coreutils \
curl \
environment-modules \
file \
gfortran \
git \
openssh-server \
python \
unzip \
vim \
wget \
&& rm -rf /var/lib/apt/lists/*

# load spack environment on login
RUN echo "source $SPACK_ROOT/share/spack/setup-env.sh" \
> /etc/profile.d/spack.sh

RUN adduser user
USER user
WORKDIR /home/user

# install spack
RUN git clone https://github.com/spack/spack.git
iamashwin99 marked this conversation as resolved.
Show resolved Hide resolved
# default branch is develop
RUN cd spack && git checkout $SPACK_VERSION

# # show which version we use
RUN $SPACK --version

# copy our package.py into the spack tree (and also example files)
COPY spack/package.py $SPACK_ROOT/var/spack/repos/builtin/packages/octopus/package.py
RUN ls -l $SPACK_ROOT/var/spack/repos/builtin/packages/octopus
COPY spack/test/ $SPACK_ROOT/var/spack/repos/builtin/packages/octopus/test
RUN ls -l $SPACK_ROOT/var/spack/repos/builtin/packages/octopus/test
COPY check_buildlog.py /home/user

# Install and test serial and MPI versions of ocoptus via spack
# # serial version

RUN . $SPACK_ROOT/share/spack/setup-env.sh && \
# create a new environment for the serial version and activate it:
spack env create octopus-serial && \
Copy link
Owner

Choose a reason for hiding this comment

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

Why are all the commands in lines 68 to 99 in one line? Doesn't that make it hard to read the output? See for example the beginning of a lot of output at this step 21: https://github.com/fangohr/octopus-in-spack/pull/56/checks#step:3:940

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I made them in one line to minimise the size of the docker container thus formed. Do you think I should split them into multiple RUN commands?

spack env activate octopus-serial && \
# make a dev-build direcotry for the serial version:
mkdir ~/dev-build-serial && cd ~/dev-build-serial && \

wget https://octopus-code.org/down.php?file=12.1/octopus-12.1.tar.gz -O octopus-12.1.tar.gz &&\
iamashwin99 marked this conversation as resolved.
Show resolved Hide resolved
tar --strip-components=1 -xf octopus-12.1.tar.gz -C ./&& \
# install the serial version of octopus:
# display specs of upcoming spack installation:
spack spec octopus@${OCT_VERSION} ~mpi+netcdf+parmetis+arpack+cgal+pfft+python+likwid+libyaml+elpa+nlopt~debug~cuda~metis~scalapack && \
Copy link
Owner

Choose a reason for hiding this comment

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

The long list of flags is repeated in line 81. And then again (most of them) in line 112 and 114. Perhaps define them once in the beginning in a variable and only change here what is different for each case?

# run the spack installation (adding it to the environment):
spack dev-build octopus@${OCT_VERSION} ~mpi+netcdf+parmetis+arpack+cgal+pfft+python+likwid+libyaml+elpa+nlopt~debug~cuda~metis~scalapack && \
Copy link
Owner

Choose a reason for hiding this comment

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

Comment A: I think the spack dev-build does not install Octopus but just the dependencies. Is that correct? (See Comment B below.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, spack dev-build would be identical to spack install except that instead of spack fetching the source, we manually provide the source and the build directory. In the end all the dependencies are installed, octopus is compiled with these dependencies and the resulting octopus binary is added to the spack's database. See here

# run spack smoke tests for octopus. We get an error if any of the fails:
spack test run --alias test_serial octopus && \
fangohr marked this conversation as resolved.
Show resolved Hide resolved
# display output from smoke tests (just for information):
spack test results -l test_serial && \
# show which octopus version we use (for convenience):
spack load octopus && octopus --version && \
# Run make checks
cd ~/dev-build-serial ; \
echo "-+-+-+-+ Running make check-short" ; \
make check-short | tee serial_check-short.log || /bin/true ; \
echo "-+-+-+-+ Running make check-long" ; \
make check-long | tee serial_check-long.log || /bin/true ; \
echo "-+-+-+-+ Parsing serial_check-short.log" ; \
iamashwin99 marked this conversation as resolved.
Show resolved Hide resolved
python3 /home/user/check_buildlog.py serial_check-short.log foss2021a-serial || /bin/true; \
echo "-+-+-+-+ Parsing serial_check-long.log" ; \
python3 /home/user/check_buildlog.py serial_check-long.log foss2021a-serial || /bin/true; \
# deactivate the environment.
spack env deactivate

# # MPI version

RUN . $SPACK_ROOT/share/spack/setup-env.sh && \
Copy link
Owner

Choose a reason for hiding this comment

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

Same comments as for serial block.

# create a new environment for the MPI version and activate it:
spack env create octopus-mpi && \
spack env activate octopus-mpi && \
# make a dev-build direcotry for the parallel version:
mkdir ~/dev-build-parallel && cd ~/dev-build-parallel && \
wget https://octopus-code.org/down.php?file=12.1/octopus-12.1.tar.gz -O octopus-12.1.tar.gz &&\
tar --strip-components=1 -xf octopus-12.1.tar.gz -C ./&& \
# display specs of upcoming spack installation:
spack spec octopus@${OCT_VERSION} +mpi +netcdf+parmetis+arpack+cgal+pfft+python+likwid+libyaml+elpa+nlopt~debug~cuda~metis~scalapack && \
# run the spack installation (adding it to the environment):
spack dev-build octopus@${OCT_VERSION} +mpi +netcdf+parmetis+arpack+cgal+pfft+python+likwid+libyaml+elpa+nlopt~debug~cuda~metis~scalapack && \
# run spack smoke tests for octopus. We get an error if any of the fails:
spack test run --alias test_MPI octopus && \
# display output from smoke tests (just for information):
spack test results -l test_MPI && \
# show which octopus version we use (for convenience):
spack load octopus && octopus --version && \
# Run make checks
cd ~/dev-build-parallel ; \
echo "+|+|+|+ Running make check-short" ; \
make check-short | tee mpi_check-short.log || /bin/true ; \
echo "+|+|+|+ Running make check-long" ; \
make check-long | tee mpi_check-long.log || /bin/true ; \
echo "+|+|+|+ Parsing mpi_check-short.log" ; \
python3 /home/user/check_buildlog.py mpi_check-short.log foss2021a-mpi || /bin/true; \
echo "+|+|+|+ Parsing mpi_check-long.log" ; \
python3 /home/user/check_buildlog.py mpi_check-long.log foss2021a-mpi || /bin/true; \
spack env deactivate

# Provide bash in case the image is meant to be used interactively
Copy link
Owner

Choose a reason for hiding this comment

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

Would be nice to have a summary of passed and failed tests (if easily done) for serial and mpi. So that you can scroll to the end and find the most interesting information there.

Or perhaps just re-run the check_buildog.py script at the very end.

Copy link
Collaborator Author

@iamashwin99 iamashwin99 Nov 25, 2022

Choose a reason for hiding this comment

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

Currently check_buildog.py is the last thing thats run for each variant.
It gives the summary in the following format:

-+-+-+-+ Parsing serial_check-short.log
Unexpected failures :
periodic_systems/24-hartree_fock_1D.test, functionals/18-mgga.test, finite_systems_3d/37-sternheimer_polarized.test, finite_systems_3d/06-restart.test, finite_systems_1d/01-hydrogen.test
Built with tool chain : foss2021a-serial
-+-+-+-+ Parsing serial_check-long.log
Unexpected failures :
real_time/14-absorption-spinors.test, periodic_systems/21-magnon.test, periodic_systems/07-mgga.test, linear_response/01-casida.test, finite_systems_3d/16-scfinlcao_std.test
Built with tool chain : foss2021a-serial

------------------ Build log and check log for MPI variant ---------------


+|+|+|+ Parsing mpi_check-short.log
Unexpected failures :
real_time/12-absorption.test, periodic_systems/24-hartree_fock_1D.test, functionals/18-mgga.test, finite_systems_3d/37-sternheimer_polarized.test, finite_systems_3d/06-restart.test
Built with tool chain : foss2021a-mpi
+|+|+|+ Parsing mpi_check-long.log
Unexpected failures :
real_time/14-absorption-spinors.test, periodic_systems/07-mgga.test, linear_response/01-casida.test, finite_systems_3d/16-scfinlcao_std.test
Built with tool chain : foss2021a-mpi

Did you want it in some other format?

CMD /bin/bash -l

10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ FROM debian:bullseye
# # but other strings can be given to the docker build command
# # (for example docker build --build-arg SPACK_VERSION=v0.16.2)
ARG SPACK_VERSION=develop
ARG OCT_VERSION=12.1
ARG SPACK_OCT_VERSION=12.1
RUN echo "Building with spack version ${SPACK_VERSION}"

# Any extra packages to be installed in the host
Expand Down Expand Up @@ -68,9 +68,9 @@ RUN . $SPACK_ROOT/share/spack/setup-env.sh && \
spack env create octopus-serial && \
spack env activate octopus-serial && \
# display specs of upcoming spack installation:
spack spec octopus@${OCT_VERSION} ~mpi+netcdf+parmetis+arpack+cgal+pfft+python+likwid+libyaml+elpa+nlopt~debug~cuda~metis~scalapack && \
spack spec octopus@${SPACK_OCT_VERSION} ~mpi+netcdf+parmetis+arpack+cgal+pfft+python+likwid+libyaml+elpa+nlopt~debug~cuda~metis~scalapack && \
# run the spack installation (adding it to the environment):
spack add octopus@${OCT_VERSION} ~mpi+netcdf+parmetis+arpack+cgal+pfft+python+likwid+libyaml+elpa+nlopt~debug~cuda~metis~scalapack && \
spack add octopus@${SPACK_OCT_VERSION} ~mpi+netcdf+parmetis+arpack+cgal+pfft+python+likwid+libyaml+elpa+nlopt~debug~cuda~metis~scalapack && \
spack install && \
# run spack smoke tests for octopus. We get an error if any of the fails:
spack test run --alias test_serial octopus && \
Expand All @@ -88,9 +88,9 @@ RUN . $SPACK_ROOT/share/spack/setup-env.sh && \
spack env create octopus-mpi && \
spack env activate octopus-mpi && \
# display specs of upcoming spack installation:
spack spec octopus@${OCT_VERSION} +mpi +netcdf+parmetis+arpack+cgal+pfft+python+likwid+libyaml+elpa+nlopt~debug~cuda~metis~scalapack && \
spack spec octopus@${SPACK_OCT_VERSION} +mpi +netcdf+parmetis+arpack+cgal+pfft+python+likwid+libyaml+elpa+nlopt~debug~cuda~metis~scalapack && \
# run the spack installation (adding it to the environment):
spack add octopus@${OCT_VERSION} +mpi +netcdf+parmetis+arpack+cgal+pfft+python+likwid+libyaml+elpa+nlopt~debug~cuda~metis~scalapack && \
spack add octopus@${SPACK_OCT_VERSION} +mpi +netcdf+parmetis+arpack+cgal+pfft+python+likwid+libyaml+elpa+nlopt~debug~cuda~metis~scalapack && \
spack install && \
# run spack smoke tests for octopus. We get an error if any of the fails:
spack test run --alias test_MPI octopus && \
Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ spack-latest:
docker build -f Dockerfile --build-arg SPACK_VERSION=releases/latest -t octopus-spack .

spack-latest-octopus-develop:
docker build -f Dockerfile --build-arg SPACK_VERSION=releases/latest --build-arg OCT_VERSION=develop -t octopus-spack .
docker build -f Dockerfile --build-arg SPACK_VERSION=releases/latest --build-arg SPACK_OCT_VERSION=develop -t octopus-spack .

spack-dev-build:
docker build -f Docker-dev-build --build-arg SPACK_VERSION=releases/latest --build-arg SPACK_OCT_VERSION=12.1 -t octopus-spack-dev-build .

run-spack:
docker run --rm -ti -v $PWD:/io octopus-spack
Expand Down
87 changes: 87 additions & 0 deletions check_buildlog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# A simple script to check the log file of `make check or `make check-short`
# and report the number of failed tests.
# And if the failed tests are ignorable.
# (errors due to tight thresholds, for example) or needs attention.

import sys
import re

ignored_test_list = {
"foss2021a-mpi": [
"finite_systems_2d/06-gdlib.test",
"finite_systems_3d/30-local_multipoles.test",
"periodic_systems/11-silicon_force.test",
],
"foss2021a-serial": [
"components/07-cholesky serial.test",
"finite_systems_2d/06-gdlib.test",
],
}


def check_log(log_file):
with open(log_file, "r") as f:
logs = f.readlines()
# extract the last lines that has the format

# |Status: 1 failures
# | Passed: 139 / 142
# | Skipped: 0 / 142
# | Failed: 3 / 142
# |
# | testfile # failed testcases
# | ------------------------------------------------------------------------------
# | finite_systems_2d/06-gdlib.test 1
# | finite_systems_3d/30-local_multipoles.test 2
# | periodic_systems/11-silicon_force.test 1
# |
# |Total run-time of the testsuite: 03:27:12

# and extract the list of failed test files like
# finite_systems_2d/06-gdlib.test,
# finite_systems_3d/30-local_multipoles.test,
# periodic_systems/11-silicon_force.test
# from this example, by scanning from the end of the log file
# starting from the line that has the format
# `Total run-time of the testsuite:`
# and stop when the first line with the format
# `' -------------------------------------`

test_lists = []
reversed_logs = reversed(logs)
while not next(reversed_logs).startswith(
"Total run-time of the testsuite:"
):
pass
while not re.match(r" +-+", (line := next(reversed_logs))):
if not line == "\n": # skip blank lines
test_lists.append(line.split()[0])

if not test_lists:
print("No failed tests")
sys.exit(0)
unexpected_failures = [
test
for test in test_lists
if test not in ignored_test_list[used_toolchain]
]
if unexpected_failures:
print("Unexpected failures : \n" + ", ".join(unexpected_failures))
print("Built with tool chain : " + used_toolchain)
sys.exit(1)
print("All failed tests are ignored")


if __name__ == "__main__":

try:
log_file = sys.argv[1]
except IndexError:
print("Usage: python3 check_buildlog.py log_file toolchain[optional]")
sys.exit(1)
try:
used_toolchain = sys.argv[2]
except IndexError:
print("No toolchain specified, assuming the default foss2021a-mpi")
used_toolchain = "foss2021a-mpi"
check_log(log_file)