From 6e75f3bfa4e8d82750935864024f3d2f21a2ed8d Mon Sep 17 00:00:00 2001 From: wakonig_k Date: Tue, 8 Sep 2026 14:52:22 +0200 Subject: [PATCH 1/2] fix: migrate plugin scans to v4 --- bec_testing_plugin/scans/custom_scan.py | 2 +- .../scans/device_progress_scan.py | 35 ++++++++++++++++--- .../scans/scan_customization/scan_modifier.py | 8 ++--- 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/bec_testing_plugin/scans/custom_scan.py b/bec_testing_plugin/scans/custom_scan.py index 3975c5d..9aa5bf5 100644 --- a/bec_testing_plugin/scans/custom_scan.py +++ b/bec_testing_plugin/scans/custom_scan.py @@ -1,4 +1,4 @@ -from bec_server.scan_server.scans import LineScan +from bec_server.scan_server.scans.line_scan import LineScan class CustomTestingScan(LineScan): diff --git a/bec_testing_plugin/scans/device_progress_scan.py b/bec_testing_plugin/scans/device_progress_scan.py index 9e04c19..13ec5ac 100644 --- a/bec_testing_plugin/scans/device_progress_scan.py +++ b/bec_testing_plugin/scans/device_progress_scan.py @@ -1,10 +1,37 @@ -from bec_server.scan_server.scans import Scan +from bec_server.scan_server.scans import position_generators +from bec_server.scan_server.scans.grid_scan import GridScan, scan_hook -class DeviceProgressScan(Scan): +class DeviceProgressScan(GridScan): """A scan that simulates device progress updates.""" scan_name = "device_progress_grid_scan" - def scan_report_instructions(self): - yield from self.stubs.scan_report_instruction({"device_progress": ["waveform"]}) + @scan_hook + def prepare_scan(self): + """ + Prepare the scan. This can include any steps that need to be executed + before the scan is opened, such as preparing the positions (if not done already) + or setting up the devices. + """ + self.positions = position_generators.nd_grid_positions( + self.motor_input_bundles.values(), snaked=self.snaked + ) + + if self.relative: + self.start_positions = self.components.get_start_positions(self.motors) + self.positions += self.start_positions + + self.components.check_limits(self.motors, self.positions) + + self.update_scan_info( + positions=self.positions, + num_points=len(self.positions), + num_monitored_readouts=len(self.positions) * self.burst_at_each_point, + ) + + self.actions.add_scan_report_instruction_device_progress(device="waveform") + + self._baseline_readout_status = self.actions.read_baseline_devices(wait=False) + + self._premove_motor_status = self.actions.set(self.motors, self.positions[0], wait=False) diff --git a/bec_testing_plugin/scans/scan_customization/scan_modifier.py b/bec_testing_plugin/scans/scan_customization/scan_modifier.py index 646bde1..c2a6625 100644 --- a/bec_testing_plugin/scans/scan_customization/scan_modifier.py +++ b/bec_testing_plugin/scans/scan_customization/scan_modifier.py @@ -13,14 +13,14 @@ class BecTestingPluginScanModifier(ScanModifier): """ Scan modifier for bec_testing_plugin. - + By inheriting from the ScanModifier base class, you get access to currently running scan (self.scan), the devices (self.dev), the scan info (self.scan_info), the scan components (self.components) and the scan actions (self.actions). """ - def __init__(self, **kwargs): + def __init__(self, *args, **kwargs): """Initialize the scan modifier.""" - super().__init__(**kwargs) + super().__init__(*args, **kwargs) # Example of running code before the scan stage for a specific scan # @scan_hook_impl("stage", "before") @@ -29,5 +29,3 @@ def __init__(self, **kwargs): # self.actions.send_client_info("Custom stage logic executed by ScanModifier.") # if self.scan_info.scan_name == "example_scan": # self.dev.samx.set(20) - - From c3db6903d21c8ad33ea088e6995de4663d946b24 Mon Sep 17 00:00:00 2001 From: wakonig_k Date: Tue, 8 Sep 2026 15:05:32 +0200 Subject: [PATCH 2/2] fix: use coverage instead of pytest-cov --- .github/workflows/ci.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e370e35..a01910b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -90,8 +90,13 @@ jobs: uv pip install --system -e ./bec/bec_ipython_client uv pip install --system -e ./bec/bec_server[dev] uv pip install --system -e ./bec_widgets[dev] - uv pip install --system -e ./bec_testing_plugin + uv pip install --system -e "./bec_testing_plugin[dev]" - name: Run Pytest with Coverage id: coverage - run: pytest --random-order --cov=./bec_testing_plugin --cov-config=./bec_testing_plugin/pyproject.toml --cov-branch --cov-report=xml --no-cov-on-fail ./bec_testing_plugin/tests/ || test $? -eq 5 + run: | + if coverage run --rcfile=./bec_testing_plugin/pyproject.toml --branch --source=./bec_testing_plugin -m pytest --random-order ./bec_testing_plugin/tests/; then + coverage xml --rcfile=./bec_testing_plugin/pyproject.toml + else + test $? -eq 5 + fi