From 2316e22d1e2b8aed9437ddd7fa7e1e4d3b4e10d3 Mon Sep 17 00:00:00 2001 From: janvanrijn Date: Sat, 6 Oct 2018 15:48:27 -0400 Subject: [PATCH 1/4] fixes issue #565 and removes future / deprecation warnings --- tests/test_runs/test_run_functions.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/test_runs/test_run_functions.py b/tests/test_runs/test_run_functions.py index f622ea269..5b25d9dab 100644 --- a/tests/test_runs/test_run_functions.py +++ b/tests/test_runs/test_run_functions.py @@ -596,7 +596,8 @@ def test_get_run_trace(self): task = openml.tasks.get_task(task_id) # IMPORTANT! Do not sentinel this flow. is faster if we don't wait on openml server - clf = RandomizedSearchCV(RandomForestClassifier(random_state=42), + clf = RandomizedSearchCV(RandomForestClassifier(random_state=42, + n_estimators=5), {"max_depth": [3, None], "max_features": [1, 2, 3, 4], "bootstrap": [True, False], @@ -606,12 +607,10 @@ def test_get_run_trace(self): # [SPEED] make unit test faster by exploiting run information from the past try: # in case the run did not exists yet - run = openml.runs.run_model_on_task(task, clf, avoid_duplicate_runs=True) - trace = openml.runs.functions._create_trace_from_arff( - run._generate_trace_arff_dict() - ) + run = openml.runs.run_model_on_task(clf, task, + avoid_duplicate_runs=True) self.assertEqual( - len(trace.trace_iterations), + len(run.trace.trace_iterations), num_iterations * num_folds, ) run = run.publish() From e6392ba0cf4c4ad7606736a7cbf1a6b21350d80b Mon Sep 17 00:00:00 2001 From: janvanrijn Date: Sat, 6 Oct 2018 16:03:07 -0400 Subject: [PATCH 2/4] removes last deprecation warning --- tests/test_runs/test_run_functions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_runs/test_run_functions.py b/tests/test_runs/test_run_functions.py index 5b25d9dab..6fabac8d9 100644 --- a/tests/test_runs/test_run_functions.py +++ b/tests/test_runs/test_run_functions.py @@ -602,7 +602,7 @@ def test_get_run_trace(self): "max_features": [1, 2, 3, 4], "bootstrap": [True, False], "criterion": ["gini", "entropy"]}, - num_iterations, random_state=42) + num_iterations, random_state=42, cv=3) # [SPEED] make unit test faster by exploiting run information from the past try: From 00c8a06bb5bb29f8629c19d0203fcaa4f18fc9b7 Mon Sep 17 00:00:00 2001 From: janvanrijn Date: Tue, 9 Oct 2018 12:20:25 -0400 Subject: [PATCH 3/4] added additional raised error --- openml/setups/functions.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/openml/setups/functions.py b/openml/setups/functions.py index 7e7c296f8..e094803f8 100644 --- a/openml/setups/functions.py +++ b/openml/setups/functions.py @@ -37,6 +37,9 @@ def setup_exists(flow, model=None): if model is None: model = flow.model + if flow.model is None: + raise ValueError('Could not locate model (neither given as' + 'argument nor available as flow.model)') else: exists = flow_exists(flow.name, flow.external_version) if exists != flow.flow_id: From fef6c8955c40b1a5ca2c235f8ab41512be2b2709 Mon Sep 17 00:00:00 2001 From: janvanrijn Date: Tue, 9 Oct 2018 13:57:40 -0400 Subject: [PATCH 4/4] changed structure --- openml/setups/functions.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/openml/setups/functions.py b/openml/setups/functions.py index e094803f8..fb58dc1ab 100644 --- a/openml/setups/functions.py +++ b/openml/setups/functions.py @@ -20,7 +20,9 @@ def setup_exists(flow, model=None): ---------- flow : flow - The openml flow object. + The openml flow object. Should have flow id present for the main flow + and all subflows (i.e., it should be downloaded from the server by + means of flow.get, and not instantiated locally) sklearn_model : BaseEstimator, optional If given, the parameters are parsed from this model instead of the @@ -36,14 +38,16 @@ def setup_exists(flow, model=None): openml.flows.functions._check_flow_for_server_id(flow) if model is None: + # model is left empty. We take the model from the flow. model = flow.model if flow.model is None: raise ValueError('Could not locate model (neither given as' 'argument nor available as flow.model)') - else: - exists = flow_exists(flow.name, flow.external_version) - if exists != flow.flow_id: - raise ValueError('This should not happen!') + + # checks whether the flow exists on the server and flow ids align + exists = flow_exists(flow.name, flow.external_version) + if exists != flow.flow_id: + raise ValueError('This should not happen!') openml_param_settings = openml.runs.OpenMLRun._parse_parameters(flow, model) description = xmltodict.unparse(_to_dict(flow.flow_id,