Skip to content

Commit a0ef724

Browse files
authored
Merge pull request #617 from openml/develop
[WIP] New release
2 parents 7a612ea + cefd097 commit a0ef724

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+5770
-3284
lines changed

.travis.yml

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,38 @@ env:
1515
- TEST_DIR=/tmp/test_dir/
1616
- MODULE=openml
1717
matrix:
18-
- DISTRIB="conda" PYTHON_VERSION="2.7" SKLEARN_VERSION="0.18.2"
19-
- DISTRIB="conda" PYTHON_VERSION="3.4" SKLEARN_VERSION="0.18.2"
20-
- DISTRIB="conda" PYTHON_VERSION="3.5" SKLEARN_VERSION="0.18.2"
21-
- DISTRIB="conda" PYTHON_VERSION="3.6" COVERAGE="true" SKLEARN_VERSION="0.18.2"
22-
- DISTRIB="conda" PYTHON_VERSION="3.6" EXAMPLES="true" SKLEARN_VERSION="0.18.2"
23-
- DISTRIB="conda" PYTHON_VERSION="3.6" DOCTEST="true" SKLEARN_VERSION="0.18.2"
18+
- DISTRIB="conda" PYTHON_VERSION="2.7" SKLEARN_VERSION="0.20.0"
19+
- DISTRIB="conda" PYTHON_VERSION="3.5" SKLEARN_VERSION="0.20.0"
20+
- DISTRIB="conda" PYTHON_VERSION="3.6" SKLEARN_VERSION="0.20.0"
21+
- DISTRIB="conda" PYTHON_VERSION="3.7" SKLEARN_VERSION="0.20.0" RUN_FLAKE8="true" SKIP_TESTS="true"
22+
- DISTRIB="conda" PYTHON_VERSION="3.7" SKLEARN_VERSION="0.20.0" COVERAGE="true" DOCPUSH="true"
23+
# Checks for older scikit-learn versions (which also don't nicely work with
24+
# Python3.7)
25+
- DISTRIB="conda" PYTHON_VERSION="3.6" SKLEARN_VERSION="0.19.2"
26+
- DISTRIB="conda" PYTHON_VERSION="3.6" SKLEARN_VERSION="0.18.2"
27+
28+
# Travis issue
29+
# https://github.com/travis-ci/travis-ci/issues/8920
30+
before_install:
31+
- python -c "import fcntl; fcntl.fcntl(1, fcntl.F_SETFL, 0)"
2432

2533
install: source ci_scripts/install.sh
2634
script: bash ci_scripts/test.sh
27-
after_success: source ci_scripts/success.sh
35+
after_success: source ci_scripts/success.sh && source ci_scripts/create_doc.sh $TRAVIS_BRANCH "doc_result"
36+
37+
# travis will check the deploy on condition, before actually running before_deploy
38+
# before_deploy: source ci_scripts/create_doc.sh $TRAVIS_BRANCH "doc_result"
39+
40+
# For more info regarding the deploy process and the github token look at:
41+
# https://docs.travis-ci.com/user/deployment/pages/
42+
43+
deploy:
44+
provider: pages
45+
skip_cleanup: true
46+
github_token: $GITHUB_TOKEN
47+
keep-history: true
48+
committer-from-gh: true
49+
on:
50+
all_branches: true
51+
condition: $doc_result = "success"
52+
local_dir: doc/$TRAVIS_BRANCH

CONTRIBUTING.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,14 @@ following rules before you submit a pull request:
7474
[task list](https://github.com/blog/1375-task-lists-in-gfm-issues-pulls-comments)
7575
in the PR description.
7676

77-
- All tests pass when running `nosetests`. On
77+
- All tests pass when running `pytest`. On
7878
Unix-like systems, check with (from the toplevel source folder):
7979

8080
```bash
81-
$ nosetests
81+
$ pytest
8282
```
8383

84-
For Windows systems, execute the command from an Anaconda Prompt or add `nosetests` to PATH before executing the command.
84+
For Windows systems, execute the command from an Anaconda Prompt or add `pytest` to PATH before executing the command.
8585

8686
- Documentation and high-coverage tests are necessary for enhancements to be
8787
accepted. Bug-fixes or new features should be provided with
@@ -92,15 +92,17 @@ following rules before you submit a pull request:
9292
For the Bug-fixes case, at the time of the PR, this tests should fail for
9393
the code base in develop and pass for the PR code.
9494

95+
- Add your changes to the changelog in the file doc/progress.rst.
96+
9597

9698
You can also check for common programming errors with the following
9799
tools:
98100

99101
- Code with good unittest **coverage** (at least 80%), check with:
100102

101103
```bash
102-
$ pip install nose coverage
103-
$ nosetests --with-coverage path/to/tests_for_package
104+
$ pip install pytest pytest-cov
105+
$ pytest --cov=. path/to/tests_for_package
104106
```
105107

106108
- No pyflakes warnings, check with:

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
PYTHON ?= python
44
CYTHON ?= cython
5-
NOSETESTS ?= nosetests
5+
PYTEST ?= pytest
66
CTAGS ?= ctags
77

88
all: clean inplace test
@@ -16,12 +16,12 @@ inplace:
1616
$(PYTHON) setup.py build_ext -i
1717

1818
test-code: in
19-
$(NOSETESTS) -s -v tests
19+
$(PYTEST) -s -v tests
2020
test-doc:
21-
$(NOSETESTS) -s -v doc/*.rst
21+
$(PYTEST) -s -v doc/*.rst
2222

2323
test-coverage:
2424
rm -rf coverage .coverage
25-
$(NOSETESTS) -s -v --with-coverage tests
25+
$(PYTEST) -s -v --cov=. tests
2626

2727
test: test-code test-sphinxext test-doc

appveyor.yml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
1+
clone_folder: C:\\projects\\openml-python
12

23
environment:
3-
global:
4-
CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\appveyor\\scikit-learn-contrib\\run_with_env.cmd"
4+
# global:
5+
# CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\appveyor\\scikit-learn-contrib\\run_with_env.cmd"
56

67
matrix:
78
- PYTHON: "C:\\Python35-x64"
89
PYTHON_VERSION: "3.5"
910
PYTHON_ARCH: "64"
1011
MINICONDA: "C:\\Miniconda35-x64"
11-
12-
- PYTHON: "C:\\Python35"
13-
PYTHON_VERSION: "3.5"
14-
PYTHON_ARCH: "32"
15-
MINICONDA: "C:\\Miniconda35"
1612

1713
matrix:
1814
fast_finish: true
@@ -36,17 +32,19 @@ install:
3632
# XXX: setuptools>23 is currently broken on Win+py3 with numpy
3733
# (https://github.com/pypa/setuptools/issues/728)
3834
- conda update --all --yes setuptools=23
35+
- conda install --yes nb_conda nb_conda_kernels
3936

4037
# Install the build and runtime dependencies of the project.
4138
- "cd C:\\projects\\openml-python"
42-
- conda install --quiet --yes mock numpy scipy nose requests scikit-learn nbformat python-dateutil nbconvert
39+
- conda install --quiet --yes scikit-learn=0.18.2
40+
- conda install --quiet --yes mock numpy scipy pytest requests nbformat python-dateutil nbconvert pandas matplotlib seaborn
4341
- pip install liac-arff xmltodict oslo.concurrency
44-
- "%CMD_IN_ENV% python setup.py install"
42+
- "pip install .[test]"
4543

4644

4745
# Not a .NET project, we build scikit-learn in the install step instead
4846
build: false
4947

5048
test_script:
5149
- "cd C:\\projects\\openml-python"
52-
- "%CMD_IN_ENV% python setup.py test"
50+
- "%CMD_IN_ENV% pytest"

ci_scripts/create_doc.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
set -euo pipefail
2+
3+
# Check if DOCPUSH is set
4+
if ! [[ -z ${DOCPUSH+x} ]]; then
5+
6+
if [[ "$DOCPUSH" == "true" ]]; then
7+
8+
# install documentation building dependencies
9+
pip install matplotlib seaborn sphinx pillow sphinx-gallery sphinx_bootstrap_theme cython numpydoc nbformat nbconvert
10+
11+
# $1 is the branch name
12+
# $2 is the global variable where we set the script status
13+
14+
if ! { [ $1 = "master" ] || [ $1 = "develop" ]; }; then
15+
{ echo "Not one of the allowed branches"; exit 0; }
16+
fi
17+
18+
# delete any previous documentation folder
19+
if [ -d doc/$1 ]; then
20+
rm -rf doc/$1
21+
fi
22+
23+
# create the documentation
24+
cd doc && make html 2>&1
25+
26+
# create directory with branch name
27+
# the documentation for dev/stable from git will be stored here
28+
mkdir $1
29+
30+
# get previous documentation from github
31+
git clone https://github.com/openml/openml-python.git --branch gh-pages --single-branch
32+
33+
# copy previous documentation
34+
cp -r openml-python/. $1
35+
rm -rf openml-python
36+
37+
# if the documentation for the branch exists, remove it
38+
if [ -d $1/$1 ]; then
39+
rm -rf $1/$1
40+
fi
41+
42+
# copy the updated documentation for this branch
43+
mkdir $1/$1
44+
cp -r build/html/. $1/$1
45+
46+
# takes a variable name as an argument and assigns the script outcome to a
47+
# variable with the given name. If it got this far, the script was successful
48+
function set_return() {
49+
# $1 is the variable where we save the script outcome
50+
local __result=$1
51+
local status='success'
52+
eval $__result="'$status'"
53+
}
54+
55+
set_return "$2"
56+
fi
57+
fi
58+
# Workaround for travis failure
59+
set +u

ci_scripts/flake8_diff.sh

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
#!/bin/bash
2+
3+
# Inspired from https://github.com/scikit-learn/scikit-learn/blob/master/build_tools/travis/flake8_diff.sh
4+
5+
# This script is used in Travis to check that PRs do not add obvious
6+
# flake8 violations. It relies on two things:
7+
# - find common ancestor between branch and
8+
# openml/openml-python remote
9+
# - run flake8 --diff on the diff between the branch and the common
10+
# ancestor
11+
#
12+
# Additional features:
13+
# - the line numbers in Travis match the local branch on the PR
14+
# author machine.
15+
# - ./ci_scripts/flake8_diff.sh can be run locally for quick
16+
# turn-around
17+
18+
set -e
19+
# pipefail is necessary to propagate exit codes
20+
set -o pipefail
21+
22+
PROJECT=openml/openml-python
23+
PROJECT_URL=https://github.com/$PROJECT.git
24+
25+
# Find the remote with the project name (upstream in most cases)
26+
REMOTE=$(git remote -v | grep $PROJECT | cut -f1 | head -1 || echo '')
27+
28+
# Add a temporary remote if needed. For example this is necessary when
29+
# Travis is configured to run in a fork. In this case 'origin' is the
30+
# fork and not the reference repo we want to diff against.
31+
if [[ -z "$REMOTE" ]]; then
32+
TMP_REMOTE=tmp_reference_upstream
33+
REMOTE=$TMP_REMOTE
34+
git remote add $REMOTE $PROJECT_URL
35+
fi
36+
37+
echo "Remotes:"
38+
echo '--------------------------------------------------------------------------------'
39+
git remote --verbose
40+
41+
# Travis does the git clone with a limited depth (50 at the time of
42+
# writing). This may not be enough to find the common ancestor with
43+
# $REMOTE/develop so we unshallow the git checkout
44+
if [[ -a .git/shallow ]]; then
45+
echo -e '\nTrying to unshallow the repo:'
46+
echo '--------------------------------------------------------------------------------'
47+
git fetch --unshallow
48+
fi
49+
50+
if [[ "$TRAVIS" == "true" ]]; then
51+
if [[ "$TRAVIS_PULL_REQUEST" == "false" ]]
52+
then
53+
# In main repo, using TRAVIS_COMMIT_RANGE to test the commits
54+
# that were pushed into a branch
55+
if [[ "$PROJECT" == "$TRAVIS_REPO_SLUG" ]]; then
56+
if [[ -z "$TRAVIS_COMMIT_RANGE" ]]; then
57+
echo "New branch, no commit range from Travis so passing this test by convention"
58+
exit 0
59+
fi
60+
COMMIT_RANGE=$TRAVIS_COMMIT_RANGE
61+
fi
62+
else
63+
# We want to fetch the code as it is in the PR branch and not
64+
# the result of the merge into develop. This way line numbers
65+
# reported by Travis will match with the local code.
66+
LOCAL_BRANCH_REF=travis_pr_$TRAVIS_PULL_REQUEST
67+
# In Travis the PR target is always origin
68+
git fetch origin pull/$TRAVIS_PULL_REQUEST/head:refs/$LOCAL_BRANCH_REF
69+
fi
70+
fi
71+
72+
# If not using the commit range from Travis we need to find the common
73+
# ancestor between $LOCAL_BRANCH_REF and $REMOTE/develop
74+
if [[ -z "$COMMIT_RANGE" ]]; then
75+
if [[ -z "$LOCAL_BRANCH_REF" ]]; then
76+
LOCAL_BRANCH_REF=$(git rev-parse --abbrev-ref HEAD)
77+
fi
78+
echo -e "\nLast 2 commits in $LOCAL_BRANCH_REF:"
79+
echo '--------------------------------------------------------------------------------'
80+
git --no-pager log -2 $LOCAL_BRANCH_REF
81+
82+
REMOTE_DEV_REF="$REMOTE/develop"
83+
# Make sure that $REMOTE_DEV_REF is a valid reference
84+
echo -e "\nFetching $REMOTE_DEV_REF"
85+
echo '--------------------------------------------------------------------------------'
86+
git fetch $REMOTE develop:refs/remotes/$REMOTE_DEV_REF
87+
LOCAL_BRANCH_SHORT_HASH=$(git rev-parse --short $LOCAL_BRANCH_REF)
88+
REMOTE_DEV_SHORT_HASH=$(git rev-parse --short $REMOTE_DEV_REF)
89+
90+
COMMIT=$(git merge-base $LOCAL_BRANCH_REF $REMOTE_DEV_REF) || \
91+
echo "No common ancestor found for $(git show $LOCAL_BRANCH_REF -q) and $(git show $REMOTE_DEV_REF -q)"
92+
93+
if [ -z "$COMMIT" ]; then
94+
exit 1
95+
fi
96+
97+
COMMIT_SHORT_HASH=$(git rev-parse --short $COMMIT)
98+
99+
echo -e "\nCommon ancestor between $LOCAL_BRANCH_REF ($LOCAL_BRANCH_SHORT_HASH)"\
100+
"and $REMOTE_DEV_REF ($REMOTE_DEV_SHORT_HASH) is $COMMIT_SHORT_HASH:"
101+
echo '--------------------------------------------------------------------------------'
102+
git --no-pager show --no-patch $COMMIT_SHORT_HASH
103+
104+
COMMIT_RANGE="$COMMIT_SHORT_HASH..$LOCAL_BRANCH_SHORT_HASH"
105+
106+
if [[ -n "$TMP_REMOTE" ]]; then
107+
git remote remove $TMP_REMOTE
108+
fi
109+
110+
else
111+
echo "Got the commit range from Travis: $COMMIT_RANGE"
112+
fi
113+
114+
echo -e '\nRunning flake8 on the diff in the range' "$COMMIT_RANGE" \
115+
"($(git rev-list $COMMIT_RANGE | wc -l) commit(s)):"
116+
echo '--------------------------------------------------------------------------------'
117+
# We need the following command to exit with 0 hence the echo in case
118+
# there is no match
119+
MODIFIED_FILES="$(git diff --name-only $COMMIT_RANGE || echo "no_match")"
120+
121+
check_files() {
122+
files="$1"
123+
shift
124+
options="$*"
125+
if [ -n "$files" ]; then
126+
# Conservative approach: diff without context (--unified=0) so that code
127+
# that was not changed does not create failures
128+
git diff --unified=0 $COMMIT_RANGE -- $files | flake8 --ignore E402 --diff --show-source $options
129+
fi
130+
}
131+
132+
if [[ "$MODIFIED_FILES" == "no_match" ]]; then
133+
echo "No file has been modified"
134+
else
135+
136+
check_files "$(echo "$MODIFIED_FILES" | grep -v ^examples)"
137+
check_files "$(echo "$MODIFIED_FILES" | grep ^examples)" \
138+
--config ./examples/.flake8
139+
fi
140+
echo -e "No problem detected by flake8\n"

ci_scripts/install.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ popd
2626
# provided versions
2727
conda create -n testenv --yes python=$PYTHON_VERSION pip
2828
source activate testenv
29-
pip install nose numpy scipy cython scikit-learn==$SKLEARN_VERSION \
29+
pip install pytest pytest-xdist pytest-timeout numpy scipy cython scikit-learn==$SKLEARN_VERSION \
3030
oslo.concurrency
3131

3232
if [[ "$EXAMPLES" == "true" ]]; then
@@ -37,10 +37,13 @@ if [[ "$DOCTEST" == "true" ]]; then
3737
pip install pandas sphinx_bootstrap_theme
3838
fi
3939
if [[ "$COVERAGE" == "true" ]]; then
40-
pip install codecov
40+
pip install codecov pytest-cov
41+
fi
42+
if [[ "$RUN_FLAKE8" == "true" ]]; then
43+
pip install flake8
4144
fi
4245

4346
python --version
4447
python -c "import numpy; print('numpy %s' % numpy.__version__)"
4548
python -c "import scipy; print('scipy %s' % scipy.__version__)"
46-
python setup.py develop
49+
pip install -e '.[test]'

0 commit comments

Comments
 (0)