From b96d125c654e6ec8e6431a467fe37643c081ccd5 Mon Sep 17 00:00:00 2001 From: appleb_m Date: Thu, 9 Jul 2026 13:12:40 +0200 Subject: [PATCH] fix: added end_operation to the exception mess at the end of def measure() in daq.py --- src/aare/daq/daq.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/aare/daq/daq.py b/src/aare/daq/daq.py index bdb29fcf..ddcf0ba0 100644 --- a/src/aare/daq/daq.py +++ b/src/aare/daq/daq.py @@ -67,6 +67,7 @@ from aarecommon.models.rotation_scan import CompletedRotationScan, RotationScanR from aarecommon.models.tell import TellPhaseEnum, TellStateModel from aareDB import SampleEventType +from aare.common.models import DAQOperation from aare.daq import workflows from aare.daq.aaredb import AareWrapper from aare.daq.config import ABR_POS_MOUNT, BeamlineConfig, BeamlineStateEnum @@ -2599,7 +2600,7 @@ class AareDAQ: def _end_operation( self, - start, + start: float, operation: Optional[DAQOperation] = DAQOperation.AUTOMATION, error: bool = False, ) -> float: @@ -2841,9 +2842,11 @@ class AareDAQ: self._validate_automation_state(context="automation end") except BECCommunicationError as e: + self._end_operation(start, operation=DAQOperation.AUTOMATION, error=True) self._raise_if_critical_bec_error(e, command=getattr(e, "operation", None) or "bec") except JFJochCommunicationError as e: + self._end_operation(start, operation=DAQOperation.AUTOMATION, error=True) self._raise_if_critical_jfjoch_detector_error(e, command=e.endpoint or "unknown") raise @@ -2872,6 +2875,7 @@ class AareDAQ: error=e, event_type=SampleEventType.FAILED, ) + self._end_operation(start, operation=DAQOperation.AUTOMATION, error=True) raise except (BeamlineBusyTimeoutException, BeamlineBusyException) as e: @@ -2906,12 +2910,13 @@ class AareDAQ: error=e, event_type=SampleEventType.FAILED, ) - + self._end_operation(start, operation=None, error=True) raise except MountingFailed as e: logger.error(f"Failed to mount sample: {e}") if e.critical: + self._end_operation(start, operation=DAQOperation.AUTOMATION, error=True) raise e else: pass @@ -2937,7 +2942,7 @@ class AareDAQ: error=e, event_type=SampleEventType.FAILED, ) - + self._end_operation(start, operation=DAQOperation.AUTOMATION, error=True) raise Exception(f"Critical Error in automation: {e}") from e self._record_completed_sample_time(progress, time.time() - sample_started_at)