Skip to content

Commit ac01913

Browse files
committed
Merge branch 'maintenance-1.5.x'
2 parents 9069a0a + edb460a commit ac01913

File tree

11 files changed

+409
-248
lines changed

11 files changed

+409
-248
lines changed

.circleci/config.yml

Lines changed: 18 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,61 +3,41 @@ version: 2
33
jobs:
44
build:
55
docker:
6-
- image: circleci/python:3.8.0a4-stretch
6+
- image: circleci/python:3.9
77
steps:
88
- run:
99
name: Install dependencies (debian)
1010
command: |
1111
sudo apt-get update
12-
sudo apt-get install gcc gfortran make binutils binutils-dev libc6-dev libbsd-dev
12+
sudo apt-get install gcc gfortran make binutils binutils-dev libc6-dev libbsd-dev
1313
sudo apt-get install libnetcdf-dev libhdf5-dev
14-
sudo apt-get install ruby rake
15-
sudo apt-get install python-dev libpython-dev
16-
sudo apt-get install python-netcdf4
17-
sudo apt-get install python-unittest2
14+
sudo apt-get install colorize
15+
sudo apt-get install cdo
16+
sudo apt-get install rake ruby-dev
1817
- run:
19-
name: Checkout cdo-bindings
20-
command: |
21-
git clone https://github.com/Try2Code/cdo-bindings.git
22-
- run:
23-
name: Install conda, CDO and environements for Python 2.7/3.7
24-
command: |
25-
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh && bash miniconda.sh -b -p $HOME/miniconda
26-
export PATH="$HOME/miniconda/bin:$PATH"
27-
hash -r
28-
conda config --set always_yes yes --set changeps1 no
29-
conda config --add channels conda-forge
30-
conda update -q --all
31-
conda info -a
32-
cd cdo-bindings
33-
conda env create --file .circleci/py2.7.yml
34-
conda env create --file .circleci/py3.7.yml
35-
- run:
36-
name: Install dependencies (rake)
18+
name: Install dependencies (testing)
3719
command: |
20+
pip install xarray netcdf4 six numpy unittest2
3821
gem install parallel --version '<= 1.12' --user -N
3922
gem install minitest colorize facets --user -N
4023
- run:
41-
name: Run Tests Python 2.7
24+
name: Checkout cdo-bindings
25+
command: |
26+
git clone -b ${CIRCLE_BRANCH} https://github.com/Try2Code/cdo-bindings.git
27+
- run:
28+
name: Run Tests Python 3.9
4229
command: |
43-
export PATH="$HOME/miniconda/bin:$PATH"
44-
source activate test_env_py27
4530
cdo -V
4631
type -p cdo
47-
python --version
32+
python3 --version
4833
cd cdo-bindings
49-
rake testPython CDO=$(type -p cdo) NO_COLOR=1
50-
conda remove -y netCDF4 xarray
51-
rake testPython CDO=$(type -p cdo) NO_COLOR=1
34+
rake testPython3 CDO=$(type -p cdo) NO_COLOR=1
5235
- run:
53-
name: Run Tests Python 3.7
36+
name: Run Tests Python 3.9 - no netCDF4/Xarray
5437
command: |
55-
export PATH="$HOME/miniconda/bin:$PATH"
56-
source activate test_env_py37
5738
cdo -V
5839
type -p cdo
59-
python --version
40+
python3 --version
6041
cd cdo-bindings
61-
rake testPython CDO=$(type -p cdo) NO_COLOR=1
62-
conda remove -y netCDF4 xarray
63-
rake testPython CDO=$(type -p cdo) NO_COLOR=1
42+
pip uninstall -y xarray netcdf4
43+
rake testPython3 CDO=$(type -p cdo) NO_COLOR=1

.circleci/py2.7.yml

Lines changed: 0 additions & 11 deletions
This file was deleted.

.circleci/py3.7.yml

Lines changed: 0 additions & 11 deletions
This file was deleted.

.github/workflows

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Ruby CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
matrix:
16+
ruby-version: ['3.1', '3.0', '2.7']
17+
18+
steps:
19+
- uses: actions/checkout@v3
20+
- name: Set up Ruby ${{ matrix.ruby-version }}
21+
uses: ruby/setup-ruby@359bebbc29cbe6c87da6bc9ea3bc930432750108
22+
with:
23+
ruby-version: ${{ matrix.ruby-version }}
24+
- name: Install dependencies
25+
run: apt-get install cdo libnetcdf-dev
26+
run: gem install narray narray-miss ruby-netcdf
27+
- name: Run tests
28+
run: rake testRuby

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Cdo.{rb,py} - Use Ruby/Python to access the power of CDO
22

3-
[![Python Tests](https://circleci.com/gh/Try2Code/cdo-bindings/tree/master.svg?style=shield)](https://circleci.com/gh/Try2Code/cdo-bindings)
3+
[![Tests](https://circleci.com/gh/Try2Code/cdo-bindings/tree/master.svg?style=shield)](https://circleci.com/gh/Try2Code/cdo-bindings)
44

55
Welcome to the scripting interfaces of [CDO](https://code.mpimet.mpg.de/projects/cdo/wiki)!
66
This repository contains interfaces for [Ruby](http://www.ruby-lang.org) and [Python](https://www.python.org). If you are not sure, wether this is useful or not, please have a look at:
@@ -32,6 +32,9 @@ Releases are distributed via [pypi](https://pypi.org/project/cdo) and [rubygems]
3232

3333
Cdo.{rb,py} requires a working CDO binary and Ruby 2.x or Python 2.7/3.x
3434

35+
**PLEASE NOTE: python-2.7 is unmaintained since January 2021**
36+
Many dependencies dropped support for 2.7 so I do manual testing with it,only.
37+
3538
Multi-dimensional arrays (numpy for python, narray for ruby) require addtional
3639
netcdf-io modules. These are [scipy](https://docs.scipy.org/doc/scipy/reference/io.html) or [python-netcdf4](https://pypi.python.org/pypi/netCDF4) for python and
3740
[ruby-netcdf](https://rubygems.org/gems/ruby-netcdf) for ruby. Because scipy has some difficulties with netcdf, I dropped the support of it with release 1.5.0.
@@ -204,6 +207,11 @@ http://code.mpimet.mpg.de/projects/cdo
204207
- many of them just set return type, so they will go to the _run()_ method
205208
- options only has effect during run of the tool, so this can also go into _run()_
206209
- the different input types can be handled in something like _input()_ or
210+
* **1.5.6**:
211+
- slight adoptions for CDO-2.0.0
212+
- limitted support for python-2.7: many other libs dropped support for it so I can only do limitted testing
213+
- new API: `cdo.config` holds a dictionary/hash with built-in CDO features (availble sind CDO-1.9.x), empty otherwise
214+
- removed cdo.hasLib() and cdo.libsVersion(): relied on unstable output of `cdo -V`. use cdo.config instead
207215
_infiles()_. This should clean up the lengthy code, which does this
208216
currently
209217
* **1.5.4(python-only)**:

Rakefile

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ CLEAN.include("**/*.log")
88
CLEAN.include("**/*.log.[0-9]*")
99
CLEAN.include("{ruby,python}/*.{grb,nc,png,svg}")
1010
CLEAN.include("python/tempPy*")
11+
CLEAN.include("ruby/tempRb*")
12+
CLEAN.include("/tmp/Cdorb*")
1113
CLEAN.include("python/test/tempPy*")
1214
CLEAN.include("python/__pycache__")
1315
CLEAN.include("python/test/__pycache__")
@@ -24,28 +26,37 @@ String.disable_colorization = (ENV.has_key?('NO_COLOR'))
2426
# following test should not be run in parallel with other tests
2527
SERIAL_TESTS = %w[test_system_tempdir]
2628

29+
spackEnvCommand = lambda {|modhash|
30+
lambda {|command| [". #{SpackEnv}" ,
31+
"spack load /#{modhash}",
32+
command,
33+
"spack unload /#{modhash}"].join(';')
34+
}
35+
}
2736

2837
def getCdoPackagesFromSpack
2938
# list possible cdo modules provided by spack
30-
cmd = [". #{SpackEnv}" , 'spack module tcl loads cdo | grep module'].join(';')
31-
modules = IO.popen(cmd).readlines.map(&:chomp)
39+
info = IO.popen([". #{SpackEnv}" ,
40+
'spack find -lp cdo | grep cdo'].join(';')).readlines.map(&:chomp).map(&:split).transpose
41+
42+
return {
43+
hash: info[0],
44+
version: info[1],
45+
path: info[2],
46+
}
3247
end
3348

3449
desc "run each CDO binary from the regression tests"
3550
task :checkRegression do |t|
36-
getCdoPackagesFromSpack.each {|spackModule|
37-
cmd = [". #{SpackEnv}" ,
38-
"module purge",
39-
spackModule,
40-
"cdo -V",
41-
"module purge"].join(';')
42-
43-
sh cmd
51+
info = getCdoPackagesFromSpack
52+
info[:hash].each_with_index {|spackHash,i|
53+
puts info[:version][i].colorize(:green)
54+
sh spackEnvCommand[spackHash]["cdo -V"]
4455
}
4556
end
4657
desc "list spack modules available for regression testing"
4758
task :listRegressionModules do |t|
48-
getCdoPackagesFromSpack.each {|mod| puts mod}
59+
pp getCdoPackagesFromSpack[:version]
4960
end
5061

5162
def pythonTest(name: nil,interpreter: PythonInterpreter)
@@ -89,7 +100,7 @@ end
89100

90101
desc "test for correct tempfile deletion (#{lang})"
91102
task "test#{lang}_tempfiles".to_sym do |t|
92-
# make sure no other testing process has already created cdo-tempfile
103+
# make sure no other testing process has already created cdo-tempfile
93104
unless Dir.glob("/tmp/Cdo*").empty? then
94105
warn "Cannot run temp file test - target dir /tmp is no empty"
95106
exit(1)
@@ -106,13 +117,10 @@ end
106117
desc "run regresssion for multiple CDO releases in #{lang}"
107118
task "test#{lang}Regression".to_sym, :name do |t,args|
108119
runTests = args.name.nil? ? "rake test#{lang}" : "rake test#{lang}[#{args.name}]"
109-
getCdoPackagesFromSpack.each {|spackModule|
110-
cmd = [". #{SpackEnv}" ,
111-
"module purge",
112-
spackModule,
113-
runTests,
114-
"module purge"].join(';')
115-
puts spackModule.split.last.colorize(:green)
120+
spackInfo = getCdoPackagesFromSpack
121+
spackInfo[:hash].each_with_index {|spackModule,i|
122+
cmd = spackEnvCommand[spackModule][runTests]
123+
puts "#{spackInfo[:version][i]}(#{spackModule.colorize(:green)})"
116124
sh cmd
117125
}
118126
end
@@ -123,18 +131,14 @@ end
123131
? "rake test#{lang}#{pythonRelease}" \
124132
: "rake test#{lang}#{pythonRelease}[#{args.name}]"
125133
getCdoPackagesFromSpack.each {|spackModule|
126-
cmd = [". #{SpackEnv}" ,
127-
"module purge",
128-
spackModule,
129-
runTests,
130-
"module purge"].join(';')
134+
cmd = spackEnvCommand[spackModule][runTests]
131135
puts spackModule.split.last.colorize(:green)
132136
sh cmd
133137
}
134138
end
135139
desc "test for correct tempfile deletion (#{lang}#{pythonRelease})"
136140
task "test#{lang}#{pythonRelease}_tempfiles".to_sym do |t|
137-
# make sure no other testing process has already created cdo-tempfile
141+
# make sure no other testing process has already created cdo-tempfile
138142
unless Dir.glob("/tmp/Cdo*").empty? then
139143
warn "Cannot run temp file test - target dir /tmp is no empty"
140144
exit(1)

0 commit comments

Comments
 (0)