From 703513b1759a3832d87aa4a83ff704592104dbf7 Mon Sep 17 00:00:00 2001 From: wakonig_k Date: Wed, 7 Oct 2026 14:21:39 +0200 Subject: [PATCH] chore: drop scan base-class filter and require BEC 4.0 --- .../control/scan_control/scan_control.py | 4 +-- pyproject.toml | 4 +-- tests/unit_tests/test_scan_control.py | 35 ++++++++++++++++++- 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/bec_widgets/widgets/control/scan_control/scan_control.py b/bec_widgets/widgets/control/scan_control/scan_control.py index 45078546..d6e2422c 100644 --- a/bec_widgets/widgets/control/scan_control/scan_control.py +++ b/bec_widgets/widgets/control/scan_control/scan_control.py @@ -61,7 +61,6 @@ class ScanControl(BECWidget, QWidget): PLUGIN = True ICON_NAME = "tune" ARG_BOX_POSITION: int = 2 - SUPPORTED_SCAN_BASE_CLASSES = {"ScanBase", "SyncFlyScanBase", "AsyncFlyScanBase", "ScanBaseV4"} RECENT_SCAN_HISTORY_COUNT = 50 MAX_HISTORY_LOOKBACK = 500 LAST_SCAN_FETCH_TIMEOUT_MS = 30_000 @@ -264,8 +263,7 @@ class ScanControl(BECWidget, QWidget): return [ scan_name for scan_name, scan_info in getattr(self, "available_scans", {}).items() - if scan_info.get("base_class") in self.SUPPORTED_SCAN_BASE_CLASSES - and self._scan_info_adapter.has_scan_ui_config(scan_info) + if self._scan_info_adapter.has_scan_ui_config(scan_info) and not scan_name.startswith("_") ] diff --git a/pyproject.toml b/pyproject.toml index f7208d8a..d968a377 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,8 +12,8 @@ dependencies = [ "PyJWT~=2.9", "PySide6==6.11.1", "PySide6-QtAds==5.0.0", - "bec_ipython_client>=3.134", # needed for jupyter console - "bec_lib>=3.134", + "bec_ipython_client>=4.0", # needed for jupyter console + "bec_lib>=4.0", "bec_qthemes~=1.0, >=1.3.7", "black>=26,<27", # needed for bw-generate-cli "copier~=9.7", diff --git a/tests/unit_tests/test_scan_control.py b/tests/unit_tests/test_scan_control.py index 91d77b78..c052cc03 100644 --- a/tests/unit_tests/test_scan_control.py +++ b/tests/unit_tests/test_scan_control.py @@ -1,4 +1,5 @@ # pylint: disable = no-name-in-module,missing-class-docstring, missing-module-docstring +from copy import deepcopy from threading import Event, get_ident from types import SimpleNamespace from unittest.mock import MagicMock, call, patch @@ -380,6 +381,39 @@ def test_allowed_scans_override_support_filter(scan_control): assert items == ["not_supported_scan_class", "line_scan"] +def test_scan_discovery_and_selection_without_base_class(qtbot, mocked_client): + scans = deepcopy(available_scans_message.resource) + for scan_info in scans.values(): + scan_info.pop("base_class", None) + scans["_hidden_scan"] = deepcopy(scans["line_scan"]) + scans["unsupported_input_scan"] = deepcopy(scans["line_scan"]) + scans["unsupported_input_scan"]["gui_config"]["arg_group"]["inputs"][0]["type"] = { + "Generic": {"origin": "list", "args": ["float"]} + } + mocked_client.connector.set_and_publish( + MessageEndpoints.available_scans(), AvailableResourceMessage(resource=scans) + ) + + widget = ScanControl(client=mocked_client) + qtbot.addWidget(widget) + + assert widget.allowed_scans == ["line_scan", "grid_scan"] + assert widget.current_scan == "line_scan" + assert len(widget.arg_box.widgets) == 3 + + widget.comboBox_scan_selection.setCurrentText("grid_scan") + + assert widget.current_scan == "grid_scan" + assert len(widget.arg_box.widgets) == 8 + + # Explicit filters still override hidden-name and UI support checks and keep order. + widget.allowed_scans = ["_hidden_scan", "line_scan", "not_supported_scan_class", "missing"] + assert [ + widget.comboBox_scan_selection.itemText(index) + for index in range(widget.comboBox_scan_selection.count()) + ] == ["_hidden_scan", "line_scan", "not_supported_scan_class"] + + def test_filter_change_saves_current_scan_parameters(scan_control): assert scan_control.current_scan == "line_scan" @@ -579,7 +613,6 @@ def test_scan_selector_settings_properties_are_profile_safe(scan_control): def test_scan_control_uses_gui_visibility_and_signature(qtbot, mocked_client): scan_info = { "class": "AnnotatedScan", - "base_class": "ScanBase", "arg_input": { "device": "DeviceBase", "start": {