24
24
# pylint: disable=too-many-arguments
25
25
def create_experiment (
26
26
name , version = None , space = None , algorithms = None ,
27
- strategy = None , max_trials = None , storage = None , branching = None ,
27
+ strategy = None , max_trials = None , max_broken = None , storage = None , branching = None ,
28
28
max_idle_time = None , heartbeat = None , working_dir = None , debug = False ):
29
29
"""Create an experiment
30
30
@@ -53,12 +53,12 @@ def create_experiment(
53
53
2.2) Some other arguments than the name are given.
54
54
55
55
The configuration will be fetched from database and given arguments will override them.
56
- ``max_trials`` may be overwritten in DB, but any other changes will lead to a branching. Instead
57
- of creating the experiment ``(name, version)``, it will create a new experiment
58
- ``(name, version+1)`` which will have the same configuration than ``(name, version)`` except for
59
- the differing arguments given by user. This new experiment will have access to trials of
60
- ``(name, version)``, adapted according to the differences between ``version`` and ``version+1``.
61
- A previous version can be accessed by specifying the ``version`` argument.
56
+ ``max_trials`` and ``max_broken`` may be overwritten in DB, but any other changes will lead to a
57
+ branching. Instead of creating the experiment ``(name, version)``, it will create a new
58
+ experiment ``(name, version+1)`` which will have the same configuration than ``(name, version)``
59
+ except for the differing arguments given by user. This new experiment will have access to trials
60
+ of ``(name, version)``, adapted according to the differences between ``version`` and
61
+ ``version+1``. A previous version can be accessed by specifying the ``version`` argument.
62
62
63
63
Causes of experiment branching are:
64
64
@@ -91,6 +91,8 @@ def create_experiment(
91
91
Parallel strategy to use to parallelize the algorithm.
92
92
max_trials: int, optional
93
93
Maximum number or trials before the experiment is considered done.
94
+ max_broken: int, optional
95
+ Number of broken trials for the experiment to be considered broken.
94
96
storage: dict, optional
95
97
Configuration of the storage backend.
96
98
working_dir: str, optional
@@ -163,16 +165,16 @@ def create_experiment(
163
165
try :
164
166
experiment = experiment_builder .build (
165
167
name , version = version , space = space , algorithms = algorithms ,
166
- strategy = strategy , max_trials = max_trials , branching = branching ,
168
+ strategy = strategy , max_trials = max_trials , max_broken = max_broken , branching = branching ,
167
169
working_dir = working_dir )
168
170
except RaceCondition :
169
171
# Try again, but if it fails again, raise. Race conditions due to version increment should
170
172
# only occur once in a short window of time unless code version is changing at a crazy pace.
171
173
try :
172
174
experiment = experiment_builder .build (
173
175
name , version = version , space = space , algorithms = algorithms ,
174
- strategy = strategy , max_trials = max_trials , branching = branching ,
175
- working_dir = working_dir )
176
+ strategy = strategy , max_trials = max_trials , max_broken = max_broken ,
177
+ branching = branching , working_dir = working_dir )
176
178
except RaceCondition as e :
177
179
raise RaceCondition (
178
180
"There was a race condition during branching and new version cannot be infered "
@@ -214,7 +216,7 @@ def get_experiment(name, version=None, storage=None):
214
216
return experiment_builder .build_view (name , version )
215
217
216
218
217
- def workon (function , space , name = 'loop' , algorithms = None , max_trials = None ):
219
+ def workon (function , space , name = 'loop' , algorithms = None , max_trials = None , max_broken = None ):
218
220
"""Optimize a function over a given search space
219
221
220
222
This will create a new experiment with an in-memory storage and optimize the given function
@@ -241,6 +243,8 @@ def workon(function, space, name='loop', algorithms=None, max_trials=None):
241
243
Algorithm used for optimization.
242
244
max_trials: int, optional
243
245
Maximum number or trials before the experiment is considered done.
246
+ max_broken: int, optional
247
+ Number of broken trials for the experiment to be considered broken.
244
248
245
249
Raises
246
250
------
@@ -256,7 +260,7 @@ def workon(function, space, name='loop', algorithms=None, max_trials=None):
256
260
257
261
experiment = experiment_builder .build (
258
262
name , version = 1 , space = space , algorithms = algorithms ,
259
- strategy = 'NoParallelStrategy' , max_trials = max_trials )
263
+ strategy = 'NoParallelStrategy' , max_trials = max_trials , max_broken = max_broken )
260
264
261
265
producer = Producer (experiment )
262
266
0 commit comments