From 4d33411633c1844eb55d55861cfff9897f16277b Mon Sep 17 00:00:00 2001 From: Aliaksandr Yakutovich Date: Wed, 1 Apr 2020 11:03:04 +0200 Subject: [PATCH] Change docker base image to aiida-core. (#96) This PR replaces the base docker image with `aiida-core:latest`. In addition, it fixes one test where the running time was too short to produce an output structure. A clear error message was added to that case to allow quickly find out the origin of the problem. --- .coveragerc | 2 ++ .docker/my_init.d/add-codes.sh | 2 +- .docker/opt/add-codes.sh | 1 + .travis.yml | 3 +-- Dockerfile | 10 ++-------- examples/single_calculations/example_restart.py | 8 ++++++-- 6 files changed, 13 insertions(+), 13 deletions(-) create mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 00000000..08df5157 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,2 @@ +[run] +parallel=True diff --git a/.docker/my_init.d/add-codes.sh b/.docker/my_init.d/add-codes.sh index b7507a19..96ce5692 100755 --- a/.docker/my_init.d/add-codes.sh +++ b/.docker/my_init.d/add-codes.sh @@ -4,4 +4,4 @@ set -em su -c /opt/add-codes.sh aiida # Make /opt/aiida-cp2k folder editable for the $SYSTEM_USER. -chown -R aiida:aiida /opt/aiida-cp2k/ +chown -R ${SYSTEM_USER}:${SYSTEM_USER} /opt/aiida-cp2k/ diff --git a/.docker/opt/add-codes.sh b/.docker/opt/add-codes.sh index 1fb08faa..8b6e4352 100755 --- a/.docker/opt/add-codes.sh +++ b/.docker/opt/add-codes.sh @@ -6,4 +6,5 @@ set -x # Environment export SHELL=/bin/bash +# Install cp2k code. verdi code show cp2k@localhost || verdi code setup --config /opt/aiida-cp2k/.docker/cp2k-code.yml --non-interactive diff --git a/.travis.yml b/.travis.yml index ca5e87c9..69cb189b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,10 +7,9 @@ before_install: - python .ci/check_travis_tag.py - docker build -t aiida_cp2k_test . - export DOCKERID=`docker run -d aiida_cp2k_test` - - sleep 30 # wait until the container is launched script: - - "echo \"Docker ID: $DOCKERID\"" + - docker exec --tty $DOCKERID wait-for-services - docker exec -it --user aiida $DOCKERID /bin/bash -l -c 'cd /opt/aiida-cp2k/ && pre-commit run --all-files || ( git status --short ; git diff ; exit 1 )' - docker exec -it --user aiida $DOCKERID /bin/bash -l -c 'cd /opt/aiida-cp2k/ && py.test --cov aiida_cp2k --cov-append .' - docker exec -it --user aiida $DOCKERID /bin/bash -l -c 'cd /opt/aiida-cp2k/docs && make' diff --git a/Dockerfile b/Dockerfile index f00788bb..3ae5b2e1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,11 +5,7 @@ # For further information on the license, see the LICENSE.txt file. # ############################################################################### -FROM aiidateam/aiida-docker-stack - -# Set HOME and PATH variables. -ENV HOME="/home/aiida" -ENV PATH="${HOME}/.local/bin:${PATH}" +FROM aiidateam/aiida-core:latest # To prevent the container to exit prematurely. ENV KILL_ALL_RPOCESSES_TIMEOUT=50 @@ -28,6 +24,4 @@ RUN pip install coveralls # Install the cp2k code. COPY .docker/opt/add-codes.sh /opt/ -COPY .docker/my_init.d/add-codes.sh /etc/my_init.d/40_add-codes.sh - -RUN chown -R aiida:aiida ${HOME} +COPY .docker/my_init.d/add-codes.sh /etc/my_init.d/50_add-codes.sh diff --git a/examples/single_calculations/example_restart.py b/examples/single_calculations/example_restart.py index a0fc2cca..df922fa4 100644 --- a/examples/single_calculations/example_restart.py +++ b/examples/single_calculations/example_restart.py @@ -42,7 +42,7 @@ def example_restart(cp2k_code): dict={ 'GLOBAL': { 'RUN_TYPE': 'GEO_OPT', - 'WALLTIME': '00:00:10', # too short + 'WALLTIME': '00:00:20', # too short }, 'MOTION': { 'GEO_OPT': { @@ -123,7 +123,11 @@ def example_restart(cp2k_code): # Check walltime exceeded. assert calc1['output_parameters']['exceeded_walltime'] is True assert calc1['output_parameters']['energy'] is not None - assert 'output_structure' in calc1 + if 'output_structure' not in calc1: + print("There is no 'output_structure' in the process outputs. " + "Most probably the calculation did not reach the first geometry optimization step.") + sys.exit(1) + print("OK, walltime exceeded as expected.") # ------------------------------------------------------------------------------