Skip to content

Commit

Permalink
Merge pull request #243 from lsst-ts/tickets/DM-47223
Browse files Browse the repository at this point in the history
tickets/DM-47223: Improve `maintel/m1m3/check_hardpoint.py` to run tests concurrently.
  • Loading branch information
cvillalon authored Nov 27, 2024
2 parents 14545d7 + 60cac9f commit cf317fb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
1 change: 1 addition & 0 deletions doc/news/DM-47223.perf.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve the ``maintel/m1m3/check_hardpoint.py`` to run tests concurrently.
25 changes: 21 additions & 4 deletions python/lsst/ts/standardscripts/maintel/m1m3/check_hardpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ async def configure(self, config):
def set_metadata(self, metadata):
metadata.duration = self.timeout_check * 2 + self.timeout_std

async def run_individual_test(self, idx, hp):
await self.checkpoint(f"Testing hardpoint {hp}.")
await self.mtcs.run_m1m3_hard_point_test(hp=hp)
self.log.info(f"Tests complete: {idx + 1}/{len(self.hardpoints)}")

async def run_block(self):
# Check that the MTCS is in the right state
await asyncio.gather(
Expand All @@ -135,10 +140,22 @@ async def run_block(self):

await self.mtcs.enter_m1m3_engineering_mode()

for idx, hp in enumerate(self.hardpoints):
await self.checkpoint(f"Testing hardpoint {hp}.")
await self.mtcs.run_m1m3_hard_point_test(hp=hp)
self.log.info(f"Tests complete: {idx + 1}/{len(self.hardpoints)}")
tasks = [
self.run_individual_test(idx, hp)
for (idx, hp) in enumerate(self.hardpoints)
]
return_values = await asyncio.gather(*tasks, return_exceptions=True)
exceptions = [
(hp, value)
for (hp, value) in zip(self.hardpoints, return_values)
if isinstance(value, Exception)
]

if exceptions:
err_message = f"{len(exceptions)} out of {len(self.hardpoints)} hard point tests failed.\n"
for hp, exception in exceptions:
err_message += f"Hardpoint {hp} test failed with {exception!r}.\n"
raise RuntimeError(err_message)

await self.checkpoint("Hardpoint breakaway check complete.")

Expand Down

0 comments on commit cf317fb

Please sign in to comment.