Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*~
doc/generated
examples/.ipynb_checkpoints
# Byte-compiled / optimized / DLL files
Expand Down
10 changes: 6 additions & 4 deletions openml/runs/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,26 +231,28 @@ def _run_exists(task_id, setup_id):
Parameters
----------
task_id: int

setup_id: int

Returns
-------
List of run ids iff these already exists on the server, False otherwise
Set run ids for runs where flow setup_id was run on task_id. Empty
set if it wasn't run yet.
"""
if setup_id <= 0:
# openml setups are in range 1-inf
return False
return set()

try:
result = list_runs(task=[task_id], setup=[setup_id])
if len(result) > 0:
return set(result.keys())
else:
return False
return set()
except OpenMLServerException as exception:
# error code 512 implies no results. This means the run does not exist yet
assert(exception.code == 512)
return False
return set()


def _get_seeded_model(model, seed=None):
Expand Down
3 changes: 3 additions & 0 deletions tests/test_runs/test_run_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,10 +527,13 @@ def test_get_run_trace(self):
flow = openml.flows.sklearn_to_flow(clf)
flow_exists = openml.flows.flow_exists(flow.name, flow.external_version)
self.assertIsInstance(flow_exists, int)
self.assertGreater(flow_exists, 0)
downloaded_flow = openml.flows.get_flow(flow_exists)
setup_exists = openml.setups.setup_exists(downloaded_flow)
self.assertIsInstance(setup_exists, int)
self.assertGreater(setup_exists, 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can just use assertGreater instead of also making use of assertIsInstance, since if the argument is False it will throw AttributeError: 'NoneType' object has no attribute 'fail'.

run_ids = _run_exists(task.task_id, setup_exists)
self.assertGreater(len(run_ids), 0)
run_id = random.choice(list(run_ids))

# now the actual unit test ...
Expand Down
Empty file added tests/test_utils/__init__.py
Empty file.
18 changes: 18 additions & 0 deletions tests/test_utils/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from openml.testing import TestBase
import openml


class OpenMLTaskTest(TestBase):
_multiprocess_can_split_ = True

def test_list_all(self):
list_datasets = openml.datasets.functions._list_datasets
datasets = openml.utils.list_all(list_datasets)

self.assertGreaterEqual(len(datasets), 100)
for did in datasets:
self._check_dataset(datasets[did])

# TODO implement these tests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure you didn't forget these?

Copy link
Member

@ArlindKadra ArlindKadra Apr 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@janvanrijn you mean we should not verify the datasets?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean there's still a TODO in the PR ;)

(line 16)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah you are right, I did not see what you meant because of the lines selected. The TODO seems already implemented.

# datasets = openml.utils.list_all(list_datasets, limit=50)
# self.assertEqual(len(datasets), 50)