Skip to content

Commit 24aa266

Browse files
committed
use conda-build for the tests
1 parent 6b84145 commit 24aa266

9 files changed

Lines changed: 180 additions & 109 deletions

File tree

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,4 @@ target/
7373

7474
# conda build files
7575
recipe/meta.yaml
76+
ci/conda-recipe/recipe_append.yaml

‎.travis.yml‎

Lines changed: 112 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,118 @@
11
language: generic
2+
sudo: false # use container based build
3+
4+
# set clone depth to false to make sure that conda build can write the
5+
# correct GIT_BUILD_STR
6+
git:
7+
depth: false
8+
29
env:
3-
global:
4-
- secure: "FnfYmn2KQLCmLVPDQ5rRSyunT8rEh/HsBejTCEX34oWnYMp3FGPWJC2je/KvTV18EORZ5KhiHBvkqMnmm6WvEbCJhX/snBTufco74famK44hriEzZ0z+u5hDt8tifjhIEtI+zJXrSDvgcoa2piOlRb9SAnWBGhtGMVYX5oFgyH0zya9OFdw+tC7oUddi+2XkInZt8GfnBya83jE4sfxGj0F9dQYAoVGV0RPE1bHnk+vXpCpPuJgwFRolou5z7yr+MWDMZQ6dm3ocCHJ977w/x0fHyRSLXti2ZsGNKKU4p109y/4E1s9p9lYIRg61LsS5XUrQBcwTJ+x6avmFFnNNlPYKFg0H/cshXS1BiCrM+CNHW5gU0o+qKfdnjc4JJ4SZ3f+4viP1rv0EpLjHdDyrvB0Dk0WpS+eVIloa0S1IVhQenDbiM2ehBvyYNdSiczj6cXple0DSF8o87r2cRYfOyQuEOTJvmJs117PVeMCGy86jrI6kKfs7v4L3KJqxY8DcNFUnCHGio+e4KE5HIuYgXqNvJAbGHzs8SRPROhaRWM7OlCMKsdrGZLtPKTl7lI7j/rco0hg/53S/36uR74DmwAu0LS+I5/WyXgNYjvbys/xKeyfChRVWkfN7z8zI70dx/E74WRHBchtnZIvxO432+cyK61fwC9nX6s+X0swY4MY="
10+
matrix:
11+
# python 3.8
12+
- PYTHON_VERSION=3.8 USE_PIP=false DEPLOY_CONDA=true
13+
- PYTHON_VERSION=3.8 USE_PIP=false DEPLOY_CONDA=false XARRAY_VERSION=0.14
14+
- PYTHON_VERSION=3.8 USE_PIP=true DEPLOY_CONDA=false
15+
# python 3.7
16+
- PYTHON_VERSION=3.7 USE_PIP=false DEPLOY_CONDA=true
17+
- PYTHON_VERSION=3.7 USE_PIP=false DEPLOY_CONDA=false XARRAY_VERSION=0.14
18+
- PYTHON_VERSION=3.7 USE_PIP=false DEPLOY_CONDA=false XARRAY_VERSION=0.13
19+
- PYTHON_VERSION=3.7 USE_PIP=false DEPLOY_CONDA=false XARRAY_VERSION=0.12
20+
global:
21+
- secure: "FnfYmn2KQLCmLVPDQ5rRSyunT8rEh/HsBejTCEX34oWnYMp3FGPWJC2je/KvTV18EORZ5KhiHBvkqMnmm6WvEbCJhX/snBTufco74famK44hriEzZ0z+u5hDt8tifjhIEtI+zJXrSDvgcoa2piOlRb9SAnWBGhtGMVYX5oFgyH0zya9OFdw+tC7oUddi+2XkInZt8GfnBya83jE4sfxGj0F9dQYAoVGV0RPE1bHnk+vXpCpPuJgwFRolou5z7yr+MWDMZQ6dm3ocCHJ977w/x0fHyRSLXti2ZsGNKKU4p109y/4E1s9p9lYIRg61LsS5XUrQBcwTJ+x6avmFFnNNlPYKFg0H/cshXS1BiCrM+CNHW5gU0o+qKfdnjc4JJ4SZ3f+4viP1rv0EpLjHdDyrvB0Dk0WpS+eVIloa0S1IVhQenDbiM2ehBvyYNdSiczj6cXple0DSF8o87r2cRYfOyQuEOTJvmJs117PVeMCGy86jrI6kKfs7v4L3KJqxY8DcNFUnCHGio+e4KE5HIuYgXqNvJAbGHzs8SRPROhaRWM7OlCMKsdrGZLtPKTl7lI7j/rco0hg/53S/36uR74DmwAu0LS+I5/WyXgNYjvbys/xKeyfChRVWkfN7z8zI70dx/E74WRHBchtnZIvxO432+cyK61fwC9nX6s+X0swY4MY="
22+
23+
os:
24+
- linux
25+
- osx
26+
27+
services:
28+
- xvfb
29+
530
matrix:
6-
include:
7-
# linux environments
8-
- env:
9-
- PYTHON_VERSION=3.7
10-
XARRAY_VERSION=0.12
11-
DEPLOY_CONDA=true
12-
os: linux
13-
- env:
14-
- PYTHON_VERSION=3.7
15-
XARRAY_VERSION=0.11
16-
os: linux
17-
- env:
18-
- PYTHON_VERSION=3.7
19-
XARRAY_VERSION=0.10
20-
os: linux
21-
- env:
22-
- PYTHON_VERSION=3.6
23-
XARRAY_VERSION=0.9
24-
DEPLOY_CONDA=true
25-
os: linux
26-
- env:
27-
- PYTHON_VERSION=3.6
28-
XARRAY_VERSION=0.8
29-
os: linux
30-
# osx environments
31-
- env:
32-
- PYTHON_VERSION=3.7
33-
XARRAY_VERSION=0.12
34-
DEPLOY_CONDA=true
35-
os: osx
36-
- env:
37-
- PYTHON_VERSION=3.7
38-
XARRAY_VERSION=0.11
39-
os: osx
40-
- env:
41-
- PYTHON_VERSION=3.7
42-
XARRAY_VERSION=0.10
43-
os: osx
31+
allow_failures:
32+
- env: PYTHON_VERSION=3.8 USE_PIP=true DEPLOY_CONDA=false
33+
34+
before_install:
35+
- if [[ "$TRAVIS_EVENT_TYPE" == "cron" ]]; then export DEPLOY_CONDA=false; fi
36+
# Remove homebrew.
37+
- |
38+
if [[ $TRAVIS_OS_NAME == "osx" ]]; then
39+
echo ""
40+
echo "Removing homebrew from Travis CI to avoid conflicts."
41+
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall > ~/uninstall_homebrew
42+
chmod +x ~/uninstall_homebrew
43+
~/uninstall_homebrew -fq
44+
rm ~/uninstall_homebrew
45+
fi
46+
# define functions to unset and reset encrypted variables
47+
- function unset_secure {
48+
CONDA_TOKEN_SAVE=$CONDA_REPO_TOKEN;
49+
unset CONDA_REPO_TOKEN;
50+
}
51+
- function reset_secure {
52+
export CONDA_REPO_TOKEN=$CONDA_TOKEN_SAVE;
53+
}
54+
- unset_secure
55+
# increase open files limit
56+
- ulimit -a
57+
- ulimit -Sn 10000
58+
- ulimit -a
59+
# select the os name for the conda installer
60+
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
61+
OS_NAME=MacOSX;
62+
else
63+
OS_NAME=Linux;
64+
fi
65+
# Install Miniconda.
66+
- |
67+
echo ""
68+
echo "Installing a fresh version of Miniconda."
69+
MINICONDA_URL="https://repo.continuum.io/miniconda"
70+
MINICONDA_FILE="Miniconda3-latest-${OS_NAME}-x86_64.sh"
71+
curl -L -O "${MINICONDA_URL}/${MINICONDA_FILE}"
72+
bash $MINICONDA_FILE -bp $HOME/miniconda3
73+
- source $HOME/miniconda3/bin/activate root
74+
- hash -r
75+
- reset_secure
76+
77+
before_script:
78+
- if [[ $TRAVIS_OS_NAME == "linux" ]]; then
79+
export "DISPLAY=:99.0";
80+
sh -e /etc/init.d/xvfb start;
81+
sleep 3;
82+
fi
4483

4584
install:
46-
# select the os name for the conda installer
47-
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
48-
OS_NAME=MacOSX;
49-
else
50-
OS_NAME=Linux;
51-
fi
52-
# We do this conditionally because it saves us some downloading if the
53-
# version is the same.
54-
- wget https://repo.continuum.io/miniconda/Miniconda3-latest-"${OS_NAME}"-x86_64.sh -O miniconda.sh
55-
# make sure we use an 'innocent' default matplotlib environment
56-
- touch matplotlibrc
57-
- bash miniconda.sh -b -p $HOME/miniconda
58-
- . $HOME/miniconda/etc/profile.d/conda.sh && conda activate base
59-
- pip install pyyaml # is somehow not included in the current conda installation
60-
- hash -r
61-
- conda config --set always_yes yes --set changeps1 no
62-
- conda update -q conda
63-
# install conda build and anaconda-client for deploy
64-
- conda install conda-build anaconda-client
65-
# Useful for debugging any issues with conda
66-
- conda info -a
67-
- 'ENVKEY=py"${PYTHON_VERSION}"_xr"${XARRAY_VERSION}"'
68-
- conda env create -f tests/envs/environment_$ENVKEY.yml
69-
- conda activate psyplot_$ENVKEY
70-
# install python cdo bindings
71-
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
72-
conda install -c conda-forge cdo python-cdo;
73-
export CDO="$HOME/miniconda/envs/psyplot_$ENVKEY/bin/cdo";
74-
fi
75-
- if [[ $TRAVIS_TAG == "" ]]; then export GIT_BRANCH=$TRAVIS_BRANCH; fi
76-
# install coveralls
77-
- pip install coveralls
78-
# install the test plugin
79-
- cd tests/test_plugin && python setup.py install && cd ../../
80-
# install psyplot
81-
- python setup.py install
82-
# export the environment for debugging
83-
- conda env export -n psyplot_$ENVKEY
84-
# print versions of all the important requirements
85-
- psyplot -aV
86-
# add conda-forge channel for build
87-
- conda config --add channels conda-forge
85+
# unset the global CONDA_REPO_TOKEN variable because it is not needed
86+
# during the tests. This decreases the vulnerability
87+
- unset_secure
88+
- |
89+
echo ""
90+
echo "Configuring conda."
91+
conda config --set always_yes yes --set changeps1 no
92+
conda config --add channels conda-forge
93+
conda config --add channels chilipp
94+
conda update -q conda
95+
conda install conda-build anaconda-client conda-verify
96+
- if [[ $TRAVIS_TAG == "" ]]; then
97+
export GIT_BRANCH=$TRAVIS_BRANCH;
98+
conda config --add channels chilipp/label/${TRAVIS_BRANCH}
99+
fi
100+
- python ci/setup_append.py ci/conda-recipe xarray=${XARRAY_VERSION}
101+
- if [[ $USE_PIP == true ]]; then pip install .; fi
102+
- conda info -a
103+
- conda list
104+
- reset_secure
88105
script:
89-
- coverage run --source=psyplot setup.py test -a "-v"
90-
- conda build ci/conda-recipe --python $PYTHON_VERSION
91-
# deploy here (don't use travis deploy because it requires homebrew)
92-
- if [[ $TRAVIS_PULL_REQUEST == "false" && $TRAVIS_REPO_SLUG == "Chilipp/psyplot" && $DEPLOY_CONDA == "true" ]]; then
93-
conda activate base;
94-
ci/deploy_anaconda.py;
95-
fi
96-
97-
after_success:
98-
- coveralls
106+
- unset_secure
107+
# install conda
108+
- if [[ $USE_PIP == true ]]; then
109+
coverage run --source=psyplot setup.py test -a "-v" && codecov
110+
else
111+
conda build conda-recipe --python $PYTHON_VERSION;
112+
fi
113+
# export the pw to make it available for the deploy
114+
- reset_secure
115+
# deploy here (don't use travis deploy because it requires homebrew)
116+
- if [[ $DEPLOY_CONDA == "true" && $USE_PIP == "false" && $TRAVIS_PULL_REQUEST == "false" && $TRAVIS_REPO_SLUG == "Chilipp/straditize" ]]; then
117+
ci/deploy_anaconda.py;
118+
fi

‎ci/conda-recipe/meta.yaml‎

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ package:
66
version: {{ data.get('version') }}
77

88
source:
9-
path: ../../
9+
git_url: ../../
1010

1111
build:
1212
number: {{ environ.get('GIT_DESCRIBE_NUMBER', 0) }}
@@ -18,7 +18,7 @@ build:
1818
skip: true # [py == 27]
1919

2020
requirements:
21-
build:
21+
host:
2222
- python
2323
- pip
2424
run:
@@ -29,17 +29,31 @@ requirements:
2929
- pyyaml
3030

3131
test:
32+
requires:
33+
- pytest
34+
- codecov
35+
- pytest-cov >=2.6.1
36+
- gdal
37+
- pyqt # [osx]
38+
- netcdf4
39+
- dask
40+
- scipy
41+
source_files:
42+
- tests
3243
commands:
3344
- psyplot --help
3445
- psyplot-plugin --help
46+
- pytest -v --cov={{ name|lower }}
47+
- codecov
3548
imports:
3649
- psyplot
50+
- psyplot.gdal_store
3751
- psyplot.compat
3852
- psyplot.config
3953
- psyplot.sphinxext
4054

4155
about:
42-
home: https://github.com/Chilipp/psyplot
56+
home: https://github.com/psyplot/psyplot
4357
license: GPL-2.0
4458
license_family: GPL
4559
license_file: LICENSE
@@ -51,4 +65,4 @@ about:
5165
the xarray package and integrates them into a software that can be used via
5266
command-line and via a GUI.
5367
doc_url: http://psyplot.readthedocs.io/en/latest/
54-
dev_url: https://github.com/Chilipp/psyplot
68+
dev_url: https://github.com/psyplot/psyplot

‎ci/deploy_anaconda.sh‎

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

‎ci/setup_append.py‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Script to generate conda build config to be appended
2+
import argparse
3+
import os.path as osp
4+
import yaml
5+
6+
parser = argparse.ArgumentParser()
7+
8+
parser.add_argument('recipe_dir', help="Path to the conda recipe directory")
9+
parser.add_argument(
10+
"packages", nargs="+", metavar="PACKAGE=VERSION",
11+
help="Package specifications to include in the test.requires section")
12+
13+
args = parser.parse_args()
14+
15+
output = osp.join(args.recipe_dir, 'recipe_append.yaml')
16+
packages = []
17+
18+
for pkg in args.packages:
19+
if pkg.strip().endswith("="): # no version specified
20+
packages.append(pkg.strip()[:-1])
21+
else:
22+
packages.append(pkg)
23+
24+
with open(output, 'w') as f:
25+
yaml.dump({"test": {"requires": packages}}, f)

‎psyplot/data.py‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2011,7 +2011,9 @@ def open_mfdataset(paths, decode_cf=True, decode_times=True,
20112011
raise IOError('no files to open')
20122012
if t_format is not None:
20132013
time, paths = get_tdata(t_format, paths)
2014-
kwargs['concat_dim'] = time
2014+
kwargs['concat_dim'] = 'time'
2015+
if xr_version > (0, 11):
2016+
kwargs['combine'] = 'nested'
20152017
if engine == 'gdal':
20162018
from psyplot.gdal_store import GdalStore
20172019
paths = list(map(GdalStore, paths))
@@ -2026,6 +2028,8 @@ def open_mfdataset(paths, decode_cf=True, decode_times=True,
20262028
decode_coords=decode_coords,
20272029
decode_times=decode_times)
20282030
ds.psy._concat_dim = kwargs.get('concat_dim')
2031+
if t_format is not None:
2032+
ds['time'] = time
20292033
return ds
20302034

20312035

@@ -2746,7 +2750,10 @@ def copy(self, deep=False):
27462750
This method returns a copy of the underlying array in the :attr:`arr`
27472751
attribute. It is more stable because it creates a new `psy` accessor"""
27482752
arr = self.arr.copy(deep)
2749-
arr.psy = InteractiveArray(arr)
2753+
try:
2754+
arr.psy = InteractiveArray(arr)
2755+
except AttributeError: # attribute is read-only for xarray >=0.13
2756+
pass
27502757
return arr
27512758

27522759
def to_interactive_list(self):

‎psyplot/gdal_store.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@
2020
from numpy import arange, nan, dtype
2121
from xarray import Variable
2222
from collections import OrderedDict
23-
from xarray.core.utils import FrozenOrderedDict
23+
try:
24+
from xarray.core.utils import FrozenOrderedDict
25+
except ImportError:
26+
FrozenOrderedDict = dict
2427
from xarray.backends.common import AbstractDataStore
2528
from psyplot.compat.pycompat import range
2629
from psyplot.warning import warn

‎psyplot/project.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import pickle
1717
from importlib import import_module
1818
from itertools import chain, repeat, cycle, count, islice
19-
from collections import Iterable, defaultdict
19+
from collections import defaultdict
2020
from functools import wraps, partial
2121
import xarray
2222
import pandas as pd
@@ -809,7 +809,7 @@ def save(fig):
809809

810810
def close():
811811
pass
812-
elif isinstance(output, Iterable): # a list of strings
812+
elif utils.is_iterable(output): # a list of strings
813813
output = cycle(output)
814814

815815
def save(fig):

0 commit comments

Comments
 (0)