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

initial version of Julia support #654

Merged
merged 32 commits into from
Mar 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
da37d44
add intial version of setup script for Julia
fdiblen Oct 12, 2018
4065b52
update the README to add Julia instructions
fdiblen Oct 12, 2018
8ce94a4
add jl extension to support Julia diagnostics
fdiblen Oct 12, 2018
9649158
solve script relative path issue
fdiblen Oct 12, 2018
9ddce0c
require Julia 1.0.2
jhardenberg Dec 7, 2018
2226941
merging version2_development
jhardenberg Dec 7, 2018
802030c
moved Julia folder to install
jhardenberg Dec 13, 2018
45aa120
make setup.jl work with all julia versions
jhardenberg Jan 21, 2019
48300c4
Merge branch 'version2_development' into version2_development_Julia_s…
bouweandela Feb 11, 2019
a92ff3b
Add julia diagnostic run test
bouweandela Feb 11, 2019
90f69d1
Unpin packages
bouweandela Feb 11, 2019
628775c
Add Rcpp to r_requirements.txt
bouweandela Feb 11, 2019
f1e2b0b
Add libunwind because pip install is failing on this
bouweandela Feb 18, 2019
38a91c5
Merge branch 'version2_development' into version2_development_Julia_s…
bouweandela Feb 19, 2019
a7197b9
Try to fix environment
bouweandela Feb 19, 2019
3715087
Correct typo
bouweandela Feb 19, 2019
f62ca9a
Add julia from apt
bouweandela Feb 19, 2019
ac1969d
Merge branch 'version2_development' into version2_development_Julia_s…
bouweandela Mar 8, 2019
6e24af3
Pin hdf5
bouweandela Mar 8, 2019
c572500
Add cdo test, install r-lintr from conda
bouweandela Mar 8, 2019
1091c5c
Add test for cdo
bouweandela Mar 8, 2019
a5ed254
Skip r-lintr installation if already installed
bouweandela Mar 8, 2019
1b6df53
Merge branch 'version2_development' into version2_development_Julia_s…
bouweandela Mar 18, 2019
5c83666
Add note on Julia
bouweandela Mar 18, 2019
4ae388b
Add conda package cache for python3_install test
bouweandela Mar 18, 2019
a86f19a
Fix yaml issue
bouweandela Mar 18, 2019
39be8b5
Improve julia install
bouweandela Mar 18, 2019
8187547
Finalize julia tests and cache .eggs dir
bouweandela Mar 18, 2019
b6f1ecd
Move cache to correct place
bouweandela Mar 18, 2019
1524a2e
Add Julia documentation
bouweandela Mar 18, 2019
1383d5f
Use logger and clean up a bit
bouweandela Mar 18, 2019
e0cd006
Remove executable bit
bouweandela Mar 18, 2019
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
38 changes: 27 additions & 11 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,22 @@ jobs:
# Create a file to checksum as cache key
date --rfc-3339 date > cache_key.txt
cat environment.yml >> cache_key.txt
cat esmvaltool/install/R/r_requirements.txt >> cache_key.txt
- restore_cache:
key: deps3-{{ .Branch }}-{{ checksum "cache_key.txt" }}
- run:
# Update/Create Conda Environment
# Update/Create Conda environment and run tests
command: |
. /opt/conda/etc/profile.d/conda.sh
conda update -y conda
conda env update
conda activate esmvaltool
Rscript esmvaltool/install/R/setup.R
conda install -yS r-lintr
python setup.py test
- save_cache:
key: deps3-{{ .Branch }}-{{ checksum "cache_key.txt" }}
paths:
- "/opt/conda/envs/esmvaltool"
- run:
# Activate Conda environment and run tests
command: |
. /opt/conda/etc/profile.d/conda.sh
conda activate esmvaltool
python setup.py test
- ".eggs"
- store_test_results:
path: test-reports/
- store_artifacts:
Expand All @@ -47,6 +42,8 @@ jobs:
- image: continuumio/miniconda3
steps:
- checkout
- restore_cache:
key: python3-install-{{ .Branch }}
- run:
command: |
. /opt/conda/etc/profile.d/conda.sh
Expand All @@ -55,11 +52,15 @@ jobs:
# Install
apt update > /logs/apt.txt 2>&1
apt -y install build-essential gfortran >> /logs/apt.txt 2>&1
wget https://julialang-s3.julialang.org/bin/linux/x64/1.0/julia-1.0.3-linux-x86_64.tar.gz
tar xfz julia-*-linux-x86_64.tar.gz
ln -s $(pwd)/julia-*/bin/julia /usr/bin/julia
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
Rscript esmvaltool/install/R/setup.R > /logs/R_install.txt 2>&1
julia esmvaltool/install/Julia/setup.jl > /logs/julia_install.txt 2>&1
# Log versions
dpkg -l > /logs/versions.txt
conda env export > /logs/environment.yml
Expand All @@ -73,6 +74,11 @@ jobs:
echo 0 | cdo -f nc input,r1x1 tmp.nc
ncdump tmp.nc | ncgen -k hdf5 -o tmp.nc
cdo -f nc copy tmp.nc tmp2.nc
- save_cache:
key: python3-install-{{ .Branch }}
paths:
- "/opt/conda/pkgs"
- ".eggs"
- store_artifacts:
path: /logs
- store_artifacts:
Expand Down Expand Up @@ -100,11 +106,15 @@ jobs:
# Install
apt update > /logs/apt.txt 2>&1
apt -y install build-essential gfortran >> /logs/apt.txt 2>&1
wget https://julialang-s3.julialang.org/bin/linux/x64/1.0/julia-1.0.3-linux-x86_64.tar.gz
tar xfz julia-*-linux-x86_64.tar.gz
ln -s $(pwd)/julia-*/bin/julia /usr/bin/julia
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 -e .[develop] > /logs/install.txt 2>&1
Rscript ./esmvaltool/install/R/setup.R > /logs/R_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
# Log versions
dpkg -l > /logs/versions.txt
conda env export > /logs/environment.yml
Expand Down Expand Up @@ -160,6 +170,9 @@ jobs:
mkdir /logs
apt update > /logs/apt.txt 2>&1
apt -y install build-essential gfortran >> /logs/apt.txt 2>&1
wget https://julialang-s3.julialang.org/bin/linux/x64/1.0/julia-1.0.3-linux-x86_64.tar.gz
tar xfz julia-*-linux-x86_64.tar.gz
ln -s $(pwd)/julia-*/bin/julia /usr/bin/julia
conda update -y conda > /logs/conda_base.txt 2>&1
conda install -y conda-build conda-verify >> /logs/conda_base.txt 2>&1
# Log versions
Expand Down Expand Up @@ -190,6 +203,9 @@ jobs:
mkdir /logs
apt update > /logs/apt.txt 2>&1
apt -y install build-essential gfortran >> /logs/apt.txt 2>&1
wget https://julialang-s3.julialang.org/bin/linux/x64/1.0/julia-1.0.3-linux-x86_64.tar.gz
tar xfz julia-*-linux-x86_64.tar.gz
ln -s $(pwd)/julia-*/bin/julia /usr/bin/julia
conda update -y conda > /logs/conda.txt 2>&1
# Create and activate conda environment
conda create -y --name esmvaltool
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ To install in development mode, follow these instructions.
- Update the esmvaltool conda environment `conda env update`
- Install in development mode: `pip install -e '.[develop]'`. If you are installing behind a proxy that does not trust the usual pip-urls 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 dependences.
- If you want to use Julia diagnostics, run `julia esmvaltool/install/Julia/setup.jl` to install the Julia dependences.
- Test that your installation was succesful by running `esmvaltool -h`.

## Running tests
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ Please see [CONTRIBUTING.md](https://github.com/ESMValGroup/ESMValTool/blob/vers
The Anaconda package can be found on [ESMValGroup Anaconda Channel.](https://anaconda.org/ESMValGroup)

First install gcc, g++ and gfortran if these are not available on your system. On Debian based systems, this can be done by
running `apt install build-essential gfortran`.
running `apt install build-essential gfortran`. In order to run
Julia diagnostics, you will also need to [install Julia](https://julialang.org/downloads/) version 1 or greater.

If you already installed Anaconda, you can install ESMValTool by running:
```
Expand Down
7 changes: 7 additions & 0 deletions doc/sphinx/source/user_guide2/install.inc
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,13 @@ the following command:
cd ESMValTool
python setup.py install

If you would like to run Julia diagnostic scripts, you will also need to
`install Julia <https://julialang.org/downloads/>`_ and the Julia dependencies:

.. code-block:: bash

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

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

Expand Down
4 changes: 2 additions & 2 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ channels:
dependencies:
# Python packages that cannot be installed from PyPI:
- iris
- esmpy
- matplotlib<3 # Can be installed from PyPI, but is a dependency of iris and should be pinned.
- python-stratify
- esmpy
- xarray # Can be installed from PyPI, but here to get a consistent set of depencies with iris.
# Non-Python dependencies
- graphviz
Expand All @@ -34,4 +34,4 @@ dependencies:
- jasper!=1.900.31 # pinned NCL dependency
- r-base
- libunwind # Needed for Python3.7+
# TODO: add julia
# - julia>=1.0.0 # The Julia package on conda is apparently broken
2 changes: 2 additions & 0 deletions esmvaltool/_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ def _initialize_cmd(self, script):
'py': [which('python')],
'ncl': [which('ncl'), '-n', '-p'],
'r': [which('Rscript')],
'jl': [which('julia')],
}
else:
profile_file = os.path.join(self.settings['run_dir'],
Expand All @@ -293,6 +294,7 @@ def _initialize_cmd(self, script):
],
'ncl': [which('ncl'), '-n', '-p'],
'r': [which('Rscript')],
'jl': [which('julia')],
}

if extension not in executables:
Expand Down
2 changes: 2 additions & 0 deletions esmvaltool/install/Julia/julia_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DataFrames
YAML
29 changes: 29 additions & 0 deletions esmvaltool/install/Julia/setup.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env julia

scriptDir=@__DIR__

if VERSION >= v"0.7.0-DEV.2005"
using Pkg
end

@info "Installing the packages from" scriptDir * "/julia_requirements.txt"
pkgName=in
open(scriptDir * "/julia_requirements.txt") do f
for i in enumerate(eachline(f))

pkgId=i[1]
pkgName=i[2]
@info "Installing" pkgName
Pkg.add(pkgName)

@info "Testing: ", pkgName
# load the package this needs to be called at top-level
Expr(:toplevel, :(module ($pkgName) end))

end
end

# Show the package list
@info "Installed Julia packages:"
Pkg.installed()
Pkg.status()
3 changes: 2 additions & 1 deletion language_support.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

tools=(R Rscript)
tools=(R Rscript julia)

for tool in "${tools[@]}"; do
if ! command -v "$tool" > /dev/null 2>&1; then
Expand All @@ -10,3 +10,4 @@ for tool in "${tools[@]}"; do
done

Rscript $PREFIX/lib/python*/site-packages/esmvaltool/install/R/setup.R >> $PREFIX/.messages.txt
julia $PREFIX/lib/python*/site-packages/esmvaltool/install/Julia/setup.jl >> $PREFIX/.messages.txt
1 change: 0 additions & 1 deletion meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ requirements:
- jasper!=1.900.31 # pinned NCL dependency
- r-base
- cdo
# TODO: add julia

test:
# TODO: add unit tests? This seems to require installing the tests
Expand Down
11 changes: 11 additions & 0 deletions tests/integration/test_diagnostic_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,17 @@ def main(cfg):
print(paste0("INFO Writing settings to ", settings$setting_name))
yaml::write_yaml(settings, settings$setting_name)
"""),
'diagnostic.jl':
dedent("""
import YAML
@info "Starting diagnostic script with" ARGS
config_file = ARGS[1]
cfg = YAML.load_file(config_file)
out_file = cfg["setting_name"]
@info "Copying file to" out_file
Base.Filesystem.cp(config_file, out_file)
@info "Done"
"""),
}


Expand Down