From c37bfc76d62286a3b47d6895e70c2bc8a1db6f1f Mon Sep 17 00:00:00 2001 From: x01dc Date: Wed, 2 Sep 2026 03:46:52 +0200 Subject: [PATCH] fix(omny): set cam200-203/cam_xeye readoutPriority to on_request, fixes scan crash omny.tomo_scan_projection(1) -> omny_fermat_scan crashed with ValueError: 'cam200' is not in list once a scan actually did a readback-tracked osamroy rotation (the first time this branch's testing got that far). Root cause, traced through bec_server + bec_ipython_client core code: omny_fermat_scan's add_scan_report_instruction_readback(devices=["osamroy"]) registers osamroy as requiring a response; post_scan()'s complete_all_devices() then batches every enabled+claimable-owned device into one end-of-scan instruction, including cam200 (readoutPriority: async + enabled: true default to ownership_mode: "claimable", auto-acquired for any scan unless readoutPriority is "on_request"). The batched instruction's response flag isn't scoped per-device, so the server publishes a device-request-status message for cam200 too, under the same RID the osamroy-only readback progressbar is listening on -- which then crashes on an unrecognized device name. cam200/201/202/203 (and cam_xeye, added last pass) are view-only GUI cameras never referenced by any scan code (confirmed via repo-wide grep). Changing their readoutPriority to on_request excludes them from the claimable/owned auto-acquire set entirely, fixing the crash with a config-only change -- and matches flomni's own convention for this same category of device (cam_flomni_gripper/cam_flomni_overview are both on_request already). Live-mode GUI streaming (start_live_mode(), used by the parking/samplestage camera views) is unaffected since it's a dedicated background thread, not driven by readout-priority scheduling -- flomni's own cameras already prove on_request + live-mode works together. Applied to both simulated_omny.yaml and the real ptycho_omny.yaml per Mirko: this brings both configs in line with flomni's convention, not just a sim-only workaround. The underlying bug (instruction-batch-scoped response flag in scan_actions.py:_send(), plus missing per-device filtering in ReadbackDataHandler/DeviceProgressBar) is a genuine bec-core issue, not omny-specific -- flomni's own cam_xeye has the same latent exposure, untouched here since it's out of this branch's scope. Recorded in omny/AI_docs/OPEN_ISSUES.md and reported upstream separately. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01QLrD7sVYGLAzsQjLVJpCgt --- .../plugins/omny/AI_docs/OPEN_ISSUES.md | 37 +++++++++++++++++++ csaxs_bec/device_configs/ptycho_omny.yaml | 8 ++-- .../simulated_omny/simulated_omny.yaml | 10 ++--- 3 files changed, 46 insertions(+), 9 deletions(-) diff --git a/csaxs_bec/bec_ipython_client/plugins/omny/AI_docs/OPEN_ISSUES.md b/csaxs_bec/bec_ipython_client/plugins/omny/AI_docs/OPEN_ISSUES.md index 1f043c8d..7e5b3243 100644 --- a/csaxs_bec/bec_ipython_client/plugins/omny/AI_docs/OPEN_ISSUES.md +++ b/csaxs_bec/bec_ipython_client/plugins/omny/AI_docs/OPEN_ISSUES.md @@ -139,6 +139,43 @@ hardware use:** `sim_velocity`/`sim_initial_position` hand-additions elsewhere in this file, already present before this session). +## cam200-203 readoutPriority: async caused a scan crash (fixed, bec-core bug found along the way) + +`omny.tomo_scan_projection(1)` -> `omny_fermat_scan` crashed with `ValueError: 'cam200' is not in +list` in `bec_ipython_client`'s `DeviceProgressBar.set_finished()`, once a scan actually did a +readback-tracked osamroy rotation (the first time this branch got that far). Root cause, traced +through bec_server + bec_ipython_client core code: + +- `omny_fermat_scan.py`'s `add_scan_report_instruction_readback(devices=["osamroy"], ...)` + registers `osamroy` as requiring a response. +- `post_scan()`'s `complete_all_devices()` batches **every enabled+claimable-owned device** into + one instruction -- including `cam200`, because `readoutPriority: async` + `enabled: true` default + to `ownership_mode: "claimable"`, and claimable async-priority devices are auto-acquired for any + scan **unless** their `readoutPriority` is `"on_request"` (`bec_server/.../scan_actions.py: + 1148-1188`). +- The batched instruction's `response=True` flag is set because *any* device in the batch needs a + response (`scan_actions.py:_send()`, not scoped per-device) -- so the server publishes a + `DeviceReqStatusMessage` for cam200 too, under the same RID the osamroy-only readback progressbar + is listening on. +- `ReadbackDataHandler.on_req_status()` (`bec_ipython_client/.../move_device.py`) filters by RID + only, not by device, so it records cam200's status even though this progressbar only tracks + `["osamroy"]`, and `DeviceProgressBar.set_finished()` crashes on `self.devices.index("cam200")`. + +**Fixed** by changing `cam200`/`cam201`/`cam202`/`cam203` from `readoutPriority: async` to +`on_request` in both `simulated_omny.yaml` and `ptycho_omny.yaml` (also applied to the `cam_xeye` +added earlier this session) -- `on_request` is explicitly excluded from the claimable/owned +auto-acquire set, and is also the semantically correct value for these view-only cameras (never +referenced by any scan code), matching flomni's own `cam_flomni_gripper`/`cam_flomni_overview` +convention. Live-mode GUI streaming (`start_live_mode()`) is unaffected -- it's a dedicated +background thread, not driven by readout-priority scheduling. + +**Not fixed, out of scope here**: this is a genuine bec-core bug (steps 3-4 above -- an +instruction-batch-scoped response flag combined with device-unfiltered status handling +client-side), not something specific to omny. flomni's own `cam_xeye` (`ptycho_flomni.yaml`, +`readoutPriority: async`, untouched by this session) has the exact same latent exposure and would +hit the same crash the first time a flomni scan does an actual (non-"already at angle") rotation +with cam_xeye enabled. Reported upstream as feedback; not something csaxs_bec can fix directly. + ## Environment note (not code, but will bite again if forgotten) Both `csaxs_bec` and `bec_widgets` were pip-installed editable pointing at pre-repo- diff --git a/csaxs_bec/device_configs/ptycho_omny.yaml b/csaxs_bec/device_configs/ptycho_omny.yaml index 9580b7b1..d68d9aac 100755 --- a/csaxs_bec/device_configs/ptycho_omny.yaml +++ b/csaxs_bec/device_configs/ptycho_omny.yaml @@ -12,7 +12,7 @@ cam200: enabled: true onFailure: buffer readOnly: false - readoutPriority: async + readoutPriority: on_request deviceTags: - ptycho_omny @@ -27,7 +27,7 @@ cam201: enabled: true onFailure: buffer readOnly: false - readoutPriority: async + readoutPriority: on_request deviceTags: - ptycho_omny @@ -42,7 +42,7 @@ cam202: enabled: true onFailure: buffer readOnly: false - readoutPriority: async + readoutPriority: on_request deviceTags: - ptycho_omny @@ -57,7 +57,7 @@ cam203: enabled: true onFailure: buffer readOnly: false - readoutPriority: async + readoutPriority: on_request deviceTags: - ptycho_omny diff --git a/csaxs_bec/device_configs/simulated_omny/simulated_omny.yaml b/csaxs_bec/device_configs/simulated_omny/simulated_omny.yaml index 46925f66..199d010e 100644 --- a/csaxs_bec/device_configs/simulated_omny/simulated_omny.yaml +++ b/csaxs_bec/device_configs/simulated_omny/simulated_omny.yaml @@ -15,7 +15,7 @@ cam200: enabled: true onFailure: buffer readOnly: false - readoutPriority: async + readoutPriority: on_request deviceTags: - simulated_omny cam201: @@ -29,7 +29,7 @@ cam201: enabled: true onFailure: buffer readOnly: false - readoutPriority: async + readoutPriority: on_request deviceTags: - simulated_omny cam202: @@ -43,7 +43,7 @@ cam202: enabled: true onFailure: buffer readOnly: false - readoutPriority: async + readoutPriority: on_request deviceTags: - simulated_omny cam203: @@ -57,7 +57,7 @@ cam203: enabled: true onFailure: buffer readOnly: false - readoutPriority: async + readoutPriority: on_request deviceTags: - simulated_omny # Hand-added (not part of the generated ptycho_omny.yaml source -- OMNY has no cam_xeye @@ -79,7 +79,7 @@ cam_xeye: enabled: true onFailure: buffer readOnly: false - readoutPriority: async + readoutPriority: on_request userParameter: pixel_calibration: 0.00044247787610619477 # mm/pixel, placeholder (flomni's value) deviceTags: