Improve error reporting in ATCalsys.prepare_for_flat.

Description

Currently, in ATCalSys.prepare_for_flat there is a gather statement here, that runs the setup tasks concurrently. When there is an error in any of the coroutines, the error message is obfuscated and does not show which task failed.

I think the best way to improve this is to have the exceptions be returned and then process the errors individually. Luckily, asyncio.gather returns in the same order they are passed so something like this should work:

 

ret_val = await asyncio.gather( task_setup_monochromator, task_setup_latiss, task_setup_electrometer, return_exceptions=True, ) operations = ["Setup monochromator", "Setup latiss", "Setup electrometer"] exceptions = [(operation, val) for (operation, val) in zip(operations, ret_val) if isinstance(val, Exception)] if exceptions: err_message = f"{len(exceptions)} out of {len(operations)} failed.\n" for (operation, exception) in expcetions: err_message += f"{operation} failed with {exception}.\n" raise RuntimeError(err_message)

Issue Matrix

hide

Activity

Tiago Ribeiro September 30, 2024 at 6:08 PM

PR approved!

Done
Pinned fields
Click on the next to a field label to start pinning.

Details

Assignee

Reporter

Reviewers

Tiago Ribeiro

Story Points

RubinTeam

Commissioning

Sprint

Checklist

Created September 24, 2024 at 3:20 PM
Updated September 30, 2024 at 6:26 PM
Resolved September 30, 2024 at 6:26 PM