Skip to content

Commit 9ea6624

Browse files
authored
Merge pull request #202 from openml/develop
Merge develop into master (on popular demand @ hackathon)
2 parents 4ecf600 + d855a51 commit 9ea6624

50 files changed

Lines changed: 162701 additions & 882 deletions

Some content is hidden

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

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ env:
1515
- TEST_DIR=/tmp/test_dir/
1616
- MODULE=openml
1717
matrix:
18-
- DISTRIB="conda" PYTHON_VERSION="2.7" NUMPY_VERSION="1.10.4" SCIPY_VERSION="0.17.0" CYTHON_VERSION="0.21"
19-
- DISTRIB="conda" PYTHON_VERSION="3.4" NUMPY_VERSION="1.10.4" SCIPY_VERSION="0.17.0" CYTHON_VERSION="0.23.4"
20-
- DISTRIB="conda" PYTHON_VERSION="3.5" COVERAGE="true" NUMPY_VERSION="1.10.4" SCIPY_VERSION="0.17.0" CYTHON_VERSION="0.23.4"
18+
- DISTRIB="conda" PYTHON_VERSION="2.7" NUMPY_VERSION="1.11" SCIPY_VERSION="0.17.0" CYTHON_VERSION="0.21" SKLEARN_VERSION="0.18"
19+
- DISTRIB="conda" PYTHON_VERSION="3.4" NUMPY_VERSION="1.11" SCIPY_VERSION="0.17.0" CYTHON_VERSION="0.23.4" SKLEARN_VERSION="0.18"
20+
- DISTRIB="conda" PYTHON_VERSION="3.5" COVERAGE="true" NUMPY_VERSION="1.11" SCIPY_VERSION="0.17.0" CYTHON_VERSION="0.23.4" SKLEARN_VERSION="0.18"
2121
install: source ci_scripts/install.sh
2222
script: bash ci_scripts/test.sh
2323
after_success: source ci_scripts/success.sh

README.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1-
[![Build Status](https://travis-ci.org/openml/openml-python.svg)](https://travis-ci.org/openml/openml-python)
2-
[![Code Health](https://landscape.io/github/openml/openml-python/master/landscape.svg)](https://landscape.io/github/openml/openml-python/master)
3-
[![Stories in Ready](https://badge.waffle.io/openml/openml-python.png?label=ready&title=Ready)](https://waffle.io/openml/openml-python)
4-
[![Coverage Status](https://coveralls.io/repos/github/openml/openml-python/badge.svg?branch=develop)](https://coveralls.io/github/openml/openml-python?branch=develop)
5-
61
A python interface for [OpenML](http://openml.org). You can find the documentation on the [openml-python website](https://openml.github.io/openml-python).
72

83
Please commit to the right branches following the gitflow pattern:
94
http://nvie.com/posts/a-successful-git-branching-model/
5+
6+
Master branch:
7+
8+
[![Build Status](https://travis-ci.org/openml/openml-python.svg?branch=master)](https://travis-ci.org/openml/openml-python)
9+
[![Code Health](https://landscape.io/github/openml/openml-python/master/landscape.svg)](https://landscape.io/github/openml/openml-python/master)
10+
[![Coverage Status](https://coveralls.io/repos/github/openml/openml-python/badge.svg?branch=master)](https://coveralls.io/github/openml/openml-python?branch=master)
11+
12+
Development branch:
13+
14+
[![Build Status](https://travis-ci.org/openml/openml-python.svg?branch=develop)](https://travis-ci.org/openml/openml-python)
15+
[![Code Health](https://landscape.io/github/openml/openml-python/master/landscape.svg)](https://landscape.io/github/openml/openml-python/master)
16+
[![Coverage Status](https://coveralls.io/repos/github/openml/openml-python/badge.svg?branch=develop)](https://coveralls.io/github/openml/openml-python?branch=develop)

ci_scripts/install.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ ls -l
1313
echo
1414
if [[ ! -f miniconda.sh ]]
1515
then
16-
wget http://repo.continuum.io/miniconda/Miniconda-3.6.0-Linux-x86_64.sh \
16+
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh \
1717
-O miniconda.sh
1818
fi
19-
chmod +x miniconda.sh && ./miniconda.sh -b
19+
chmod +x miniconda.sh && ./miniconda.sh -b -p $HOME/miniconda
2020
cd ..
2121
export PATH=/home/travis/miniconda/bin:$PATH
2222
conda update --yes conda
@@ -25,11 +25,11 @@ popd
2525
# Configure the conda environment and put it in the path using the
2626
# provided versions
2727
conda create -n testenv --yes python=$PYTHON_VERSION pip nose \
28-
numpy=$NUMPY_VERSION scipy=$SCIPY_VERSION cython=$CYTHON_VERSION matplotlib scikit-learn nbconvert nbformat jupyter_client ipython jupyter notebook ipykernel pandas
28+
numpy=$NUMPY_VERSION scipy=$SCIPY_VERSION cython=$CYTHON_VERSION \
29+
scikit-learn=$SKLEARN_VERSION pandas
2930
source activate testenv
30-
ipython kernel install
31-
3231

32+
pip install matplotlib jupyter notebook nbconvert nbformat jupyter_client ipython ipykernel
3333
if [[ "$COVERAGE" == "true" ]]; then
3434
pip install coverage coveralls
3535
fi

doc/progress.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@
66
Progress
77
========
88

9+
Changelog
10+
=========
11+
12+
0.3.0
13+
~~~~~
14+
15+
* Add this changelog (Matthias Feurer)
16+
* 2nd example notebook PyOpenML.ipynb (Joaquin Vanschoren)
17+
* Pagination support for list datasets and list tasks
18+
919
API calls
1020
=========
1121

examples/OpenMLDemo.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
"source": [
137137
"datasets = openml.datasets.list_datasets()\n",
138138
"\n",
139-
"data = pd.DataFrame(datasets)\n",
139+
"data = pd.DataFrame(datasets).transpose()\n",
140140
"print(\"First 10 of %s datasets...\" % len(datasets))\n",
141141
"print(data[:10][['did','name','NumberOfInstances','NumberOfFeatures']])"
142142
]
@@ -569,7 +569,7 @@
569569
"source": [
570570
"task_list = openml.tasks.list_tasks()\n",
571571
"\n",
572-
"tasks = pd.DataFrame(task_list)\n",
572+
"tasks = pd.DataFrame(task_list).transpose()\n",
573573
"print(\"First 5 of %s tasks:\" % len(tasks))\n",
574574
"print(tasks[:5][['tid','did','name','task_type','estimation_procedure']])"
575575
]
@@ -688,14 +688,14 @@
688688
"language_info": {
689689
"codemirror_mode": {
690690
"name": "ipython",
691-
"version": 3
691+
"version": 3.0
692692
},
693693
"file_extension": ".py",
694694
"mimetype": "text/x-python",
695695
"name": "python",
696696
"nbconvert_exporter": "python",
697697
"pygments_lexer": "ipython3",
698-
"version": "3.5.1"
698+
"version": "3.4.3"
699699
}
700700
},
701701
"nbformat": 4,

openml/__init__.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
The OpenML module implements a python interface to
3-
`OpenML <http://openml.org>`_, a collaborative platform for machine learning.
4-
OpenML can be used to
3+
`OpenML <https://www.openml.org>`_, a collaborative platform for machine
4+
learning. OpenML can be used to
55
66
* store, download and analyze datasets
77
* make experiments and their results (e.g. models, predictions)
@@ -10,7 +10,7 @@
1010
meta studies
1111
1212
In particular, this module implemts a python interface for the
13-
`OpenML REST API <http://openml.org/guide#!rest_services>`_
13+
`OpenML REST API <https://www.openml.org/guide#!rest_services>`_
1414
(`REST on wikipedia
1515
<http://en.wikipedia.org/wiki/Representational_state_transfer>`_).
1616
"""
@@ -19,12 +19,13 @@
1919
from .datasets import OpenMLDataset
2020
from . import datasets
2121
from . import runs
22+
from . import flows
2223
from .runs import OpenMLRun
2324
from .tasks import OpenMLTask, OpenMLSplit
2425
from .flows import OpenMLFlow
2526

2627

2728
__version__ = "0.2.1"
2829

29-
__all__ = ['OpenMLDataset', 'OpenMLRun', 'OpenMLSplit',
30-
'datasets', 'OpenMLTask', 'OpenMLFlow', 'config', 'runs']
30+
__all__ = ['OpenMLDataset', 'OpenMLRun', 'OpenMLSplit', 'datasets',
31+
'OpenMLTask', 'OpenMLFlow', 'config', 'runs', 'flows']

openml/_api_calls.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from .exceptions import OpenMLServerError
99

1010

11-
def _perform_api_call(call, file_dictionary=None,
11+
def _perform_api_call(call, data=None, file_dictionary=None,
1212
file_elements=None, add_authentication=True):
1313
"""
1414
Perform an API call at the OpenML server.
@@ -19,6 +19,8 @@ def _read_url(self, url, add_authentication=False, data=None, filePath=None):
1919
----------
2020
call : str
2121
The API call. For example data/list
22+
data : dict
23+
Dictionary with post-request payload.
2224
file_dictionary : dict
2325
Mapping of {filename: path} of files which should be uploaded to the
2426
server.
@@ -39,17 +41,20 @@ def _read_url(self, url, add_authentication=False, data=None, filePath=None):
3941
if not url.endswith("/"):
4042
url += "/"
4143
url += call
44+
45+
url = url.replace('=', '%3d')
46+
4247
if file_dictionary is not None or file_elements is not None:
43-
return _read_url_files(url, file_dictionary=file_dictionary,
48+
return _read_url_files(url, data=data, file_dictionary=file_dictionary,
4449
file_elements=file_elements)
45-
return _read_url(url)
50+
return _read_url(url, data)
4651

4752

48-
def _read_url_files(url, file_dictionary=None, file_elements=None):
49-
"""do a post request to url with data None, file content of
53+
def _read_url_files(url, data=None, file_dictionary=None, file_elements=None):
54+
"""do a post request to url with data, file content of
5055
file_dictionary and sending file_elements as files"""
5156

52-
data = {}
57+
data = {} if data is None else data
5358
data['api_key'] = config.apikey
5459
if file_elements is None:
5560
file_elements = {}
@@ -75,24 +80,25 @@ def _read_url_files(url, file_dictionary=None, file_elements=None):
7580
# 'gzip,deflate'
7681
response = requests.post(url, data=data, files=file_elements)
7782
if response.status_code != 200:
78-
raise OpenMLServerError(response.text)
83+
raise OpenMLServerError(('Status code: %d\n' % response.status_code) + response.text)
7984
if 'Content-Encoding' not in response.headers or \
8085
response.headers['Content-Encoding'] != 'gzip':
8186
warnings.warn('Received uncompressed content from OpenML for %s.' % url)
82-
return response.status_code, response.text
87+
return response.text
8388

8489

85-
def _read_url(url):
90+
def _read_url(url, data=None):
8691

87-
data = {}
92+
data = {} if data is None else data
8893
data['api_key'] = config.apikey
8994

9095
# Using requests.post sets header 'Accept-encoding' automatically to
9196
# 'gzip,deflate'
9297
response = requests.post(url, data=data)
98+
9399
if response.status_code != 200:
94-
raise OpenMLServerError(response.text)
100+
raise OpenMLServerError(('Status code: %d\n' % response.status_code) + response.text)
95101
if 'Content-Encoding' not in response.headers or \
96102
response.headers['Content-Encoding'] != 'gzip':
97103
warnings.warn('Received uncompressed content from OpenML for %s.' % url)
98-
return response.status_code, response.text
104+
return response.text

openml/config.py

Lines changed: 8 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""
2-
Stores module level information like the API key, cache director, private
3-
directory and the server.
2+
Stores module level information like the API key, cache directory and the server.
43
"""
54
import os
65
import sys
@@ -11,10 +10,9 @@
1110
format='[%(levelname)s] [%(asctime)s:%(name)s] %('
1211
'message)s', datefmt='%H:%M:%S')
1312

14-
server = "http://www.openml.org/api/v1/xml"
13+
server = "https://www.openml.org/api/v1/xml"
1514
apikey = ""
1615
cachedir = ""
17-
privatedir = ""
1816

1917

2018
if sys.version_info[0] < 3:
@@ -47,57 +45,35 @@ def _setup():
4745
config = _parse_config()
4846
apikey = config.get('FAKE_SECTION', 'apikey')
4947
server = config.get('FAKE_SECTION', 'server')
50-
private_dir = config.get('FAKE_SECTION', 'private_directory')
5148
cache_dir = config.get('FAKE_SECTION', 'cachedir')
52-
set_cache_directory(cache_dir, private_dir)
49+
set_cache_directory(cache_dir)
5350

5451

55-
def set_cache_directory(cachedir, privatedir=None):
52+
def set_cache_directory(cachedir):
5653
"""Set module-wide cache directory.
5754
5855
Sets the cache directory into which to download datasets, tasks etc.
59-
Also sets the private directory for storing local datasets.
6056
6157
Parameters
6258
----------
6359
cachedir : string
6460
Path to use as cache directory.
6561
66-
privatedir : string
67-
Path containing private datasets, tasks, etc.
68-
6962
See also
7063
--------
7164
get_cache_directory
72-
get_private_directory
7365
"""
74-
if privatedir is None:
75-
privatedir = cachedir
7666

7767
global _cachedir
78-
global _privatedir
7968
_cachedir = cachedir
80-
_privatedir = privatedir
8169

8270
# Set up the cache directories
8371
dataset_cache_dir = os.path.join(cachedir, "datasets")
8472
task_cache_dir = os.path.join(cachedir, "tasks")
8573
run_cache_dir = os.path.join(cachedir, 'runs')
8674

87-
# Set up the private directory
88-
_private_directory_datasets = os.path.join(
89-
privatedir, "datasets")
90-
_private_directory_tasks = os.path.join(
91-
privatedir, "tasks")
92-
_private_directory_runs = os.path.join(
93-
privatedir, "runs")
94-
95-
for dir_ in [cachedir, dataset_cache_dir,
96-
task_cache_dir, run_cache_dir,
97-
privatedir,
98-
_private_directory_datasets,
99-
_private_directory_tasks,
100-
_private_directory_runs]:
75+
76+
for dir_ in [cachedir, dataset_cache_dir, task_cache_dir, run_cache_dir]:
10177
if not os.path.exists(dir_) and not os.path.isdir(dir_):
10278
os.mkdir(dir_)
10379

@@ -108,8 +84,7 @@ def _parse_config():
10884
defaults = {'apikey': apikey,
10985
'server': server,
11086
'verbosity': 0,
111-
'cachedir': os.path.expanduser('~/.openml/cache'),
112-
'private_directory': os.path.expanduser('~/.openml/private')}
87+
'cachedir': os.path.expanduser('~/.openml/cache')}
11388

11489
config_file = os.path.expanduser('~/.openml/config')
11590
config = configparser.RawConfigParser(defaults=defaults)
@@ -147,26 +122,10 @@ def get_cache_directory():
147122
See also
148123
--------
149124
set_cache_directory
150-
get_private_directory
151125
"""
152126
return _cachedir
153127

154128

155-
def get_private_directory():
156-
"""Get the current private directory.
157-
158-
Returns
159-
-------
160-
privatecir : string
161-
The current private directory.
162-
163-
See also
164-
--------
165-
set_cache_directory
166-
get_cache_directory
167-
"""
168-
return _privatedir
169-
170-
__all__ = ["set_cache_directory", 'get_cache_directory', 'get_private_directory']
129+
__all__ = ["set_cache_directory", 'get_cache_directory']
171130

172131
_setup()

openml/datasets/__init__.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
from .functions import (list_datasets, list_datasets_by_tag,
2-
check_datasets_active, get_datasets, get_dataset)
1+
from .functions import (list_datasets, check_datasets_active,
2+
get_datasets, get_dataset)
33
from .dataset import OpenMLDataset
44

55
__all__ = ['check_datasets_active', 'get_dataset', 'get_datasets',
6-
'OpenMLDataset', 'list_datasets', 'list_datasets_by_tag',
7-
'list_datasets']
6+
'OpenMLDataset', 'list_datasets']

0 commit comments

Comments
 (0)