Skip to content

Commit

Permalink
rename _pending_pids → _pending_tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
basnijholt committed Apr 23, 2020
1 parent 4653a84 commit 6ed7f85
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_pids = {}
self._pending_tasks = {} # mapping from concurrent.futures.Future → point id

# 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_pids.values()
pending_ids = self._pending_tasks.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_pids.pop(fut)
pid = self._pending_tasks.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_pids))
n_new_tasks = max(0, self._get_max_tasks() - len(self._pending_tasks))

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_pids[fut] = pid
self._pending_tasks[fut] = pid

# Collect and results and add them to the learner
futures = list(self._pending_pids.keys())
futures = list(self._pending_tasks.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_pids.keys())
remaining = list(self._pending_tasks.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_pids.items()
(fut, self._id_to_point[pid]) for fut, pid in self._pending_tasks.items()
]


Expand Down

0 comments on commit 6ed7f85

Please sign in to comment.