WIP: Fix Eiger to respect message_severity of JFJ broker status #199

Draft
appel_c wants to merge 1 commits from feat/add-error-handling-to-on-complete-eiger into main
+17 -2
View File
@@ -354,7 +354,20 @@ class Eiger(PSIDeviceBase):
timeout = self._wait_for_on_complete
while time.time() - start_time < timeout:
if self.jfj_client.wait_for_idle(timeout=1, raise_on_timeout=False):
# TODO: Once available, add check for
# Call API endpoints to get broker status
broker_status = self.jfj_client.jfj_status
if broker_status.message_severity not in [
"success",
"info",
]: # Log if not success or info
logger.info(
f"JungfrauJoch broker status: {yaml.dump(broker_status.to_dict(), indent=4)}"
)
if broker_status.message_severity == "error": # Raise on error
raise EigerError(
f"Device {self.name} acquisition completed with error status from JungfrauJoch broker: {yaml.dump(broker_status.to_dict(), indent=4)}"
)
# Call API endpoint to get statistics
statistics: MeasurementStatistics = (
self.jfj_client.api.statistics_data_collection_get(_request_timeout=5)
)
@@ -363,8 +376,10 @@ class Eiger(PSIDeviceBase):
f"Device {self.name} acquisition incomplete. "
f"Expected {self._num_triggers} triggers, "
f"but only {statistics.images_collected} were collected."
f"\n\nBroker status: \n{yaml.dump(broker_status.to_dict(), indent=4)} \n\n"
f"Measurement statistics: \n{yaml.dump(statistics.to_dict(), indent=4)}"
)
return
return # Acquisition completed successfully, if none of the above conditions were met
logger.info(
f"Waiting for device {self.name} to finish complete, time elapsed: "
f"{time.time() - start_time}."