Skip to content

Commit 8efcf9d

Browse files
authored
Merge pull request #706 from openml/develop
Release version 0.9
2 parents a0ef724 + 461814d commit 8efcf9d

File tree

94 files changed

+9623
-4422
lines changed

Some content is hidden

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

94 files changed

+9623
-4422
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ nosetests.xml
5757
coverage.xml
5858
*,cover
5959
.hypothesis/
60+
prof/
6061

6162
# Translations
6263
*.mo
@@ -74,3 +75,11 @@ target/
7475
# IDE
7576
.idea
7677
*.swp
78+
79+
# MYPY
80+
.mypy_cache
81+
dmypy.json
82+
dmypy.sock
83+
84+
# Tests
85+
.pytest_cache

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,14 @@ env:
1515
- TEST_DIR=/tmp/test_dir/
1616
- MODULE=openml
1717
matrix:
18-
- DISTRIB="conda" PYTHON_VERSION="2.7" SKLEARN_VERSION="0.20.0"
1918
- DISTRIB="conda" PYTHON_VERSION="3.5" SKLEARN_VERSION="0.20.0"
2019
- DISTRIB="conda" PYTHON_VERSION="3.6" SKLEARN_VERSION="0.20.0"
2120
- DISTRIB="conda" PYTHON_VERSION="3.7" SKLEARN_VERSION="0.20.0" RUN_FLAKE8="true" SKIP_TESTS="true"
2221
- DISTRIB="conda" PYTHON_VERSION="3.7" SKLEARN_VERSION="0.20.0" COVERAGE="true" DOCPUSH="true"
2322
# Checks for older scikit-learn versions (which also don't nicely work with
2423
# Python3.7)
2524
- DISTRIB="conda" PYTHON_VERSION="3.6" SKLEARN_VERSION="0.19.2"
26-
- DISTRIB="conda" PYTHON_VERSION="3.6" SKLEARN_VERSION="0.18.2"
25+
- DISTRIB="conda" PYTHON_VERSION="3.6" SKLEARN_VERSION="0.18.2" SCIPY_VERSION=1.2.0
2726

2827
# Travis issue
2928
# https://github.com/travis-ci/travis-ci/issues/8920

CONTRIBUTING.md

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ local disk:
1919
$ cd openml-python
2020
```
2121

22-
3. Swith to the ``develop`` branch:
22+
3. Switch to the ``develop`` branch:
2323

2424
```bash
2525
$ git checkout develop
@@ -31,7 +31,8 @@ local disk:
3131
$ git checkout -b feature/my-feature
3232
```
3333

34-
Always use a ``feature`` branch. It's good practice to never work on the ``master`` or ``develop`` branch! To make the nature of your pull request easily visible, please perpend the name of the branch with the type of changes you want to merge, such as ``feature`` if it contains a new feature, ``fix`` for a bugfix, ``doc`` for documentation and ``maint`` for other maintenance on the package.
34+
Always use a ``feature`` branch. It's good practice to never work on the ``master`` or ``develop`` branch!
35+
To make the nature of your pull request easily visible, please prepend the name of the branch with the type of changes you want to merge, such as ``feature`` if it contains a new feature, ``fix`` for a bugfix, ``doc`` for documentation and ``maint`` for other maintenance on the package.
3536

3637
4. Develop the feature on your feature branch. Add changed files using ``git add`` and then ``git commit`` files:
3738

@@ -59,18 +60,25 @@ We recommended that your contribution complies with the
5960
following rules before you submit a pull request:
6061

6162
- Follow the
62-
[pep8 style guilde](https://www.python.org/dev/peps/pep-0008/).
63+
[pep8 style guide](https://www.python.org/dev/peps/pep-0008/).
64+
With the following exceptions or additions:
65+
- The max line length is 100 characters instead of 80.
66+
- When creating a multi-line expression with binary operators, break before the operator.
67+
- Add type hints to all function signatures.
68+
(note: not all functions have type hints yet, this is work in progress.)
69+
- Use the [`str.format`](https://docs.python.org/3/library/stdtypes.html#str.format) over [`printf`](https://docs.python.org/3/library/stdtypes.html#printf-style-string-formatting) style formatting.
70+
E.g. use `"{} {}".format('hello', 'world')` not `"%s %s" % ('hello', 'world')`.
71+
(note: old code may still use `printf`-formatting, this is work in progress.)
6372

6473
- If your pull request addresses an issue, please use the pull request title
6574
to describe the issue and mention the issue number in the pull request description. This will make sure a link back to the original issue is
6675
created.
6776

6877
- An incomplete contribution -- where you expect to do more work before
69-
receiving a full review -- should be prefixed `[WIP]` (to indicate a work
70-
in progress) and changed to `[MRG]` when it matures. WIPs may be useful
78+
receiving a full review -- should be submitted as a `draft`. These may be useful
7179
to: indicate you are working on something to avoid duplicated work,
7280
request broad review of functionality or API, or seek collaborators.
73-
WIPs often benefit from the inclusion of a
81+
Drafts often benefit from the inclusion of a
7482
[task list](https://github.com/blog/1375-task-lists-in-gfm-issues-pulls-comments)
7583
in the PR description.
7684

@@ -105,18 +113,18 @@ tools:
105113
$ pytest --cov=. path/to/tests_for_package
106114
```
107115

108-
- No pyflakes warnings, check with:
116+
- No style warnings, check with:
109117

110118
```bash
111-
$ pip install pyflakes
112-
$ pyflakes path/to/module.py
119+
$ pip install flake8
120+
$ flake8 --ignore E402,W503 --show-source --max-line-length 100
113121
```
114122

115-
- No PEP8 warnings, check with:
123+
- No mypy (typing) issues, check with:
116124

117125
```bash
118-
$ pip install pep8
119-
$ pep8 path/to/module.py
126+
$ pip install mypy
127+
$ mypy openml --ignore-missing-imports --follow-imports skip
120128
```
121129

122130
Filing bugs
@@ -151,8 +159,8 @@ following rules before submitting:
151159
New contributor tips
152160
--------------------
153161

154-
A great way to start contributing to scikit-learn is to pick an item
155-
from the list of [Easy issues](https://github.com/openml/openml-python/issues?q=label%3Aeasy)
162+
A great way to start contributing to openml-python is to pick an item
163+
from the list of [Good First Issues](https://github.com/openml/openml-python/labels/Good%20first%20issue)
156164
in the issue tracker. Resolving these issues allow you to start
157165
contributing to the project without much prior knowledge. Your
158166
assistance in this area will be greatly appreciated by the more
@@ -175,6 +183,14 @@ information.
175183

176184
For building the documentation, you will need
177185
[sphinx](http://sphinx.pocoo.org/),
178-
[matplotlib](http://matplotlib.org/), and
179-
[pillow](http://pillow.readthedocs.io/en/latest/).
180-
[sphinx-bootstrap-theme](https://ryan-roemer.github.io/sphinx-bootstrap-theme/)
186+
[sphinx-bootstrap-theme](https://ryan-roemer.github.io/sphinx-bootstrap-theme/),
187+
[sphinx-gallery](https://sphinx-gallery.github.io/)
188+
and
189+
[numpydoc](https://numpydoc.readthedocs.io/en/latest/).
190+
```bash
191+
$ pip install sphinx sphinx-bootstrap-theme sphinx-gallery numpydoc
192+
```
193+
When dependencies are installed, run
194+
```bash
195+
$ sphinx-build -b html doc YOUR_PREFERRED_OUTPUT_DIRECTORY
196+
```

PULL_REQUEST_TEMPLATE.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@ the contribution guidelines: https://github.com/openml/openml-python/blob/master
55
Please make sure that:
66
77
* this pull requests is against the `develop` branch
8-
* you updated all docs
8+
* you updated all docs, this includes the changelog!
9+
* for any new function or class added, please add it to doc/api.rst
10+
* the list of classes and functions should be alphabetical
11+
* for any new functionality, consider adding a relevant example
912
-->
13+
1014
#### Reference Issue
1115
<!-- Example: Fixes #1234 -->
1216

appveyor.yml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,18 @@ install:
2929
- rmdir C:\\cygwin /s /q
3030

3131
# Update previous packages and install the build and runtime dependencies of the project.
32-
# XXX: setuptools>23 is currently broken on Win+py3 with numpy
33-
# (https://github.com/pypa/setuptools/issues/728)
34-
- conda update --all --yes setuptools=23
35-
- conda install --yes nb_conda nb_conda_kernels
32+
- conda update conda --yes
33+
- conda update --all --yes
3634

3735
# Install the build and runtime dependencies of the project.
3836
- "cd C:\\projects\\openml-python"
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
41-
- pip install liac-arff xmltodict oslo.concurrency
42-
- "pip install .[test]"
43-
37+
- "pip install .[examples,test]"
38+
- conda install --quiet --yes scikit-learn=0.20.0
39+
4440

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

4844
test_script:
4945
- "cd C:\\projects\\openml-python"
50-
- "%CMD_IN_ENV% pytest"
46+
- "%CMD_IN_ENV% pytest -n 4 --timeout=600 --timeout-method=thread -sv --ignore='test_OpenMLDemo.py'"

ci_scripts/flake8_diff.sh

Lines changed: 5 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -1,140 +1,7 @@
11
#!/bin/bash
22

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"
3+
# Update /CONTRIBUTING.md if these commands change.
4+
# The reason for not advocating using this script directly is that it
5+
# might not work out of the box on Windows.
6+
flake8 --ignore E402,W503 --show-source --max-line-length 100 $options
7+
mypy openml --ignore-missing-imports --follow-imports skip

ci_scripts/install.sh

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,29 @@ popd
2626
# provided versions
2727
conda create -n testenv --yes python=$PYTHON_VERSION pip
2828
source activate testenv
29-
pip install pytest pytest-xdist pytest-timeout numpy scipy cython scikit-learn==$SKLEARN_VERSION \
30-
oslo.concurrency
29+
30+
if [[ -v SCIPY_VERSION ]]; then
31+
conda install --yes scipy=$SCIPY_VERSION
32+
fi
33+
34+
python --version
35+
pip install -e '.[test]'
36+
python -c "import numpy; print('numpy %s' % numpy.__version__)"
37+
python -c "import scipy; print('scipy %s' % scipy.__version__)"
3138

3239
if [[ "$EXAMPLES" == "true" ]]; then
33-
pip install matplotlib jupyter notebook nbconvert nbformat jupyter_client \
34-
ipython ipykernel pandas seaborn
40+
pip install -e '.[examples]'
3541
fi
3642
if [[ "$DOCTEST" == "true" ]]; then
37-
pip install pandas sphinx_bootstrap_theme
43+
pip install sphinx_bootstrap_theme
3844
fi
3945
if [[ "$COVERAGE" == "true" ]]; then
4046
pip install codecov pytest-cov
4147
fi
4248
if [[ "$RUN_FLAKE8" == "true" ]]; then
43-
pip install flake8
49+
pip install flake8 mypy
4450
fi
4551

46-
python --version
47-
python -c "import numpy; print('numpy %s' % numpy.__version__)"
48-
python -c "import scipy; print('scipy %s' % scipy.__version__)"
49-
pip install -e '.[test]'
52+
# Install scikit-learn last to make sure the openml package installation works
53+
# from a clean environment without scikit-learn.
54+
pip install scikit-learn==$SKLEARN_VERSION

ci_scripts/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ run_tests() {
2222
PYTEST_ARGS=''
2323
fi
2424

25-
pytest -n 4 --timeout=600 --timeout-method=thread -sv --ignore='test_OpenMLDemo.py' $PYTEST_ARGS $test_dir
25+
pytest -n 4 --duration=20 --timeout=600 --timeout-method=thread -sv --ignore='test_OpenMLDemo.py' $PYTEST_ARGS $test_dir
2626
}
2727

2828
if [[ "$RUN_FLAKE8" == "true" ]]; then

doc/_static/codehighlightstyle.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.highlight .n { color: #000000 } /* code */
2+
.highlight .c1 { color: #1d8908 } /* comments */
3+
.highlight .mi { color: #0d9fe3; font-weight: bold } /* integers */
4+
.highlight .s1 { color: #d73c00 } /* string */
5+
.highlight .o { color: #292929 } /* operators */
6+
/* Background color for code highlights. Color for bash highlights */
7+
pre { background-color: #fbfbfb; color: #000000 }

0 commit comments

Comments
 (0)