Skip to content

Commit 19c1edd

Browse files
janvanrijnmfeurer
authored andcommitted
tiny updates to study PR (#628)
1 parent 45fe2a1 commit 19c1edd

3 files changed

Lines changed: 32 additions & 3 deletions

File tree

tests/test_runs/test_run_functions.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,7 @@ def determine_grid_size(param_grid):
456456
# suboptimal (slow), and not guaranteed to work if evaluation
457457
# engine is behind.
458458
# TODO: mock this? We have the arff already on the server
459-
print(run.run_id)
460-
self._wait_for_processed_run(run.run_id, 10)
459+
self._wait_for_processed_run(run.run_id, 200)
461460
try:
462461
model_prime = openml.runs.initialize_model_from_trace(
463462
run.run_id, 0, 0)

tests/test_study/test_study_functions.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,31 @@ def test_publish_study(self):
131131

132132
res = openml.study.delete_study(study_id)
133133
self.assertTrue(res)
134+
135+
def test_study_attach_illegal(self):
136+
run_list = openml.runs.list_runs(size=10)
137+
self.assertEqual(len(run_list), 10)
138+
run_list_more = openml.runs.list_runs(size=20)
139+
self.assertEqual(len(run_list_more), 20)
140+
141+
study = openml.study.create_study(
142+
alias=None,
143+
benchmark_suite=None,
144+
name='study with illegal runs',
145+
description='none',
146+
run_ids=list(run_list.keys())
147+
)
148+
study_id = study.publish()
149+
study_original = openml.study.get_study(study_id)
150+
151+
with self.assertRaisesRegex(openml.exceptions.OpenMLServerException,
152+
'Problem attaching entities.'):
153+
# run id does not exists
154+
openml.study.attach_to_study(study_id, [0])
155+
156+
with self.assertRaisesRegex(openml.exceptions.OpenMLServerException,
157+
'Problem attaching entities.'):
158+
# some runs already attached
159+
openml.study.attach_to_study(study_id, list(run_list_more.keys()))
160+
study_downloaded = openml.study.get_study(study_id)
161+
self.assertListEqual(study_original.runs, study_downloaded.runs)

tests/test_utils/test_utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ def test_list_datasets_with_high_size_parameter(self):
4646
datasets_a = openml.datasets.list_datasets()
4747
datasets_b = openml.datasets.list_datasets(size=np.inf)
4848

49-
self.assertEqual(len(datasets_a), len(datasets_b))
49+
# note that in the meantime the number of datasets could have increased
50+
# due to tests that run in parralel.
51+
self.assertGreaterEqual(len(datasets_b), len(datasets_a))
5052

5153
def test_list_all_for_tasks(self):
5254
required_size = 1068 # default test server reset value

0 commit comments

Comments
 (0)