Skip to content

Commit

Permalink
Inline _scale_out in BlockProviderExecutor (#3554)
Browse files Browse the repository at this point in the history
This brings two related pieces of code together into a single method,
removing the possibility of the _scale_out code being called in any
other way than via scale_out_facade.

Future PRs will rearrange the now unified code and make a bugfix that
will be more easily fixable now.

This PR should not change behaviour as it is only a code movement.
  • Loading branch information
benclifford authored Aug 1, 2024
1 parent a24bc93 commit 11d88db
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions parsl/executors/status_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,22 +183,13 @@ def _filter_scale_in_ids(self, to_kill: Sequence[Any], killed: Sequence[bool]) -
return list(compress(to_kill, killed))

def scale_out_facade(self, n: int) -> List[str]:
block_ids = self._scale_out(n)
new_status = {}
for block_id in block_ids:
new_status[block_id] = JobStatus(JobState.PENDING)
self.send_monitoring_info(new_status)
self._status.update(new_status)
return block_ids

def _scale_out(self, blocks: int = 1) -> List[str]:
"""Scales out the number of blocks by "blocks"
"""
if not self.provider:
raise ScalingFailed(self, "No execution provider available")
block_ids = []
logger.info(f"Scaling out by {blocks} blocks")
for _ in range(blocks):
logger.info(f"Scaling out by {n} blocks")
for _ in range(n):
block_id = str(self._block_id_counter.get_id())
logger.info(f"Allocated block ID {block_id}")
try:
Expand All @@ -208,6 +199,12 @@ def _scale_out(self, blocks: int = 1) -> List[str]:
block_ids.append(block_id)
except Exception as ex:
self._simulated_status[block_id] = JobStatus(JobState.FAILED, "Failed to start block {}: {}".format(block_id, ex))

new_status = {}
for block_id in block_ids:
new_status[block_id] = JobStatus(JobState.PENDING)
self.send_monitoring_info(new_status)
self._status.update(new_status)
return block_ids

def scale_in(self, blocks: int) -> List[str]:
Expand Down

0 comments on commit 11d88db

Please sign in to comment.