From 267ebd21dc53b967ba9259e15d3fba3cdf340aaa Mon Sep 17 00:00:00 2001 From: Andreas Mueller Date: Wed, 25 Sep 2019 15:04:39 -0400 Subject: [PATCH 1/3] store predictions_url in runs --- openml/runs/functions.py | 7 +++++-- tests/test_runs/test_run_functions.py | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/openml/runs/functions.py b/openml/runs/functions.py index 767a4a48a..623a2544e 100644 --- a/openml/runs/functions.py +++ b/openml/runs/functions.py @@ -687,10 +687,13 @@ def obtain_field(xml_obj, fieldname, from_server, cast=None): '(OpenML server error?)') else: output_data = run['oml:output_data'] + predictions_url = None if 'oml:file' in output_data: # multiple files, the normal case for file_dict in output_data['oml:file']: files[file_dict['oml:name']] = int(file_dict['oml:file_id']) + if file_dict['oml:name'] == 'predictions': + predictions_url = file_dict['oml:url'] if 'oml:evaluation' in output_data: # in normal cases there should be evaluations, but in case there # was an error these could be absent @@ -757,8 +760,8 @@ def obtain_field(xml_obj, fieldname, from_server, cast=None): dataset_id=dataset_id, output_files=files, evaluations=evaluations, fold_evaluations=fold_evaluations, - sample_evaluations=sample_evaluations, - tags=tags) + sample_evaluations=sample_evaluations, tags=tags, + predictions_url=predictions_url) def _get_cached_run(run_id): diff --git a/tests/test_runs/test_run_functions.py b/tests/test_runs/test_run_functions.py index 98df7dae8..15ca504b8 100644 --- a/tests/test_runs/test_run_functions.py +++ b/tests/test_runs/test_run_functions.py @@ -259,6 +259,8 @@ def _remove_random_state(flow): downloaded = openml.runs.get_run(run_.run_id) assert ('openml-python' in downloaded.tags) + assert run_.predictions_url == downloaded.predictions_url + assert run_.uploader_name == downloaded.uploader_name # TODO make sure that these attributes are instantiated when # downloading a run? Or make sure that the trace object is created when @@ -1112,6 +1114,9 @@ def test_get_run(self): self.assertEqual(run.fold_evaluations['f_measure'][0][i], value) assert ('weka' in run.tags) assert ('weka_3.7.12' in run.tags) + assert (run.predictions_url == + "https://www.openml.org/data/download/1667125/" + "weka_generated_predictions4575715871712251329.arff") def _check_run(self, run): self.assertIsInstance(run, dict) From 4eac10c4081048432ed0aee2447c7cd75ffff1c2 Mon Sep 17 00:00:00 2001 From: Andreas Mueller Date: Wed, 25 Sep 2019 16:46:12 -0400 Subject: [PATCH 2/3] can't test when uploading a new run as we don't have details locally --- tests/test_runs/test_run_functions.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/test_runs/test_run_functions.py b/tests/test_runs/test_run_functions.py index 15ca504b8..2003adc39 100644 --- a/tests/test_runs/test_run_functions.py +++ b/tests/test_runs/test_run_functions.py @@ -259,8 +259,6 @@ def _remove_random_state(flow): downloaded = openml.runs.get_run(run_.run_id) assert ('openml-python' in downloaded.tags) - assert run_.predictions_url == downloaded.predictions_url - assert run_.uploader_name == downloaded.uploader_name # TODO make sure that these attributes are instantiated when # downloading a run? Or make sure that the trace object is created when From bd0ae14af49f8272905eb26fdedf13fd344c2112 Mon Sep 17 00:00:00 2001 From: Matthias Feurer Date: Thu, 26 Sep 2019 11:06:09 +0200 Subject: [PATCH 3/3] Fix PEP8 --- tests/test_runs/test_run_functions.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/test_runs/test_run_functions.py b/tests/test_runs/test_run_functions.py index 2003adc39..74f8ee86f 100644 --- a/tests/test_runs/test_run_functions.py +++ b/tests/test_runs/test_run_functions.py @@ -1112,9 +1112,12 @@ def test_get_run(self): self.assertEqual(run.fold_evaluations['f_measure'][0][i], value) assert ('weka' in run.tags) assert ('weka_3.7.12' in run.tags) - assert (run.predictions_url == + assert ( + run.predictions_url == ( "https://www.openml.org/data/download/1667125/" - "weka_generated_predictions4575715871712251329.arff") + "weka_generated_predictions4575715871712251329.arff" + ) + ) def _check_run(self, run): self.assertIsInstance(run, dict)