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

Update docker recipe to install from source #1651

Merged
merged 34 commits into from
Aug 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
9ef7da5
Update dockerfile
Mar 12, 2020
e48a839
Update docker
Apr 1, 2020
72b9b43
Merge branch 'master' of https://github.com/ESMValGroup/ESMValTool in…
Apr 1, 2020
d0db656
Update dockerfile
Apr 1, 2020
73f3cb8
Update dockerfile
Apr 6, 2020
6b576a1
Merge branch 'master' of https://github.com/ESMValGroup/ESMValTool in…
May 7, 2020
8187210
Update docker files
May 7, 2020
7078625
Merge branch 'master' of https://github.com/ESMValGroup/ESMValTool in…
Jul 3, 2020
f8877b3
Update docker and environment
Jul 3, 2020
5ce6335
Some progress
Jul 11, 2020
374c511
Progress in experimental
Jul 14, 2020
652ae7a
Fix command line argument and remove commented out stuff
bouweandela Jul 22, 2020
1541260
Remove no longer needed cache and enable all tests
bouweandela Jul 22, 2020
a224589
Merge branch 'master' of github.com:ESMValGroup/ESMValTool into updat…
bouweandela Jul 22, 2020
eaf0011
Update doc
Jul 23, 2020
11e3a1f
Update docker files
Jul 23, 2020
07820dd
Fix folder names
Jul 23, 2020
507b79f
Merge branch 'master' of https://github.com/ESMValGroup/ESMValTool in…
Jul 23, 2020
83167bd
Apply suggestions from code review
Jul 24, 2020
53192a5
Add esmvaltool install command
bouweandela Jul 28, 2020
9ddc6ad
Apply suggestions from code review
Jul 28, 2020
c4422eb
Add dockerignore for better cache management
Jul 28, 2020
5dab33f
Better cache for R packages
Jul 28, 2020
f043480
Dockerignore actually working
Jul 28, 2020
555fe5b
Trying with pip -e
Jul 28, 2020
808ebe1
Update doc and dockerfiles
Jul 28, 2020
18a453d
Fix doc
Jul 28, 2020
d7f39e2
Merge branch 'master' of github.com:ESMValGroup/ESMValTool into updat…
bouweandela Jul 30, 2020
621b14d
Apply suggestions from code review
Jul 30, 2020
784f91a
Fix tests and comments
bouweandela Jul 31, 2020
fcebbc2
Better examples and fix title
bouweandela Jul 31, 2020
fc6598a
Fix installation test
bouweandela Aug 3, 2020
0f95708
Install test dependencies
bouweandela Aug 3, 2020
931fdbc
Upload coverage for regular unit tests
bouweandela Aug 3, 2020
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
62 changes: 23 additions & 39 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,40 +20,33 @@ jobs:
# Run Python 3 tests
working_directory: /test
docker:
- image: continuumio/miniconda3
- image: esmvalgroup/esmvaltool:development
steps:
- checkout
- run:
command: |
# Create a file to checksum as cache key
date --rfc-3339 date > cache_key.txt
cat environment.yml >> cache_key.txt
- restore_cache:
key: test-{{ .Branch }}-{{ checksum "cache_key.txt" }}
- run:
# Update/Create Conda environment and run tests
command: |
. /opt/conda/etc/profile.d/conda.sh
mkdir /logs
# conda update -y conda >> /logs/conda.txt 2>&1
conda env update >> /logs/conda.txt 2>&1
conda activate esmvaltool
# Install r-lintr for r linter test
Rscript esmvaltool/install/R/setup_devutils.R > /logs/R_install.txt 2>&1
# Run tests
python setup.py test --addopts '-m "not installation"'
julia esmvaltool/install/Julia/setup.jl
Rscript esmvaltool/install/R/setup.R
python setup.py test
no_output_timeout: 20m
- save_cache:
key: test-{{ .Branch }}-{{ checksum "cache_key.txt" }}
paths:
- "/opt/conda/envs/esmvaltool"
- ".eggs"
- store_artifacts:
path: /logs
- store_artifacts:
path: test-reports/
- store_test_results:
path: test-reports/
- run:
when: always
command: |
if [[ -v CODACY_PROJECT_TOKEN ]]
then
echo Uploading coverage report
pip install codacy-coverage
python-codacy-coverage -r test-reports/coverage.xml
else
echo Not uploading coverage report
fi

test_installation:
# Test Python 3 installation
Expand All @@ -77,15 +70,17 @@ jobs:
# conda update -y conda > /logs/conda.txt 2>&1
conda env update >> /logs/conda.txt 2>&1
set +x; conda activate esmvaltool; set -x
pip install . > /logs/install.txt 2>&1
Rscript esmvaltool/install/R/setup.R > /logs/R_install.txt 2>&1
julia esmvaltool/install/Julia/setup.jl > /logs/julia_install.txt 2>&1
pip install .[test] > /logs/install.txt 2>&1
esmvaltool install R
esmvaltool install Julia
# Remove source to test installed software
rm -r esmvaltool
# Log versions
dpkg -l > /logs/versions.txt
conda env export > /logs/environment.yml
pip freeze > /logs/requirements.txt
# Test installation
python setup.py test
pytest
esmvaltool -h
ncl -V
# cdo test, check that it supports hdf5
Expand All @@ -105,17 +100,6 @@ jobs:
path: test-reports/
- store_test_results:
path: test-reports/
- run:
when: always
command: |
if [[ -v CODACY_PROJECT_TOKEN ]]
then
echo Uploading coverage report
pip install codacy-coverage
python-codacy-coverage -r test-reports/coverage.xml
else
echo Not uploading coverage report
fi

develop:
# Test development installation
Expand All @@ -138,8 +122,8 @@ jobs:
conda env update >> /logs/conda.txt 2>&1
set +x; conda activate esmvaltool; set -x
pip install -e .[develop] > /logs/install.txt 2>&1
Rscript esmvaltool/install/R/setup.R > /logs/R_install.txt 2>&1
julia esmvaltool/install/Julia/setup.jl > /logs/julia_install.txt 2>&1
esmvaltool install R
esmvaltool install Julia
# Log versions
dpkg -l > /logs/versions.txt
conda env export > /logs/environment.yml
Expand Down
11 changes: 11 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

**/__pycache__
.*
doc
package
tests
ESMValTool.egg-info


!.zenodo.json

4 changes: 2 additions & 2 deletions doc/sphinx/source/community/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ To install in development mode, follow these instructions.
you can declare them with the option ``--trusted-host``, e.g.
``pip install --trusted-host=pypi.python.org --trusted-host=pypi.org --trusted-host=files.pythonhosted.org -e .[develop]``
- If you want to use R diagnostics, run
``Rscript esmvaltool/install/R/setup.R`` to install the R
``esmvaltool install R`` to install the R
dependences. Note that if you only want to run the lint test for R
scripts you will have to install the ``lintr`` package. You can do
that by running ``Rscript esmvaltool/install/R/setup_devutils.R``.
- If you want to use Julia diagnostics, first install Julia as
described below in section “Installing Julia”, then run
``julia esmvaltool/install/Julia/setup.jl`` to install the Julia
``esmvaltool install Julia`` to install the Julia
dependences. Install Julia dependences after R dependences if you
plan to use both.
- Test that your installation was succesful by running
Expand Down
96 changes: 92 additions & 4 deletions doc/sphinx/source/quickstart/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,96 @@ Note that the ESMValTool source code is contained in the ``esmvaltool-python`` p
Docker installation
===================

.. warning::
Docker section to be added
ESMValTool is also provided through `DockerHub <https://hub.docker.com/u/esmvalgroup/>`_
in the form of docker containers.
See https://docs.docker.com for more information about docker containers and how to
run them.

You can get the latest release with

.. code-block:: bash

docker pull esmvalgroup/esmvaltool:stable

If you want to use the current master branch, use

.. code-block:: bash

docker pull esmvalgroup/esmvaltool:latest

To run a container using those images, use:

.. code-block:: bash

docker run esmvalgroup/esmvaltool:stable --help

Note that the container does not see the data or environmental variables
available in the host by default. You can make data available with
``-v /path:/path/in/container`` and environmental variables with ``-e VARNAME``.

For example, the following command would run a recipe

.. code-block:: bash

docker run -e HOME -v "$HOME":"$HOME" -v /data:/data esmvalgroup/esmvaltool:stable run examples/recipe_python.yml

with the environmental variable ``$HOME`` available inside the container and
the data in the directories ``$HOME`` and ``/data``, so these can be used to
find the configuration file, recipe, and data.

It might be useful to define a `bash alias
<https://opensource.com/article/19/7/bash-aliases>`_
or script to abbreviate the above command, for example

.. code-block:: bash

alias esmvaltool="docker run -e HOME -v $HOME:$HOME -v /data:/data esmvalgroup/esmvaltool:stable"

would allow using the ``esmvaltool`` command without even noticing that the
tool is running inside a Docker container.


Singularity installation
========================

Docker is usually forbidden in clusters due to security reasons. However,
there is a more secure alternative to run containers that is usually available
on them: `Singularity <https://sylabs.io/guides/3.0/user-guide/quick_start.html>`_.

Singularity can use docker containers directly from DockerHub with the
following command

.. code-block:: bash

singularity run docker://esmvalgroup/esmvaltool:stable run examples/recipe_python.yml

Note that the container does not see the data available in the host by default.
You can make host data available with ``-B /path:/path/in/container``.

It might be useful to define a `bash alias
<https://opensource.com/article/19/7/bash-aliases>`_
or script to abbreviate the above command, for example

.. code-block:: bash

alias esmvaltool="singularity run -B $HOME:$HOME -B /data:/data docker://esmvalgroup/esmvaltool:stable"

would allow using the ``esmvaltool`` command without even noticing that the
tool is running inside a Singularity container.

Some clusters may not allow to connect to external services, in those cases
you can first create a singularity image locally:

.. code-block:: bash

singularity build esmvaltool.sif docker://esmvalgroup/esmvaltool:stable

and then upload the image file ``esmvaltool.sif`` to the cluster.
To run the container using the image file ``esmvaltool.sif`` use:

.. code-block:: bash

singularity run esmvaltool.sif run examples/recipe_python.yml


Install from source
Expand Down Expand Up @@ -207,14 +295,14 @@ If you would like to run Julia diagnostic scripts, you will also need to

.. code-block:: bash

julia esmvaltool/install/Julia/setup.jl
esmvaltool install Julia

If you would like to run R diagnostic scripts, you will also need to install the R
dependencies. Install the R dependency packages:

.. code-block:: bash

Rscript esmvaltool/install/R/setup.R
esmvaltool install R

The next step is to check that the installation works properly.
To do this, run the tool with:
Expand Down
23 changes: 10 additions & 13 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
# To build this container, go to ESMValTool root folder and execute:
# docker build -t esmvaltool:latest . -f docker/Dockerfile
FROM continuumio/miniconda3

# update the conda packages
RUN conda update -y conda pip
RUN apt install julia -y && apt-get clean
COPY ./environment.yml /src/ESMValTool/environment.yml
WORKDIR /src/ESMValTool
RUN conda update -y conda pip && conda env update --name base --file environment.yml && conda clean --all -y
jvegreg marked this conversation as resolved.
Show resolved Hide resolved

# install development tools
RUN apt-get update -y && apt-get install -y \
build-essential \
curl \
unzip
COPY ./esmvaltool/install/R /src/ESMValTool/esmvaltool/install/R
RUN Rscript ./esmvaltool/install/R/setup.R

# install environment packages
RUN conda install -c conda-forge -c esmvalgroup -c birdhouse esmvaltool

# run tests
RUN esmvaltool -h
COPY . /src/ESMValTool
RUN pip install -e . && pip cache purge && esmvaltool install Julia

ENTRYPOINT ["esmvaltool"]
CMD ["-h"]
17 changes: 17 additions & 0 deletions docker/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# To build this container, go to ESMValTool root folder and execute:
# docker build -t esmvaltool:development . -f docker/Dockerfile.dev
FROM continuumio/miniconda3

RUN apt install julia -y && apt-get clean
COPY ./environment.yml /src/ESMValTool/environment.yml
WORKDIR /src/ESMValTool
bouweandela marked this conversation as resolved.
Show resolved Hide resolved
RUN conda update -y conda pip && conda env update --name base --file environment.yml && conda clean --all -y

COPY ./esmvaltool/install/R /src/ESMValTool/esmvaltool/install/R
RUN Rscript ./esmvaltool/install/R/setup.R

COPY . /src/ESMValTool
RUN pip install -e .[test] && pip cache purge && esmvaltool install Julia && pip uninstall esmvaltool -y
RUN rm -rf /src
bouweandela marked this conversation as resolved.
Show resolved Hide resolved

ENTRYPOINT ["esmvaltool"]
16 changes: 16 additions & 0 deletions docker/Dockerfile.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# To build this container, go to ESMValTool root folder and execute:
# docker build -t esmvaltool:experimental . -f docker/Dockerfile.exp
FROM esmvalgroup/esmvalcore:latest

RUN apt install julia -y && apt-get clean
COPY ./environment.yml /src/ESMValTool/environment.yml
WORKDIR /src/ESMValTool
RUN conda update -y conda pip && conda env update --name base --file environment.yml && conda clean --all -y

COPY ./esmvaltool/install/R /src/ESMValTool/esmvaltool/install/R
RUN Rscript ./esmvaltool/install/R/setup.R

COPY . /src/ESMValTool
RUN pip install -e . && pip install ../ESMValCore && pip cache purge && esmvaltool install Julia

ENTRYPOINT ["esmvaltool"]
61 changes: 0 additions & 61 deletions docker/docker_guide.md

This file was deleted.

3 changes: 1 addition & 2 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ channels:
dependencies:
# Python packages that cannot be installed from PyPI:
- gdal
- esmpy
- esmvalcore>=2.0.0,<2.1
- esmf
# Non-Python dependencies
- cdo>=1.9.7
- imagemagick
Expand All @@ -17,7 +17,6 @@ dependencies:
- scikit-learn # may hit hw-specific issue if from pypi https://github.com/scikit-learn/scikit-learn/issues/14485

# Multi language support:
- python>=3.6
- ncl>=6.5.0 # this should always install 6.6.0 though
- r-base>=3.5
- r-curl # Dependency of lintr, but fails to compile because it cannot find libcurl installed from conda.
Expand Down
Loading