Skip to content

Commit fdd6c25

Browse files
authored
Fix unit tests (#448)
* FIX fixes and improves unit tests * ADD additional asserts to hunt down bug * ADD debug output * remove print statement
1 parent 67482f8 commit fdd6c25

File tree

5 files changed

+28
-4
lines changed

5 files changed

+28
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
*~
12
doc/generated
23
examples/.ipynb_checkpoints
34
# Byte-compiled / optimized / DLL files

openml/runs/functions.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,26 +231,28 @@ def _run_exists(task_id, setup_id):
231231
Parameters
232232
----------
233233
task_id: int
234+
234235
setup_id: int
235236
236237
Returns
237238
-------
238-
List of run ids iff these already exists on the server, False otherwise
239+
Set run ids for runs where flow setup_id was run on task_id. Empty
240+
set if it wasn't run yet.
239241
"""
240242
if setup_id <= 0:
241243
# openml setups are in range 1-inf
242-
return False
244+
return set()
243245

244246
try:
245247
result = list_runs(task=[task_id], setup=[setup_id])
246248
if len(result) > 0:
247249
return set(result.keys())
248250
else:
249-
return False
251+
return set()
250252
except OpenMLServerException as exception:
251253
# error code 512 implies no results. This means the run does not exist yet
252254
assert(exception.code == 512)
253-
return False
255+
return set()
254256

255257

256258
def _get_seeded_model(model, seed=None):

tests/test_runs/test_run_functions.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,10 +527,13 @@ def test_get_run_trace(self):
527527
flow = openml.flows.sklearn_to_flow(clf)
528528
flow_exists = openml.flows.flow_exists(flow.name, flow.external_version)
529529
self.assertIsInstance(flow_exists, int)
530+
self.assertGreater(flow_exists, 0)
530531
downloaded_flow = openml.flows.get_flow(flow_exists)
531532
setup_exists = openml.setups.setup_exists(downloaded_flow)
532533
self.assertIsInstance(setup_exists, int)
534+
self.assertGreater(setup_exists, 0)
533535
run_ids = _run_exists(task.task_id, setup_exists)
536+
self.assertGreater(len(run_ids), 0)
534537
run_id = random.choice(list(run_ids))
535538

536539
# now the actual unit test ...

tests/test_utils/__init__.py

Whitespace-only changes.

tests/test_utils/test_utils.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from openml.testing import TestBase
2+
import openml
3+
4+
5+
class OpenMLTaskTest(TestBase):
6+
_multiprocess_can_split_ = True
7+
8+
def test_list_all(self):
9+
list_datasets = openml.datasets.functions._list_datasets
10+
datasets = openml.utils.list_all(list_datasets)
11+
12+
self.assertGreaterEqual(len(datasets), 100)
13+
for did in datasets:
14+
self._check_dataset(datasets[did])
15+
16+
# TODO implement these tests
17+
# datasets = openml.utils.list_all(list_datasets, limit=50)
18+
# self.assertEqual(len(datasets), 50)

0 commit comments

Comments
 (0)