Skip to content

Commit 0531f55

Browse files
committed
rename self.blocks and self.block_mapping to be clearer about what they are maps for
(and that they're inverses of each other)
1 parent 17da107 commit 0531f55

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

parsl/executors/high_throughput/executor.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ def create_monitoring_info(self, status):
688688
d['status'] = s.status_name
689689
d['timestamp'] = datetime.datetime.now()
690690
d['executor_label'] = self.label
691-
d['job_id'] = self.blocks.get(bid, None)
691+
d['job_id'] = self.blocks_to_job_id.get(bid, None)
692692
d['block_id'] = bid
693693
msg.append(d)
694694
return msg
@@ -767,14 +767,14 @@ class BlockInfo:
767767

768768
# Now kill via provider
769769
# Potential issue with multiple threads trying to remove the same blocks
770-
to_kill = [self.blocks[bid] for bid in block_ids_to_kill if bid in self.blocks]
770+
to_kill = [self.blocks_to_job_id[bid] for bid in block_ids_to_kill if bid in self.blocks_to_job_id]
771771

772772
r = self.provider.cancel(to_kill)
773773
job_ids = self._filter_scale_in_ids(to_kill, r)
774774

775-
# to_kill block_ids are fetched from self.blocks
776-
# If a block_id is in self.block, it must exist in self.block_mapping
777-
block_ids_killed = [self.block_mapping[jid] for jid in job_ids]
775+
# to_kill block_ids are fetched from self.blocks_to_job_id
776+
# If a block_id is in self.blocks_to_job_id, it must exist in self.job_ids_to_block
777+
block_ids_killed = [self.job_ids_to_block[jid] for jid in job_ids]
778778

779779
return block_ids_killed
780780

parsl/executors/status_handling.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ def __init__(self, *,
6868
self._block_id_counter = AtomicIDCounter()
6969

7070
self._tasks = {} # type: Dict[object, Future]
71-
self.blocks = {} # type: Dict[str, str]
72-
self.block_mapping = {} # type: Dict[str, str]
71+
self.blocks_to_job_id = {} # type: Dict[str, str]
72+
self.job_ids_to_block = {} # type: Dict[str, str]
7373

7474
def _make_status_dict(self, block_ids: List[str], status_list: List[JobStatus]) -> Dict[str, JobStatus]:
7575
"""Given a list of block ids and a list of corresponding status strings,
@@ -194,8 +194,8 @@ def scale_out(self, blocks: int = 1) -> List[str]:
194194
logger.info(f"Allocated block ID {block_id}")
195195
try:
196196
job_id = self._launch_block(block_id)
197-
self.blocks[block_id] = job_id
198-
self.block_mapping[job_id] = block_id
197+
self.blocks_to_job_id[block_id] = job_id
198+
self.job_ids_to_block[job_id] = block_id
199199
block_ids.append(block_id)
200200
except Exception as ex:
201201
self._fail_job_async(block_id,
@@ -232,10 +232,10 @@ def _get_block_and_job_ids(self) -> Tuple[List[str], List[Any]]:
232232
# Not using self.blocks.keys() and self.blocks.values() simultaneously
233233
# The dictionary may be changed during invoking this function
234234
# As scale_in and scale_out are invoked in multiple threads
235-
block_ids = list(self.blocks.keys())
235+
block_ids = list(self.blocks_to_job_id.keys())
236236
job_ids = [] # types: List[Any]
237237
for bid in block_ids:
238-
job_ids.append(self.blocks[bid])
238+
job_ids.append(self.blocks_to_job_id[bid])
239239
return block_ids, job_ids
240240

241241
@abstractproperty

0 commit comments

Comments
 (0)