...
|
...
|
@@ -151,7 +151,7 @@ class BaseRunner(metaclass=abc.ABCMeta):
|
151
|
151
|
self._tracebacks = {}
|
152
|
152
|
|
153
|
153
|
# Keeping track of index -> point
|
154
|
|
- self._index_to_point = {}
|
|
154
|
+ self._id_to_point = {}
|
155
|
155
|
self._i = 0 # some unique index to be associated with each point
|
156
|
156
|
|
157
|
157
|
def _get_max_tasks(self):
|
...
|
...
|
@@ -159,7 +159,7 @@ class BaseRunner(metaclass=abc.ABCMeta):
|
159
|
159
|
|
160
|
160
|
def _do_raise(self, e, i):
|
161
|
161
|
tb = self._tracebacks[i]
|
162
|
|
- x = self._index_to_point[i]
|
|
162
|
+ x = self._id_to_point[i]
|
163
|
163
|
raise RuntimeError(
|
164
|
164
|
"An error occured while evaluating "
|
165
|
165
|
f'"learner.function({x})". '
|
...
|
...
|
@@ -175,7 +175,7 @@ class BaseRunner(metaclass=abc.ABCMeta):
|
175
|
175
|
for i, index in enumerate(self._to_retry.keys()):
|
176
|
176
|
if i == n:
|
177
|
177
|
break
|
178
|
|
- point = self._index_to_point[index]
|
|
178
|
+ point = self._id_to_point[index]
|
179
|
179
|
if point not in self.pending_points.values():
|
180
|
180
|
points.append(point)
|
181
|
181
|
|
...
|
...
|
@@ -212,7 +212,7 @@ class BaseRunner(metaclass=abc.ABCMeta):
|
212
|
212
|
def _process_futures(self, done_futs):
|
213
|
213
|
for fut in done_futs:
|
214
|
214
|
x = self.pending_points.pop(fut)
|
215
|
|
- i = _key_by_value(self._index_to_point, x) # O(N)
|
|
215
|
+ i = _key_by_value(self._id_to_point, x) # O(N)
|
216
|
216
|
try:
|
217
|
217
|
y = fut.result()
|
218
|
218
|
t = time.time() - fut.start_time # total execution time
|
...
|
...
|
@@ -227,7 +227,7 @@ class BaseRunner(metaclass=abc.ABCMeta):
|
227
|
227
|
self._elapsed_function_time += t / self._get_max_tasks()
|
228
|
228
|
self._to_retry.pop(i, None)
|
229
|
229
|
self._tracebacks.pop(i, None)
|
230
|
|
- self._index_to_point.pop(i)
|
|
230
|
+ self._id_to_point.pop(i)
|
231
|
231
|
if self.do_log:
|
232
|
232
|
self.log.append(("tell", x, y))
|
233
|
233
|
self.learner.tell(x, y)
|
...
|
...
|
@@ -249,11 +249,11 @@ class BaseRunner(metaclass=abc.ABCMeta):
|
249
|
249
|
fut.start_time = start_time
|
250
|
250
|
self.pending_points[fut] = x
|
251
|
251
|
try:
|
252
|
|
- i = _key_by_value(self._index_to_point, x) # O(N)
|
253
|
|
- except StopIteration: # `x` is not a value in `self._index_to_point`
|
|
252
|
+ i = _key_by_value(self._id_to_point, x) # O(N)
|
|
253
|
+ except StopIteration: # `x` is not a value in `self._id_to_point`
|
254
|
254
|
self._i += 1
|
255
|
255
|
i = self._i
|
256
|
|
- self._index_to_point[i] = x
|
|
256
|
+ self._id_to_point[i] = x
|
257
|
257
|
|
258
|
258
|
# Collect and results and add them to the learner
|
259
|
259
|
futures = list(self.pending_points.keys())
|
...
|
...
|
@@ -300,11 +300,11 @@ class BaseRunner(metaclass=abc.ABCMeta):
|
300
|
300
|
|
301
|
301
|
@property
|
302
|
302
|
def tracebacks(self):
|
303
|
|
- return [(self._index_to_point[i], tb) for i, tb in self._tracebacks.items()]
|
|
303
|
+ return [(self._id_to_point[i], tb) for i, tb in self._tracebacks.items()]
|
304
|
304
|
|
305
|
305
|
@property
|
306
|
306
|
def to_retry(self):
|
307
|
|
- return [(self._index_to_point[i], n) for i, n in self._to_retry.items()]
|
|
307
|
+ return [(self._id_to_point[i], n) for i, n in self._to_retry.items()]
|
308
|
308
|
|
309
|
309
|
|
310
|
310
|
class BlockingRunner(BaseRunner):
|