Skip to content

Commit

Permalink
Merge pull request #617 from openml/develop
Browse files Browse the repository at this point in the history
[WIP] New release
  • Loading branch information
mfeurer committed Feb 15, 2019
2 parents 7a612ea + cefd097 commit a0ef724
Show file tree
Hide file tree
Showing 71 changed files with 5,770 additions and 3,284 deletions.
39 changes: 32 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,38 @@ env:
- TEST_DIR=/tmp/test_dir/
- MODULE=openml
matrix:
- DISTRIB="conda" PYTHON_VERSION="2.7" SKLEARN_VERSION="0.18.2"
- DISTRIB="conda" PYTHON_VERSION="3.4" SKLEARN_VERSION="0.18.2"
- DISTRIB="conda" PYTHON_VERSION="3.5" SKLEARN_VERSION="0.18.2"
- DISTRIB="conda" PYTHON_VERSION="3.6" COVERAGE="true" SKLEARN_VERSION="0.18.2"
- DISTRIB="conda" PYTHON_VERSION="3.6" EXAMPLES="true" SKLEARN_VERSION="0.18.2"
- DISTRIB="conda" PYTHON_VERSION="3.6" DOCTEST="true" SKLEARN_VERSION="0.18.2"
- DISTRIB="conda" PYTHON_VERSION="2.7" SKLEARN_VERSION="0.20.0"
- DISTRIB="conda" PYTHON_VERSION="3.5" SKLEARN_VERSION="0.20.0"
- DISTRIB="conda" PYTHON_VERSION="3.6" SKLEARN_VERSION="0.20.0"
- DISTRIB="conda" PYTHON_VERSION="3.7" SKLEARN_VERSION="0.20.0" RUN_FLAKE8="true" SKIP_TESTS="true"
- DISTRIB="conda" PYTHON_VERSION="3.7" SKLEARN_VERSION="0.20.0" COVERAGE="true" DOCPUSH="true"
# Checks for older scikit-learn versions (which also don't nicely work with
# Python3.7)
- DISTRIB="conda" PYTHON_VERSION="3.6" SKLEARN_VERSION="0.19.2"
- DISTRIB="conda" PYTHON_VERSION="3.6" SKLEARN_VERSION="0.18.2"

# Travis issue
# https://github.com/travis-ci/travis-ci/issues/8920
before_install:
- python -c "import fcntl; fcntl.fcntl(1, fcntl.F_SETFL, 0)"

install: source ci_scripts/install.sh
script: bash ci_scripts/test.sh
after_success: source ci_scripts/success.sh
after_success: source ci_scripts/success.sh && source ci_scripts/create_doc.sh $TRAVIS_BRANCH "doc_result"

# travis will check the deploy on condition, before actually running before_deploy
# before_deploy: source ci_scripts/create_doc.sh $TRAVIS_BRANCH "doc_result"

# For more info regarding the deploy process and the github token look at:
# https://docs.travis-ci.com/user/deployment/pages/

deploy:
provider: pages
skip_cleanup: true
github_token: $GITHUB_TOKEN
keep-history: true
committer-from-gh: true
on:
all_branches: true
condition: $doc_result = "success"
local_dir: doc/$TRAVIS_BRANCH
12 changes: 7 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ following rules before you submit a pull request:
[task list](https://github.com/blog/1375-task-lists-in-gfm-issues-pulls-comments)
in the PR description.
- All tests pass when running `nosetests`. On
- All tests pass when running `pytest`. On
Unix-like systems, check with (from the toplevel source folder):
```bash
$ nosetests
$ pytest
```
For Windows systems, execute the command from an Anaconda Prompt or add `nosetests` to PATH before executing the command.
For Windows systems, execute the command from an Anaconda Prompt or add `pytest` to PATH before executing the command.
- Documentation and high-coverage tests are necessary for enhancements to be
accepted. Bug-fixes or new features should be provided with
Expand All @@ -92,15 +92,17 @@ following rules before you submit a pull request:
For the Bug-fixes case, at the time of the PR, this tests should fail for
the code base in develop and pass for the PR code.
- Add your changes to the changelog in the file doc/progress.rst.
You can also check for common programming errors with the following
tools:
- Code with good unittest **coverage** (at least 80%), check with:
```bash
$ pip install nose coverage
$ nosetests --with-coverage path/to/tests_for_package
$ pip install pytest pytest-cov
$ pytest --cov=. path/to/tests_for_package
```
- No pyflakes warnings, check with:
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

PYTHON ?= python
CYTHON ?= cython
NOSETESTS ?= nosetests
PYTEST ?= pytest
CTAGS ?= ctags

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

test-code: in
$(NOSETESTS) -s -v tests
$(PYTEST) -s -v tests
test-doc:
$(NOSETESTS) -s -v doc/*.rst
$(PYTEST) -s -v doc/*.rst

test-coverage:
rm -rf coverage .coverage
$(NOSETESTS) -s -v --with-coverage tests
$(PYTEST) -s -v --cov=. tests

test: test-code test-sphinxext test-doc
18 changes: 8 additions & 10 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
clone_folder: C:\\projects\\openml-python

environment:
global:
CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\appveyor\\scikit-learn-contrib\\run_with_env.cmd"
# global:
# CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\appveyor\\scikit-learn-contrib\\run_with_env.cmd"

matrix:
- PYTHON: "C:\\Python35-x64"
PYTHON_VERSION: "3.5"
PYTHON_ARCH: "64"
MINICONDA: "C:\\Miniconda35-x64"

- PYTHON: "C:\\Python35"
PYTHON_VERSION: "3.5"
PYTHON_ARCH: "32"
MINICONDA: "C:\\Miniconda35"

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

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


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

test_script:
- "cd C:\\projects\\openml-python"
- "%CMD_IN_ENV% python setup.py test"
- "%CMD_IN_ENV% pytest"
59 changes: 59 additions & 0 deletions ci_scripts/create_doc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
set -euo pipefail

# Check if DOCPUSH is set
if ! [[ -z ${DOCPUSH+x} ]]; then

if [[ "$DOCPUSH" == "true" ]]; then

# install documentation building dependencies
pip install matplotlib seaborn sphinx pillow sphinx-gallery sphinx_bootstrap_theme cython numpydoc nbformat nbconvert

# $1 is the branch name
# $2 is the global variable where we set the script status

if ! { [ $1 = "master" ] || [ $1 = "develop" ]; }; then
{ echo "Not one of the allowed branches"; exit 0; }
fi

# delete any previous documentation folder
if [ -d doc/$1 ]; then
rm -rf doc/$1
fi

# create the documentation
cd doc && make html 2>&1

# create directory with branch name
# the documentation for dev/stable from git will be stored here
mkdir $1

# get previous documentation from github
git clone https://github.com/openml/openml-python.git --branch gh-pages --single-branch

# copy previous documentation
cp -r openml-python/. $1
rm -rf openml-python

# if the documentation for the branch exists, remove it
if [ -d $1/$1 ]; then
rm -rf $1/$1
fi

# copy the updated documentation for this branch
mkdir $1/$1
cp -r build/html/. $1/$1

# takes a variable name as an argument and assigns the script outcome to a
# variable with the given name. If it got this far, the script was successful
function set_return() {
# $1 is the variable where we save the script outcome
local __result=$1
local status='success'
eval $__result="'$status'"
}

set_return "$2"
fi
fi
# Workaround for travis failure
set +u
140 changes: 140 additions & 0 deletions ci_scripts/flake8_diff.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
#!/bin/bash

# Inspired from https://github.com/scikit-learn/scikit-learn/blob/master/build_tools/travis/flake8_diff.sh

# This script is used in Travis to check that PRs do not add obvious
# flake8 violations. It relies on two things:
# - find common ancestor between branch and
# openml/openml-python remote
# - run flake8 --diff on the diff between the branch and the common
# ancestor
#
# Additional features:
# - the line numbers in Travis match the local branch on the PR
# author machine.
# - ./ci_scripts/flake8_diff.sh can be run locally for quick
# turn-around

set -e
# pipefail is necessary to propagate exit codes
set -o pipefail

PROJECT=openml/openml-python
PROJECT_URL=https://github.com/$PROJECT.git

# Find the remote with the project name (upstream in most cases)
REMOTE=$(git remote -v | grep $PROJECT | cut -f1 | head -1 || echo '')

# Add a temporary remote if needed. For example this is necessary when
# Travis is configured to run in a fork. In this case 'origin' is the
# fork and not the reference repo we want to diff against.
if [[ -z "$REMOTE" ]]; then
TMP_REMOTE=tmp_reference_upstream
REMOTE=$TMP_REMOTE
git remote add $REMOTE $PROJECT_URL
fi

echo "Remotes:"
echo '--------------------------------------------------------------------------------'
git remote --verbose

# Travis does the git clone with a limited depth (50 at the time of
# writing). This may not be enough to find the common ancestor with
# $REMOTE/develop so we unshallow the git checkout
if [[ -a .git/shallow ]]; then
echo -e '\nTrying to unshallow the repo:'
echo '--------------------------------------------------------------------------------'
git fetch --unshallow
fi

if [[ "$TRAVIS" == "true" ]]; then
if [[ "$TRAVIS_PULL_REQUEST" == "false" ]]
then
# In main repo, using TRAVIS_COMMIT_RANGE to test the commits
# that were pushed into a branch
if [[ "$PROJECT" == "$TRAVIS_REPO_SLUG" ]]; then
if [[ -z "$TRAVIS_COMMIT_RANGE" ]]; then
echo "New branch, no commit range from Travis so passing this test by convention"
exit 0
fi
COMMIT_RANGE=$TRAVIS_COMMIT_RANGE
fi
else
# We want to fetch the code as it is in the PR branch and not
# the result of the merge into develop. This way line numbers
# reported by Travis will match with the local code.
LOCAL_BRANCH_REF=travis_pr_$TRAVIS_PULL_REQUEST
# In Travis the PR target is always origin
git fetch origin pull/$TRAVIS_PULL_REQUEST/head:refs/$LOCAL_BRANCH_REF
fi
fi

# If not using the commit range from Travis we need to find the common
# ancestor between $LOCAL_BRANCH_REF and $REMOTE/develop
if [[ -z "$COMMIT_RANGE" ]]; then
if [[ -z "$LOCAL_BRANCH_REF" ]]; then
LOCAL_BRANCH_REF=$(git rev-parse --abbrev-ref HEAD)
fi
echo -e "\nLast 2 commits in $LOCAL_BRANCH_REF:"
echo '--------------------------------------------------------------------------------'
git --no-pager log -2 $LOCAL_BRANCH_REF

REMOTE_DEV_REF="$REMOTE/develop"
# Make sure that $REMOTE_DEV_REF is a valid reference
echo -e "\nFetching $REMOTE_DEV_REF"
echo '--------------------------------------------------------------------------------'
git fetch $REMOTE develop:refs/remotes/$REMOTE_DEV_REF
LOCAL_BRANCH_SHORT_HASH=$(git rev-parse --short $LOCAL_BRANCH_REF)
REMOTE_DEV_SHORT_HASH=$(git rev-parse --short $REMOTE_DEV_REF)

COMMIT=$(git merge-base $LOCAL_BRANCH_REF $REMOTE_DEV_REF) || \
echo "No common ancestor found for $(git show $LOCAL_BRANCH_REF -q) and $(git show $REMOTE_DEV_REF -q)"

if [ -z "$COMMIT" ]; then
exit 1
fi

COMMIT_SHORT_HASH=$(git rev-parse --short $COMMIT)

echo -e "\nCommon ancestor between $LOCAL_BRANCH_REF ($LOCAL_BRANCH_SHORT_HASH)"\
"and $REMOTE_DEV_REF ($REMOTE_DEV_SHORT_HASH) is $COMMIT_SHORT_HASH:"
echo '--------------------------------------------------------------------------------'
git --no-pager show --no-patch $COMMIT_SHORT_HASH

COMMIT_RANGE="$COMMIT_SHORT_HASH..$LOCAL_BRANCH_SHORT_HASH"

if [[ -n "$TMP_REMOTE" ]]; then
git remote remove $TMP_REMOTE
fi

else
echo "Got the commit range from Travis: $COMMIT_RANGE"
fi

echo -e '\nRunning flake8 on the diff in the range' "$COMMIT_RANGE" \
"($(git rev-list $COMMIT_RANGE | wc -l) commit(s)):"
echo '--------------------------------------------------------------------------------'
# We need the following command to exit with 0 hence the echo in case
# there is no match
MODIFIED_FILES="$(git diff --name-only $COMMIT_RANGE || echo "no_match")"

check_files() {
files="$1"
shift
options="$*"
if [ -n "$files" ]; then
# Conservative approach: diff without context (--unified=0) so that code
# that was not changed does not create failures
git diff --unified=0 $COMMIT_RANGE -- $files | flake8 --ignore E402 --diff --show-source $options
fi
}

if [[ "$MODIFIED_FILES" == "no_match" ]]; then
echo "No file has been modified"
else

check_files "$(echo "$MODIFIED_FILES" | grep -v ^examples)"
check_files "$(echo "$MODIFIED_FILES" | grep ^examples)" \
--config ./examples/.flake8
fi
echo -e "No problem detected by flake8\n"
9 changes: 6 additions & 3 deletions ci_scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ popd
# provided versions
conda create -n testenv --yes python=$PYTHON_VERSION pip
source activate testenv
pip install nose numpy scipy cython scikit-learn==$SKLEARN_VERSION \
pip install pytest pytest-xdist pytest-timeout numpy scipy cython scikit-learn==$SKLEARN_VERSION \
oslo.concurrency

if [[ "$EXAMPLES" == "true" ]]; then
Expand All @@ -37,10 +37,13 @@ if [[ "$DOCTEST" == "true" ]]; then
pip install pandas sphinx_bootstrap_theme
fi
if [[ "$COVERAGE" == "true" ]]; then
pip install codecov
pip install codecov pytest-cov
fi
if [[ "$RUN_FLAKE8" == "true" ]]; then
pip install flake8
fi

python --version
python -c "import numpy; print('numpy %s' % numpy.__version__)"
python -c "import scipy; print('scipy %s' % scipy.__version__)"
python setup.py develop
pip install -e '.[test]'
Loading

0 comments on commit a0ef724

Please sign in to comment.