From 1a9726feb4ce06aa6a103f2c36f676426d6fe9ec Mon Sep 17 00:00:00 2001 From: Matthias Feurer Date: Fri, 4 Sep 2015 11:44:28 +0200 Subject: [PATCH 1/6] Add encrypted API key to .travis.yml --- .travis.yml | 3 +++ openml/apiconnector.py | 2 +- tests/test_apiconnector.py | 7 ++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index cd82a6f8f..e82cf2edb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,9 @@ python: - "2.7" - "3.4" +env: + secure: "cEIvnra5uFYph1v32vkpwRf1nxzCsSWfOtkjPSg0z6szLg3IJN7bhg/5A1S3DRRi0YLZ4CEJYLcCCcnj6OUwMotaVphFwJZ/Y3gGo1BXNHlrOmQL1vUR8LgJC+FN2PIFk4rAUM/Zq6oxldxkW8YtJx4l/RCcams8GRHKWtO+IR4=" + before_install: - sudo apt-get install -q libatlas3gf-base libatlas-dev liblapack-dev gfortran diff --git a/openml/apiconnector.py b/openml/apiconnector.py index a5d2308ea..0ce09ea5b 100644 --- a/openml/apiconnector.py +++ b/openml/apiconnector.py @@ -994,7 +994,7 @@ def _read_url(self, url, add_authentication=False, data=None, filePath=None): def _read_url(self, url, data=None, file_path=None): if data is None: data = {} - data['session_hash'] = self.config.get('FAKE_SECTION', 'apikey') + data['api_key'] = self.config.get('FAKE_SECTION', 'apikey') if file_path is not None: if os.path.isabs(file_path): diff --git a/tests/test_apiconnector.py b/tests/test_apiconnector.py index 33956c81b..a85c3f3a5 100644 --- a/tests/test_apiconnector.py +++ b/tests/test_apiconnector.py @@ -44,8 +44,13 @@ def setUp(self): os.chdir(self.workdir) self.cached = True + + try: + apikey = os.environ['OPENML_APIKEY'] + except: + apikey = None self.connector = APIConnector(cache_directory=self.workdir, - apikey='test') + apikey=apikey) def tearDown(self): os.chdir(self.cwd) From 5202c7b70db0ded755cc5d0c586fe9b24e049a4c Mon Sep 17 00:00:00 2001 From: Matthias Feurer Date: Fri, 4 Sep 2015 12:11:01 +0200 Subject: [PATCH 2/6] FIX: python 3 compability --- openml/apiconnector.py | 5 ++--- openml/entities/dataset.py | 2 +- tests/test_apiconnector.py | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/openml/apiconnector.py b/openml/apiconnector.py index 0ce09ea5b..2f7385040 100644 --- a/openml/apiconnector.py +++ b/openml/apiconnector.py @@ -947,7 +947,6 @@ def _create_run_from_xml(self, xml): url = file_[u"oml:url"] files[name] = url - print dic.keys() evaluations = dict() for evaluation in dic[u"oml:output_data"][u"oml:evaluation"]: name = evaluation[u"oml:name"] @@ -1009,8 +1008,8 @@ def _read_url(self, url, data=None, file_path=None): try: response = requests.post(url, data=data, files=fileElement) - except URLError, error: - print error + except URLError as error: + print(error) return response.status_code, response else: diff --git a/openml/entities/dataset.py b/openml/entities/dataset.py index 459bb346a..977129423 100644 --- a/openml/entities/dataset.py +++ b/openml/entities/dataset.py @@ -81,7 +81,7 @@ def __init__(self, id, name, version, description, format, creator, else: raise Exception() - with open(self.data_pickle_file, "w") as fh: + with open(self.data_pickle_file, "wb") as fh: pickle.dump((X, categorical, attribute_names), fh, -1) logger.debug("Saved dataset %d: %s to file %s" % (self.id, self.name, self.data_pickle_file)) diff --git a/tests/test_apiconnector.py b/tests/test_apiconnector.py index a85c3f3a5..92a50d9ac 100644 --- a/tests/test_apiconnector.py +++ b/tests/test_apiconnector.py @@ -71,7 +71,7 @@ def test_get_cached_datasets(self): datasets = connector.get_cached_datasets() self.assertIsInstance(datasets, dict) self.assertEqual(len(datasets), 2) - self.assertIsInstance(datasets.values()[0], OpenMLDataset) + self.assertIsInstance(list(datasets.values())[0], OpenMLDataset) def test_get_cached_dataset(self): workdir = os.path.dirname(os.path.abspath(__file__)) From d475897aeee119529a90372c799ef8655bbee70a Mon Sep 17 00:00:00 2001 From: Matthias Feurer Date: Fri, 4 Sep 2015 12:14:47 +0200 Subject: [PATCH 3/6] Add requests library to setup.py --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index a45438b30..4c1213f2c 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,8 @@ "scipy>=0.13.3", "xmltodict", "nose", - "numpydoc"], + "numpydoc", + "requests"], test_suite="nose.collector", classifiers=['Intended Audience :: Science/Research', 'Intended Audience :: Developers', From 3b53bb0185687b6ef7c549430602913d64f4e836 Mon Sep 17 00:00:00 2001 From: Matthias Feurer Date: Fri, 4 Sep 2015 12:18:17 +0200 Subject: [PATCH 4/6] Remove check for config file at test time --- tests/test_apiconnector.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/test_apiconnector.py b/tests/test_apiconnector.py index 92a50d9ac..d8c018c22 100644 --- a/tests/test_apiconnector.py +++ b/tests/test_apiconnector.py @@ -27,11 +27,6 @@ class TestAPIConnector(unittest.TestCase): """ def setUp(self): - config_file = os.path.expanduser('~/.openml/config') - if not os.path.exists(config_file): - raise Exception("OpenML config file required to run unit tests. " - "See https://github.com/openml/OpenML/wiki/Client-API") - self.cwd = os.getcwd() workdir = os.path.dirname(os.path.abspath(__file__)) self.workdir = os.path.join(workdir, "tmp") From 5c967c051c0e5a0444e2d4dfc847e60a3b9765d5 Mon Sep 17 00:00:00 2001 From: Matthias Feurer Date: Fri, 4 Sep 2015 13:38:32 +0200 Subject: [PATCH 5/6] Change APIKEY --- .travis.yml | 3 ++- tests/test_apiconnector.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index e82cf2edb..008b684c2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,8 @@ python: - "3.4" env: - secure: "cEIvnra5uFYph1v32vkpwRf1nxzCsSWfOtkjPSg0z6szLg3IJN7bhg/5A1S3DRRi0YLZ4CEJYLcCCcnj6OUwMotaVphFwJZ/Y3gGo1BXNHlrOmQL1vUR8LgJC+FN2PIFk4rAUM/Zq6oxldxkW8YtJx4l/RCcams8GRHKWtO+IR4=" + global: + secure: "KTU56Bhft39FhFnV80Ek+Ht8nwAAJWlLAN104bALBzQWVraoD/znx0gQnoS+YQDjzxgpj30UKBua/o8q1IrvkjxJb8yUBzpS0P1jcGwqmpVRoNdb3pQPk8R7fB9pTFiaJUQbdQJ2/xTrB/T9Kda0J1zq81LC1zSOxAxUL47UI50=" before_install: - sudo apt-get install -q libatlas3gf-base libatlas-dev liblapack-dev gfortran diff --git a/tests/test_apiconnector.py b/tests/test_apiconnector.py index d8c018c22..2ab976bf8 100644 --- a/tests/test_apiconnector.py +++ b/tests/test_apiconnector.py @@ -41,7 +41,7 @@ def setUp(self): self.cached = True try: - apikey = os.environ['OPENML_APIKEY'] + apikey = os.environ['OPENMLAPIKEY'] except: apikey = None self.connector = APIConnector(cache_directory=self.workdir, From 9712ddf720fd45ca86198b1802bc2ff2734f46e5 Mon Sep 17 00:00:00 2001 From: Matthias Feurer Date: Fri, 4 Sep 2015 13:40:22 +0200 Subject: [PATCH 6/6] Update .travis.yml --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 008b684c2..bab5584df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,8 +5,7 @@ python: - "3.4" env: - global: - secure: "KTU56Bhft39FhFnV80Ek+Ht8nwAAJWlLAN104bALBzQWVraoD/znx0gQnoS+YQDjzxgpj30UKBua/o8q1IrvkjxJb8yUBzpS0P1jcGwqmpVRoNdb3pQPk8R7fB9pTFiaJUQbdQJ2/xTrB/T9Kda0J1zq81LC1zSOxAxUL47UI50=" + secure: "KTU56Bhft39FhFnV80Ek+Ht8nwAAJWlLAN104bALBzQWVraoD/znx0gQnoS+YQDjzxgpj30UKBua/o8q1IrvkjxJb8yUBzpS0P1jcGwqmpVRoNdb3pQPk8R7fB9pTFiaJUQbdQJ2/xTrB/T9Kda0J1zq81LC1zSOxAxUL47UI50=" before_install: - sudo apt-get install -q libatlas3gf-base libatlas-dev liblapack-dev gfortran