From 2f35ecbd2b86ddb0194677970f6ea36aceef21ba Mon Sep 17 00:00:00 2001 From: David Perl Date: Wed, 25 Nov 2026 15:37:59 +0100 Subject: [PATCH 1/2] feat: add support for aarebec --- pxiii_bec/bec_widgets/widgets/__init__.py | 5 ++ pxiii_bec/bec_widgets/widgets/client.py | 85 +++++++++++++++++++ .../bec_widgets/widgets/designer_plugins.py | 13 +++ pxiii_bec/devices/__init__.py | 2 + pyproject.toml | 4 + 5 files changed, 109 insertions(+) diff --git a/pxiii_bec/bec_widgets/widgets/__init__.py b/pxiii_bec/bec_widgets/widgets/__init__.py index e69de29..562ce61 100644 --- a/pxiii_bec/bec_widgets/widgets/__init__.py +++ b/pxiii_bec/bec_widgets/widgets/__init__.py @@ -0,0 +1,5 @@ +from mx_bec.bec_widgets.widgets.aare_bec.actors_config import MxActorConfigWidget +from mx_bec.bec_widgets.widgets.aare_bec.task_panel import MxTaskPanel +from mx_bec.bec_widgets.widgets.aare_bec.task_queue import MxTaskQueueWidget + +__all__ = ["MxActorConfigWidget", "MxTaskPanel", "MxTaskQueueWidget"] diff --git a/pxiii_bec/bec_widgets/widgets/client.py b/pxiii_bec/bec_widgets/widgets/client.py index f86e584..079f7d3 100644 --- a/pxiii_bec/bec_widgets/widgets/client.py +++ b/pxiii_bec/bec_widgets/widgets/client.py @@ -13,10 +13,95 @@ logger = bec_logger.logger _Widgets = { + "PxIIIActorConfigWidget": "PxIIIActorConfigWidget", + "PxIIISampleQueueWidget": "PxIIISampleQueueWidget", + "PxIIISpreadsheetDisplay": "PxIIISpreadsheetDisplay", + "PxIIITaskPanel": "PxIIITaskPanel", + "PxIIITaskQueueWidget": "PxIIITaskQueueWidget", "ScanHistory": "ScanHistory", } +class PxIIIActorConfigWidget(RPCBase): + _IMPORT_MODULE = "pxiii_bec.bec_widgets.widgets.imported" + + @rpc_call + def refresh(self): + """ + Reset the layout for currently loaded actors + """ + + +class PxIIISampleQueueWidget(RPCBase): + _IMPORT_MODULE = "pxiii_bec.bec_widgets.widgets.imported" + + @rpc_call + def refresh(self): + """ + Reload the queued samples from Redis. + """ + + @rpc_call + def clear_queue(self): + """ + Delete the queue contents + """ + + +class PxIIISpreadsheetDisplay(RPCBase): + _IMPORT_MODULE = "pxiii_bec.bec_widgets.widgets.imported" + + @rpc_call + def remove(self): + """ + Cleanup the BECConnector + """ + + @rpc_call + def attach(self): + """ + None + """ + + @rpc_call + def detach(self): + """ + Detach the widget from its parent dock widget (if widget is in the dock), making it a floating widget. + """ + + +class PxIIITaskPanel(RPCBase): + _IMPORT_MODULE = "pxiii_bec.bec_widgets.widgets.imported" + + @rpc_call + def request_task(self, name: "str", *args, **kwargs): + """ + Submit a task request to the AareBec service. + """ + + +class PxIIITaskQueueWidget(RPCBase): + _IMPORT_MODULE = "pxiii_bec.bec_widgets.widgets.imported" + + @rpc_call + def refresh(self): + """ + Reload the queued tasks from Redis. + """ + + @rpc_call + def clear_queue(self): + """ + Delete the queue contents + """ + + @rpc_call + def start_queue(self): + """ + Try to start the queue + """ + + class ScanHistory(RPCBase): _IMPORT_MODULE = "pxiii_bec.bec_widgets.widgets.scan_history.scan_history" diff --git a/pxiii_bec/bec_widgets/widgets/designer_plugins.py b/pxiii_bec/bec_widgets/widgets/designer_plugins.py index 37d9ecb..f3868ee 100644 --- a/pxiii_bec/bec_widgets/widgets/designer_plugins.py +++ b/pxiii_bec/bec_widgets/widgets/designer_plugins.py @@ -5,9 +5,22 @@ from __future__ import annotations # pylint: skip-file designer_plugins = { + "PxIIIActorConfigWidget": ("pxiii_bec.bec_widgets.widgets.imported", "PxIIIActorConfigWidget"), + "PxIIISampleQueueWidget": ("pxiii_bec.bec_widgets.widgets.imported", "PxIIISampleQueueWidget"), + "PxIIISpreadsheetDisplay": ( + "pxiii_bec.bec_widgets.widgets.imported", + "PxIIISpreadsheetDisplay", + ), + "PxIIITaskPanel": ("pxiii_bec.bec_widgets.widgets.imported", "PxIIITaskPanel"), + "PxIIITaskQueueWidget": ("pxiii_bec.bec_widgets.widgets.imported", "PxIIITaskQueueWidget"), "ScanHistory": ("pxiii_bec.bec_widgets.widgets.scan_history.scan_history", "ScanHistory"), } widget_icons = { + "PxIIIActorConfigWidget": "format_list_bulleted", + "PxIIISampleQueueWidget": "pending_actions", + "PxIIISpreadsheetDisplay": "format_list_bulleted", + "PxIIITaskPanel": "play_arrow", + "PxIIITaskQueueWidget": "pending_actions", "ScanHistory": "widgets", } diff --git a/pxiii_bec/devices/__init__.py b/pxiii_bec/devices/__init__.py index 8d83b17..3909b30 100644 --- a/pxiii_bec/devices/__init__.py +++ b/pxiii_bec/devices/__init__.py @@ -7,6 +7,8 @@ Ophyd devices for the PX III beamline, including the MX specific Aerotech A3200 from mx_bec.devices.beam_profile import CentroidBeamProfile, GaussianBeamProfile from mx_bec.devices.beam_steering import BeamSteerer +from mx_bec.devices.sim_sample_changer import SimSampleChanger +from mx_bec.devices.sim_stages import SimAerotechStage, SimGoniometer from .A3200 import AerotechAbrStage from .A3200utils import A3200Axis diff --git a/pyproject.toml b/pyproject.toml index 2dcd61c..7bd836a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,6 +13,7 @@ classifiers = [ "Topic :: Scientific/Engineering", ] dependencies = [ + "mx_bec", "bec_ipython_client", "bec_lib", "bec_server", @@ -70,6 +71,9 @@ plugin_widgets_update = "pxiii_bec.bec_widgets.auto_updates" [project.entry-points."bec.widgets.user_widgets"] plugin_widgets = "pxiii_bec.bec_widgets.widgets" +[project.entry-points."bec.messages"] +plugin_messages = "pxiii_bec.messages" + [tool.hatch.build.targets.wheel] include = ["*"] -- 2.54.1 From 963eae2d830eb2eb1b9d27774c355541d4f88382 Mon Sep 17 00:00:00 2001 From: David Perl Date: Wed, 25 Nov 2026 15:46:55 +0100 Subject: [PATCH 2/2] feat: fix ci dependency install --- .gitea/workflows/ci.yml | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index c6fdcef..1b16f8f 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -1,6 +1,7 @@ name: CI for pxiii_bec on: push: + branches: [main] pull_request: workflow_dispatch: inputs: @@ -24,6 +25,11 @@ on: required: false type: string default: "main" + MX_BEC_REPO_BRANCH: + description: "Branch of the mx_bec core repo to install" + required: false + type: string + default: "main" PYTHON_VERSION: description: "Python version to use" required: false @@ -46,6 +52,29 @@ jobs: with: python-version: "${{ inputs.PYTHON_VERSION || '3.12' }}" + # Use the same-named branch of mx_bec if it exists (e.g. a feature developed in both repos), otherwise main. + - name: Resolve mx_bec branch + id: mx_bec + shell: bash + run: | + ref="${{ inputs.MX_BEC_REPO_BRANCH || github.head_ref || github.ref_name }}" + auth="$(printf 'x-access-token:%s' '${{ github.token }}' | base64 -w0)" + if git -c "http.extraheader=Authorization: Basic ${auth}" ls-remote --exit-code --heads \ + "${{ github.server_url }}/bec/mx_bec.git" "refs/heads/${ref}" >/dev/null; then + echo "Using mx_bec branch '${ref}'" + else + echo "mx_bec has no branch '${ref}', using main" + ref=main + fi + echo "ref=${ref}" >> "$GITHUB_OUTPUT" + + - name: Checkout MX BEC Repository + uses: actions/checkout@v4 + with: + repository: bec/mx_bec + ref: "${{ steps.mx_bec.outputs.ref }}" + path: ./mx_bec + - name: Checkout BEC Plugin Repository uses: actions/checkout@v4 with: @@ -94,8 +123,11 @@ jobs: uv pip install --system -e ./bec/bec_lib[dev] 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,pyside6] - uv pip install --system -e ./pxiii_bec[dev] + uv pip install --system -e ./bec_widgets[dev] + # mx_bec pins its MX-internal dependencies (aarecommon, aare_config, ...) as direct URLs + # to the gitea registry. uv only accepts URL dependencies from packages named on the + # command line, so mx_bec must be installed together with the plugin which depends on it. + uv pip install --system -e ./mx_bec[dev] -e ./pxiii_bec[dev] - name: Run Tests with Coverage id: coverage -- 2.54.1