Skip to content

Commit

Permalink
rename _pending_points -> _pending_pids
Browse files Browse the repository at this point in the history
  • Loading branch information
basnijholt committed Apr 23, 2020
1 parent 473dd42 commit 4653a84
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions adaptive/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def __init__(

self._max_tasks = ntasks

self._pending_points = {}
self._pending_pids = {}

# if we instantiate our own executor, then we are also responsible
# for calling 'shutdown'
Expand Down Expand Up @@ -170,7 +170,7 @@ def do_log(self):
return self.log is not None

def _ask(self, n):
pending_ids = self._pending_points.values()
pending_ids = self._pending_pids.values()
pids_gen = (pid for pid in self._to_retry.keys() if pid not in pending_ids)
pids = list(itertools.islice(pids_gen, n))

Expand Down Expand Up @@ -210,7 +210,7 @@ def overhead(self):

def _process_futures(self, done_futs):
for fut in done_futs:
pid = self._pending_points.pop(fut)
pid = self._pending_pids.pop(fut)
try:
y = fut.result()
t = time.time() - fut.start_time # total execution time
Expand All @@ -234,7 +234,7 @@ def _get_futures(self):
# Launch tasks to replace the ones that completed
# on the last iteration, making sure to fill workers
# that have started since the last iteration.
n_new_tasks = max(0, self._get_max_tasks() - len(self._pending_points))
n_new_tasks = max(0, self._get_max_tasks() - len(self._pending_pids))

if self.do_log:
self.log.append(("ask", n_new_tasks))
Expand All @@ -246,17 +246,17 @@ def _get_futures(self):
point = self._id_to_point[pid]
fut = self._submit(point)
fut.start_time = start_time
self._pending_points[fut] = pid
self._pending_pids[fut] = pid

# Collect and results and add them to the learner
futures = list(self._pending_points.keys())
futures = list(self._pending_pids.keys())
return futures

def _remove_unfinished(self):
# remove points with 'None' values from the learner
self.learner.remove_unfinished()
# cancel any outstanding tasks
remaining = list(self._pending_points.keys())
remaining = list(self._pending_pids.keys())
for fut in remaining:
fut.cancel()
return remaining
Expand Down Expand Up @@ -302,7 +302,7 @@ def to_retry(self):
@property
def pending_points(self):
return [
(fut, self._id_to_point[pid]) for fut, pid in self._pending_points.items()
(fut, self._id_to_point[pid]) for fut, pid in self._pending_pids.items()
]


Expand Down

0 comments on commit 4653a84

Please sign in to comment.