Skip to content

Commit 31bf79e

Browse files
authored
Merge pull request #167 from openml/feature/upload-flow
Feature/upload flow
2 parents e594abc + 146a42a commit 31bf79e

16 files changed

Lines changed: 1650 additions & 131 deletions

File tree

.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

ci_scripts/install.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ 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 matplotlib \
29+
scikit-learn=$SKLEARN_VERSION nbconvert nbformat jupyter_client ipython \
30+
jupyter notebook ipykernel pandas
2931
source activate testenv
3032
ipython kernel install
3133

openml/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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: 16 additions & 10 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,23 +80,24 @@ 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)
8287
return response.status_code, 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)

openml/flows/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
from .flow import OpenMLFlow
2+
from .sklearn_converter import sklearn_to_flow, flow_to_sklearn
3+
from .functions import get_flow
24

3-
__all__ = ['OpenMLFlow']
5+
__all__ = ['OpenMLFlow', 'create_flow_from_model', 'get_flow',
6+
'sklearn_to_flow', 'flow_to_sklearn']

0 commit comments

Comments
 (0)