@@ -47,7 +47,8 @@ def get_params(self, deep=True):
4747 return {}
4848
4949
50- class TestRun (TestBase ):
50+ class TestSetupFunctions (TestBase ):
51+ _multiprocess_can_split_ = True
5152
5253 def test_nonexisting_setup_exists (self ):
5354 # first publish a non-existing flow
@@ -64,41 +65,49 @@ def test_nonexisting_setup_exists(self):
6465 setup_id = openml .setups .setup_exists (flow )
6566 self .assertFalse (setup_id )
6667
67- def test_existing_setup_exists (self ):
68- clfs = [ParameterFreeClassifier (), # zero hyperparemeters
69- GaussianNB (), # one hyperparameter
70- DecisionTreeClassifier (max_depth = 5 , # many hyperparameters
71- min_samples_split = 3 ,
72- # Not setting the random state will
73- # make this flow fail as running it
74- # will add a random random_state.
75- random_state = 1 )]
76-
77- for classif in clfs :
78- # first publish a nonexiting flow
79- flow = openml .flows .sklearn_to_flow (classif )
80- flow .name = 'TEST%s%s' % (get_sentinel (), flow .name )
81- flow .publish ()
82-
83- # although the flow exists, we can be sure there are no
84- # setups (yet) as it hasn't been ran
85- setup_id = openml .setups .setup_exists (flow )
86- self .assertFalse (setup_id )
87- setup_id = openml .setups .setup_exists (flow , classif )
88- self .assertFalse (setup_id )
89-
90- # now run the flow on an easy task:
91- task = openml .tasks .get_task (115 ) # diabetes
92- run = openml .runs .run_flow_on_task (task , flow )
93- # spoof flow id, otherwise the sentinel is ignored
94- run .flow_id = flow .flow_id
95- run .publish ()
96- # download the run, as it contains the right setup id
97- run = openml .runs .get_run (run .run_id )
98-
99- # execute the function we are interested in
100- setup_id = openml .setups .setup_exists (flow )
101- self .assertEquals (setup_id , run .setup_id )
68+ def _existing_setup_exists (self , classif ):
69+ flow = openml .flows .sklearn_to_flow (classif )
70+ flow .name = 'TEST%s%s' % (get_sentinel (), flow .name )
71+ flow .publish ()
72+
73+ # although the flow exists, we can be sure there are no
74+ # setups (yet) as it hasn't been ran
75+ setup_id = openml .setups .setup_exists (flow )
76+ self .assertFalse (setup_id )
77+ setup_id = openml .setups .setup_exists (flow , classif )
78+ self .assertFalse (setup_id )
79+
80+ # now run the flow on an easy task:
81+ task = openml .tasks .get_task (115 ) # diabetes
82+ run = openml .runs .run_flow_on_task (task , flow )
83+ # spoof flow id, otherwise the sentinel is ignored
84+ run .flow_id = flow .flow_id
85+ run .publish ()
86+ # download the run, as it contains the right setup id
87+ run = openml .runs .get_run (run .run_id )
88+
89+ # execute the function we are interested in
90+ setup_id = openml .setups .setup_exists (flow )
91+ self .assertEquals (setup_id , run .setup_id )
92+
93+ def test_existing_setup_exists_1 (self ):
94+ # Check a flow with zero hyperparameters
95+ self ._existing_setup_exists (ParameterFreeClassifier ())
96+
97+ def test_exisiting_setup_exists_2 (self ):
98+ # Check a flow with one hyperparameter
99+ self ._existing_setup_exists (GaussianNB ())
100+
101+ def test_existing_setup_exists_3 (self ):
102+ # Check a flow with many hyperparameters
103+ self ._existing_setup_exists (
104+ DecisionTreeClassifier (max_depth = 5 , # many hyperparameters
105+ min_samples_split = 3 ,
106+ # Not setting the random state will
107+ # make this flow fail as running it
108+ # will add a random random_state.
109+ random_state = 1 )
110+ )
102111
103112 def test_get_setup (self ):
104113 # no setups in default test server
0 commit comments