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
17 changes: 12 additions & 5 deletions openml/setups/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ def setup_exists(flow, model=None):
----------

flow : flow
The openml flow object.
The openml flow object. Should have flow id present for the main flow
and all subflows (i.e., it should be downloaded from the server by
means of flow.get, and not instantiated locally)

sklearn_model : BaseEstimator, optional
If given, the parameters are parsed from this model instead of the
Expand All @@ -36,11 +38,16 @@ def setup_exists(flow, model=None):
openml.flows.functions._check_flow_for_server_id(flow)

if model is None:
# model is left empty. We take the model from the flow.
model = flow.model
else:
exists = flow_exists(flow.name, flow.external_version)
if exists != flow.flow_id:
raise ValueError('This should not happen!')
if flow.model is None:
raise ValueError('Could not locate model (neither given as'
'argument nor available as flow.model)')

# checks whether the flow exists on the server and flow ids align
exists = flow_exists(flow.name, flow.external_version)
if exists != flow.flow_id:
raise ValueError('This should not happen!')

openml_param_settings = openml.runs.OpenMLRun._parse_parameters(flow, model)
description = xmltodict.unparse(_to_dict(flow.flow_id,
Expand Down
13 changes: 6 additions & 7 deletions tests/test_runs/test_run_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,22 +596,21 @@ def test_get_run_trace(self):

task = openml.tasks.get_task(task_id)
# IMPORTANT! Do not sentinel this flow. is faster if we don't wait on openml server
clf = RandomizedSearchCV(RandomForestClassifier(random_state=42),
clf = RandomizedSearchCV(RandomForestClassifier(random_state=42,
n_estimators=5),
{"max_depth": [3, None],
"max_features": [1, 2, 3, 4],
"bootstrap": [True, False],
"criterion": ["gini", "entropy"]},
num_iterations, random_state=42)
num_iterations, random_state=42, cv=3)

# [SPEED] make unit test faster by exploiting run information from the past
try:
# in case the run did not exists yet
run = openml.runs.run_model_on_task(task, clf, avoid_duplicate_runs=True)
trace = openml.runs.functions._create_trace_from_arff(
run._generate_trace_arff_dict()
)
run = openml.runs.run_model_on_task(clf, task,
avoid_duplicate_runs=True)
self.assertEqual(
len(trace.trace_iterations),
len(run.trace.trace_iterations),
num_iterations * num_folds,
)
run = run.publish()
Expand Down