Skip to content

Commit 7064899

Browse files
committed
fix unit tests
1 parent 57666fa commit 7064899

5 files changed

Lines changed: 12 additions & 18 deletions

File tree

openml/flows/functions.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,9 @@ def assert_flows_equal(flow1, flow2, ignore_parameters_on_older_children=None,
192192
if not name in attr2:
193193
raise ValueError('Component %s only available in '
194194
'argument2, but not in argument1.' % name)
195-
assert_flows_equal(attr1[name], attr2[name], ignore_parameters_on_older_children)
195+
assert_flows_equal(attr1[name], attr2[name],
196+
ignore_parameters_on_older_children,
197+
ignore_parameters)
196198

197199
else:
198200
if key == 'parameters':

openml/runs/functions.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,9 @@ def run_flow_on_task(task, flow, avoid_duplicate_runs=True, flow_tags=None,
6868

6969
# skips the run if it already exists and the user opts for this in the config file.
7070
# also, if the flow is not present on the server, the check is not needed.
71-
if avoid_duplicate_runs:
72-
if flow.flow_id is None:
73-
raise ValueError('Cannot check if a run exists if the '
74-
'corresponding flow has not been published yet!')
75-
flow_from_server = get_flow(flow.flow_id)
71+
flow_id = flow_exists(flow.name, flow.external_version)
72+
if avoid_duplicate_runs and flow_id:
73+
flow_from_server = get_flow(flow_id)
7674
setup_id = setup_exists(flow_from_server)
7775
ids = _run_exists(task.task_id, setup_id)
7876
if ids:

tests/test_flows/test_flow.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ def test_publish_flow_with_similar_components(self):
147147
flow1, sentinel = self._add_sentinel_to_flow_name(flow1, None)
148148
flow1.publish()
149149

150+
# In order to assign different upload times to the flows!
151+
time.sleep(1)
152+
150153
clf2 = sklearn.ensemble.VotingClassifier(
151154
[('dt', sklearn.tree.DecisionTreeClassifier(max_depth=2))])
152155
flow2 = openml.flows.sklearn_to_flow(clf2)

tests/test_runs/test_run_functions.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -180,18 +180,6 @@ def _check_detailed_evaluations(self, detailed_evaluations, num_repeats, num_fol
180180
self.assertGreater(evaluation, 0) # should take at least one millisecond (?)
181181
self.assertLess(evaluation, max_time_allowed)
182182

183-
def test_avoid_duplicate_runs_with_unpublished_flow(self):
184-
task_id = 115
185-
186-
clf = LogisticRegression()
187-
flow = sklearn_to_flow(clf)
188-
flow, _ = self._add_sentinel_to_flow_name(flow, None)
189-
task = openml.tasks.get_task(task_id)
190-
191-
self.assertRaisesRegexp(ValueError, 'Cannot check if a run exists if the corresponding flow has not been published yet!',
192-
openml.runs.run_flow_on_task, task=task,
193-
flow=flow, avoid_duplicate_runs=True)
194-
195183
def test_run_regression_on_classif_task(self):
196184
task_id = 115
197185

tests/test_setups/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Dummy to allow mock classes in the test files to have a version number for
2+
# their parent module
3+
__version__ = '0.1'

0 commit comments

Comments
 (0)