From 7e0f0a1e9ecf015bdbcabb626e3aad40f0f35b2e Mon Sep 17 00:00:00 2001 From: Srishty Date: Mon, 15 Sep 2025 15:31:32 +0100 Subject: [PATCH 01/21] add transmission percentage --- .../beamlines/i04/test_plans/__init__.py | 0 .../i04/test_plans/oav_automation.py | 30 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 src/mx_bluesky/beamlines/i04/test_plans/__init__.py create mode 100644 src/mx_bluesky/beamlines/i04/test_plans/oav_automation.py diff --git a/src/mx_bluesky/beamlines/i04/test_plans/__init__.py b/src/mx_bluesky/beamlines/i04/test_plans/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/mx_bluesky/beamlines/i04/test_plans/oav_automation.py b/src/mx_bluesky/beamlines/i04/test_plans/oav_automation.py new file mode 100644 index 0000000000..46066bdafd --- /dev/null +++ b/src/mx_bluesky/beamlines/i04/test_plans/oav_automation.py @@ -0,0 +1,30 @@ + + +import bluesky.plan_stubs as bps +import bluesky.preprocessors as bpp +#from bluesky.preprocessors import run_decorator, stage_wrapper, subs_decorator +from bluesky.utils import MsgGenerator + +#from dodal.devices + +""" +My task: + + Move the scintillator in and out + Change transmission percentage + Take OAV images + Open and close fast shutter + +""" + +def move_scintillator(): + pass + +def set_transmission_percentage(): + pass + +def take_OAV_image(): + pass + +def open_close_fast_shutter(): + pass From 86444fffb995c1c1c78798049546d853e652f778 Mon Sep 17 00:00:00 2001 From: Srishty Date: Mon, 15 Sep 2025 15:35:38 +0100 Subject: [PATCH 02/21] add transmission --- .../beamlines/i04/test_plans/oav_automation.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/mx_bluesky/beamlines/i04/test_plans/oav_automation.py b/src/mx_bluesky/beamlines/i04/test_plans/oav_automation.py index 46066bdafd..99318304b9 100644 --- a/src/mx_bluesky/beamlines/i04/test_plans/oav_automation.py +++ b/src/mx_bluesky/beamlines/i04/test_plans/oav_automation.py @@ -1,11 +1,10 @@ - - import bluesky.plan_stubs as bps import bluesky.preprocessors as bpp -#from bluesky.preprocessors import run_decorator, stage_wrapper, subs_decorator + +# from bluesky.preprocessors import run_decorator, stage_wrapper, subs_decorator from bluesky.utils import MsgGenerator -#from dodal.devices +# from dodal.devices """ My task: @@ -17,14 +16,18 @@ """ + def move_scintillator(): pass + def set_transmission_percentage(): - pass + pass + def take_OAV_image(): - pass + pass + def open_close_fast_shutter(): pass From 6cb556b51477ed85e7832ac172a0305525bd8197 Mon Sep 17 00:00:00 2001 From: Srishty Date: Mon, 15 Sep 2025 15:36:53 +0100 Subject: [PATCH 03/21] add transmission - for real --- .../i04/test_plans/oav_automation.py | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/mx_bluesky/beamlines/i04/test_plans/oav_automation.py b/src/mx_bluesky/beamlines/i04/test_plans/oav_automation.py index 99318304b9..24c334b484 100644 --- a/src/mx_bluesky/beamlines/i04/test_plans/oav_automation.py +++ b/src/mx_bluesky/beamlines/i04/test_plans/oav_automation.py @@ -1,10 +1,12 @@ -import bluesky.plan_stubs as bps -import bluesky.preprocessors as bpp -# from bluesky.preprocessors import run_decorator, stage_wrapper, subs_decorator +from bluesky.utils import MsgGenerator +import bluesky.plan_stubs as bps +#import bluesky.preprocessors as bpp +#from bluesky.preprocessors import run_decorator, stage_wrapper, subs_decorator from bluesky.utils import MsgGenerator -# from dodal.devices +from dodal.common import inject +from dodal.devices.attenuator.attenuator import BinaryFilterAttenuator """ My task: @@ -17,17 +19,19 @@ """ -def move_scintillator(): - pass +def set_transmission_percentage( + percentage: float, + attenuator: BinaryFilterAttenuator, +) -> MsgGenerator: + yield from bps.abs_set(attenuator, percentage/100) -def set_transmission_percentage(): + +def move_scintillator(): pass - def take_OAV_image(): - pass - + pass def open_close_fast_shutter(): pass From d7211d71fa0e1263523ff583df16700a8c80e9e4 Mon Sep 17 00:00:00 2001 From: Srishty Date: Mon, 15 Sep 2025 16:27:12 +0100 Subject: [PATCH 04/21] attempt at shutter task --- .../i04/test_plans/oav_automation.py | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/mx_bluesky/beamlines/i04/test_plans/oav_automation.py b/src/mx_bluesky/beamlines/i04/test_plans/oav_automation.py index 24c334b484..0894ea0d1f 100644 --- a/src/mx_bluesky/beamlines/i04/test_plans/oav_automation.py +++ b/src/mx_bluesky/beamlines/i04/test_plans/oav_automation.py @@ -7,6 +7,8 @@ from dodal.common import inject from dodal.devices.attenuator.attenuator import BinaryFilterAttenuator +from dodal.devices.zebra.zebra_controlled_shutter import ZebraShutter, ZebraShutterState, ZebraShutterControl +from sqlalchemy import Boolean """ My task: @@ -26,12 +28,24 @@ def set_transmission_percentage( yield from bps.abs_set(attenuator, percentage/100) - + +def open_close_fast_shutter( + shutter: ZebraShutter, + shutter_state: Boolean, + #shutter_control: ZebraShutterControl + +) -> MsgGenerator: + + yield from bps.abs_set(shutter.control_mode, ZebraShutterControl.MANUAL) + if shutter_state: + yield from bps.abs_set(shutter._manual_position_setpoint, ZebraShutterState.OPEN) + else: + yield from bps.abs_set(shutter._manual_position_setpoint, ZebraShutterState.CLOSE) + def move_scintillator(): pass def take_OAV_image(): pass -def open_close_fast_shutter(): - pass + From 743d1c714de9d0d4aa6c2cfdc1180e1edd62a99f Mon Sep 17 00:00:00 2001 From: Ollie Silvester Date: Tue, 16 Sep 2025 12:24:00 +0000 Subject: [PATCH 05/21] Update devcontainer.json --- .devcontainer/devcontainer.json | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index d3d639a502..c65b6e72ef 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -29,10 +29,11 @@ }, "features": { // Some default things like git config - "ghcr.io/devcontainers/features/common-utils:2": { - "upgradePackages": false - } + // add in eternal history and other bash features + "ghcr.io/diamondlightsource/devcontainer-features/bash-config:1": {} }, + // Create the config folder for the bash-config feature + "initializeCommand": "mkdir -p ${localEnv:HOME}/.config/bash-config", "runArgs": [ // Allow the container to access the host X11 display and EPICS CA "--net=host", @@ -42,5 +43,5 @@ // Mount the parent as /workspaces so we can pip install peers as editable "workspaceMount": "source=${localWorkspaceFolder}/..,target=/workspaces,type=bind", // After the container is created, install the python project in editable form - "postCreateCommand": "pip install $([ -f dev-requirements.txt ] && echo '-c dev-requirements.txt') -e '.[dev]' && pre-commit install" + "postCreateCommand": "pip install $([ -f dev-requirements.txt ] && echo '-c dev-requirements.txt') -e '.[dev]' && pip install -e /workspaces/dodal && pre-commit install" } From 4e0f3d1e67f076de84df6d064724314506aa810e Mon Sep 17 00:00:00 2001 From: Ollie Silvester Date: Tue, 16 Sep 2025 13:30:28 +0000 Subject: [PATCH 06/21] Bring in vscode settings to devcontainer --- .devcontainer/devcontainer.json | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index c65b6e72ef..0324b3e7b7 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -24,7 +24,32 @@ "ryanluker.vscode-coverage-gutters", "charliermarsh.ruff", "ms-azuretools.vscode-docker" - ] + ], + "python.testing.pytestArgs": [ + "--cov=mx_bluesky", + "--cov-report", + "xml:cov.xml" + ], + "python.testing.unittestEnabled": false, + "python.testing.pytestEnabled": true, + "python.defaultInterpreterPath": ".venv/bin/python", + "editor.formatOnSave": true, + "editor.codeActionsOnSave": { + "source.organizeImports": "explicit" + }, + "files.insertFinalNewline": true, + "[python]": { + "editor.rulers": [ + 88 + ], + "editor.codeActionsOnSave": { + "source.fixAll.ruff": "explicit", + "source.organizeImports.ruff": "explicit" + }, + "editor.defaultFormatter": "charliermarsh.ruff" + }, + "terminal.integrated.gpuAcceleration": "off", + "python.analysis.typeCheckingMode": "basic" } }, "features": { From f08a8f429079f93b16471b25314b6f3d02dfe6c5 Mon Sep 17 00:00:00 2001 From: Ollie Silvester Date: Tue, 16 Sep 2025 13:33:22 +0000 Subject: [PATCH 07/21] test commit --- docs/developer/general/how-to/get-started.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/developer/general/how-to/get-started.rst b/docs/developer/general/how-to/get-started.rst index 94d965de70..e575dce29d 100644 --- a/docs/developer/general/how-to/get-started.rst +++ b/docs/developer/general/how-to/get-started.rst @@ -4,8 +4,8 @@ Get Started with mx-bluesky Development Environment ======================= -- Clone this repo using SSH: ``git clone git@github.com:DiamondLightSource/mx-bluesky.git`` -- To install a ``dev`` environment, from the top level ``mx-bluesky`` directory, run ``./utility_scripts/dls_dev_env.sh``. Note that this will also clone and install a local version of ``dodal``, as the ``mx-bluesky`` package makes use of the devices instantiated there. +1. Clone this repo using SSH: ``git clone git@github.com:DiamondLightSource/mx-bluesky.git`` +2. At the same directory level as you completed step 1 The recommended IDE is vscode, and a workspace which includes dodal has been set up in the repo. This can be used on a DLS machine as follows: From 9aa3b1743fb6a8e477ebc78a8830f75bd4918333 Mon Sep 17 00:00:00 2001 From: Ollie Silvester Date: Tue, 16 Sep 2025 13:51:54 +0000 Subject: [PATCH 08/21] Update getting started docs --- docs/developer/general/how-to/get-started.md | 34 +++++++++++++++++++ docs/developer/general/how-to/get-started.rst | 26 -------------- 2 files changed, 34 insertions(+), 26 deletions(-) create mode 100644 docs/developer/general/how-to/get-started.md delete mode 100644 docs/developer/general/how-to/get-started.rst diff --git a/docs/developer/general/how-to/get-started.md b/docs/developer/general/how-to/get-started.md new file mode 100644 index 0000000000..d89eaa0127 --- /dev/null +++ b/docs/developer/general/how-to/get-started.md @@ -0,0 +1,34 @@ +# Get Started with mx-bluesky +--------------------------- + +## Development Environment + +We recommend using devcontainers with vscode as the IDE when developing using a DLS machine. Here's how you can set this up: + +- Clone this repo using SSH: `git clone git@github.com:DiamondLightSource/mx-bluesky.git`. +- At the same directory level as you were in for step 1, clone dodal using SSH: ``git@github.com:DiamondLightSource/dodal.git``. +You should now have a directory structure looking like`/some_path/mx-bluesky` and `some_path/dodal`. +- In a terminal, move to the mx-bluesky directory and open vscode: + +``` +cd /some_path/mx-bluesky +module load vscode +code . +``` + +- Make sure you have the [devcontainers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) installed in vscode. +- In vscode, press `shift+ctrl+p`, and type "Dev Containers: Open Folder in Container", then select the mx-bluesky folder +- Once this has built, in vscode at the top right, click `File -> Open workspace from file`, then select `mx-bluesky/.vscode/mx-bluesky.code-workspace` +- This should get dodal and mx-bluesky opened up in your workspace with all the correct settings. To prove to yourself that the environment is correct, type `tox -e tests` in a terminal in your devcontainer while inside the dodal and inside the mx-bluesky directory. + +### Notes +- The devcontainer initially takes quite a long time to build. It will be much faster every other time, and only needs to be rebuild if we change the container environment. +- The first time you make a commit after building, you will need to follow some git prompts to set your git name and email. + + +## Supported Python versions + + +As a standard for the python versions to support, we are using the [numpy deprecation policy] (https://numpy.org/neps/nep-0029-deprecation_policy.html) + +Currently supported versions are: 3.11, 3.12. diff --git a/docs/developer/general/how-to/get-started.rst b/docs/developer/general/how-to/get-started.rst deleted file mode 100644 index e575dce29d..0000000000 --- a/docs/developer/general/how-to/get-started.rst +++ /dev/null @@ -1,26 +0,0 @@ -Get Started with mx-bluesky ---------------------------- -======================= -Development Environment -======================= - -1. Clone this repo using SSH: ``git clone git@github.com:DiamondLightSource/mx-bluesky.git`` -2. At the same directory level as you completed step 1 - -The recommended IDE is vscode, and a workspace which includes dodal has been set up in the repo. This can be used on a DLS machine as follows: - -.. code-block:: bash - - cd /path/to/mx-bluesky - module load vscode - code ./.vscode/mx-bluesky.code-workspace - -- If you use vs code, you may need to set the python interpreter for both repositories to the one from the virtual environment created in ``.venv`` - -========================= -Supported Python versions -========================= - -As a standard for the python versions to support, we are using the `numpy deprecation policy `_. - -Currently supported versions are: 3.10, 3.11. From 2cba2d7d95e1bb25696f207426866a7ca4539bc1 Mon Sep 17 00:00:00 2001 From: Ollie Silvester Date: Tue, 16 Sep 2025 13:56:06 +0000 Subject: [PATCH 09/21] Fix typos on docs --- docs/developer/general/how-to/get-started.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/developer/general/how-to/get-started.md b/docs/developer/general/how-to/get-started.md index d89eaa0127..4d7f6251b2 100644 --- a/docs/developer/general/how-to/get-started.md +++ b/docs/developer/general/how-to/get-started.md @@ -6,8 +6,8 @@ We recommend using devcontainers with vscode as the IDE when developing using a DLS machine. Here's how you can set this up: - Clone this repo using SSH: `git clone git@github.com:DiamondLightSource/mx-bluesky.git`. -- At the same directory level as you were in for step 1, clone dodal using SSH: ``git@github.com:DiamondLightSource/dodal.git``. -You should now have a directory structure looking like`/some_path/mx-bluesky` and `some_path/dodal`. +- At the same directory level as you were in for step 1, clone dodal using SSH: `git clone git@github.com:DiamondLightSource/dodal.git`. +You should now have a directory structure looking like`/some_path/mx-bluesky` and `/some_path/dodal`. - In a terminal, move to the mx-bluesky directory and open vscode: ``` @@ -17,8 +17,8 @@ code . ``` - Make sure you have the [devcontainers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) installed in vscode. -- In vscode, press `shift+ctrl+p`, and type "Dev Containers: Open Folder in Container", then select the mx-bluesky folder -- Once this has built, in vscode at the top right, click `File -> Open workspace from file`, then select `mx-bluesky/.vscode/mx-bluesky.code-workspace` +- In vscode, press `shift+ctrl+p`, and type "Dev Containers: Open Folder in Container", then select the mx-bluesky folder. +- Once this has built, in vscode at the top right, click `File -> Open workspace from file`, then select `mx-bluesky/.vscode/mx-bluesky.code-workspace`. - This should get dodal and mx-bluesky opened up in your workspace with all the correct settings. To prove to yourself that the environment is correct, type `tox -e tests` in a terminal in your devcontainer while inside the dodal and inside the mx-bluesky directory. ### Notes From 6997fb635fa7771319870140cea3a58a35bc7bb6 Mon Sep 17 00:00:00 2001 From: Ollie Silvester Date: Tue, 16 Sep 2025 14:06:35 +0000 Subject: [PATCH 10/21] Fix docs CI --- docs/developer/general/how-to/get-started.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/developer/general/how-to/get-started.md b/docs/developer/general/how-to/get-started.md index 4d7f6251b2..7f3e9bbc30 100644 --- a/docs/developer/general/how-to/get-started.md +++ b/docs/developer/general/how-to/get-started.md @@ -1,5 +1,4 @@ # Get Started with mx-bluesky ---------------------------- ## Development Environment From 8651e07502dfdd3392bbe44eef4e201cc314fd63 Mon Sep 17 00:00:00 2001 From: Srishty Date: Tue, 16 Sep 2025 16:01:27 +0100 Subject: [PATCH 11/21] add OAV image plan --- .../i04/test_plans/oav_automation.py | 54 +++++++++++++------ 1 file changed, 37 insertions(+), 17 deletions(-) diff --git a/src/mx_bluesky/beamlines/i04/test_plans/oav_automation.py b/src/mx_bluesky/beamlines/i04/test_plans/oav_automation.py index 0894ea0d1f..664769a060 100644 --- a/src/mx_bluesky/beamlines/i04/test_plans/oav_automation.py +++ b/src/mx_bluesky/beamlines/i04/test_plans/oav_automation.py @@ -1,14 +1,19 @@ - from bluesky.utils import MsgGenerator import bluesky.plan_stubs as bps -#import bluesky.preprocessors as bpp -#from bluesky.preprocessors import run_decorator, stage_wrapper, subs_decorator + +# import bluesky.preprocessors as bpp +# from bluesky.preprocessors import run_decorator, stage_wrapper, subs_decorator from bluesky.utils import MsgGenerator from dodal.common import inject from dodal.devices.attenuator.attenuator import BinaryFilterAttenuator -from dodal.devices.zebra.zebra_controlled_shutter import ZebraShutter, ZebraShutterState, ZebraShutterControl -from sqlalchemy import Boolean +from dodal.devices.zebra.zebra_controlled_shutter import ( + ZebraShutter, + ZebraShutterState, + ZebraShutterControl, +) +from dodal.devices.oav.oav_detector import OAV +from dodal.devices.oav.snapshots.snapshot_with_grid import SnapshotWithGrid """ My task: @@ -20,32 +25,47 @@ """ +#def oav_automation_test() + def set_transmission_percentage( percentage: float, - attenuator: BinaryFilterAttenuator, + attenuator: BinaryFilterAttenuator = inject("attenuator"), ) -> MsgGenerator: - - yield from bps.abs_set(attenuator, percentage/100) + yield from bps.abs_set(attenuator, percentage / 100) def open_close_fast_shutter( - shutter: ZebraShutter, - shutter_state: Boolean, - #shutter_control: ZebraShutterControl + shutter: ZebraShutter, + shutter_state: ZebraShutterState, ) -> MsgGenerator: + base_control_mode = yield from bps.rd(shutter.control_mode) + yield from bps.abs_set(shutter.control_mode, ZebraShutterControl.MANUAL) - if shutter_state: - yield from bps.abs_set(shutter._manual_position_setpoint, ZebraShutterState.OPEN) - else: - yield from bps.abs_set(shutter._manual_position_setpoint, ZebraShutterState.CLOSE) + yield from bps.abs_set( + shutter, shutter_state + ) + + yield from bps.abs_set(shutter.control_mode, base_control_mode) + +def take_OAV_image( + file_path: str , + file_name: str , + oav: OAV = inject("oav"), + +) -> MsgGenerator: + group = "path setting" + yield from bps.abs_set(oav.grid_snapshot.filename, file_name, group=group) + yield from bps.abs_set(oav.grid_snapshot.directory, file_path, group=group) + yield from bps.wait(group) + yield from bps.trigger(oav.grid_snapshot) + + def move_scintillator(): pass -def take_OAV_image(): - pass From b9f19b6571ad73390f423ea168b0adce4ceaaec7 Mon Sep 17 00:00:00 2001 From: Ollie Silvester Date: Tue, 16 Sep 2025 15:20:54 +0000 Subject: [PATCH 12/21] Add dodal dev dependencies to devcontainer --- .devcontainer/devcontainer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 0324b3e7b7..d5e2a76391 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -68,5 +68,5 @@ // Mount the parent as /workspaces so we can pip install peers as editable "workspaceMount": "source=${localWorkspaceFolder}/..,target=/workspaces,type=bind", // After the container is created, install the python project in editable form - "postCreateCommand": "pip install $([ -f dev-requirements.txt ] && echo '-c dev-requirements.txt') -e '.[dev]' && pip install -e /workspaces/dodal && pre-commit install" + "postCreateCommand": "pip install $([ -f dev-requirements.txt ] && echo '-c dev-requirements.txt') -e '.[dev]' && pip install -e /workspaces/dodal[dev] && pre-commit install" } From c91adca486ad3402c68e65469565722a977d8752 Mon Sep 17 00:00:00 2001 From: Ollie Silvester Date: Tue, 16 Sep 2025 16:54:54 +0000 Subject: [PATCH 13/21] Get dlstbx working in devcontainer --- .devcontainer/devcontainer.json | 7 ++++-- .../mx-bluesky-dev-container.code-workspace | 23 +++++++++++++++++++ .vscode/mx-bluesky.code-workspace | 4 +++- docs/developer/general/how-to/get-started.md | 6 ++--- 4 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 .vscode/mx-bluesky-dev-container.code-workspace diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index d5e2a76391..59bebd5933 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -32,7 +32,7 @@ ], "python.testing.unittestEnabled": false, "python.testing.pytestEnabled": true, - "python.defaultInterpreterPath": ".venv/bin/python", + "python.defaultInterpreterPath": "/venv/bin/python", "editor.formatOnSave": true, "editor.codeActionsOnSave": { "source.organizeImports": "explicit" @@ -67,6 +67,9 @@ ], // Mount the parent as /workspaces so we can pip install peers as editable "workspaceMount": "source=${localWorkspaceFolder}/..,target=/workspaces,type=bind", + "mounts": [ + "source=/dls_sw/apps/dials/latest/latest/modules/dlstbx/src/dlstbx/,target=/dls_sw/apps/dials/latest/latest/modules/dlstbx/src/dlstbx/,type=bind,consistency=cached" + ], // After the container is created, install the python project in editable form - "postCreateCommand": "pip install $([ -f dev-requirements.txt ] && echo '-c dev-requirements.txt') -e '.[dev]' && pip install -e /workspaces/dodal[dev] && pre-commit install" + "postCreateCommand": "pip install $([ -f dev-requirements.txt ] && echo '-c dev-requirements.txt') -e '.[dev]' && pip install -e /workspaces/dodal[dev] && pre-commit install && ln -s /dls_sw/apps/dials/latest/latest/modules/dlstbx/src/dlstbx/ /venv/lib/python3.12/site-packages/dlstbx" } diff --git a/.vscode/mx-bluesky-dev-container.code-workspace b/.vscode/mx-bluesky-dev-container.code-workspace new file mode 100644 index 0000000000..45844927b8 --- /dev/null +++ b/.vscode/mx-bluesky-dev-container.code-workspace @@ -0,0 +1,23 @@ +{ + "folders": [ + { + "path": ".." + }, + { + "path": "../../dodal" + } + ], + "settings": { + "python.languageServer": "Pylance", + "[python]": { + "editor.defaultFormatter": "ms-python.black-formatter" + }, + "python.defaultInterpreterPath": "venv/bin/python", + "python.analysis.extraPaths": [ + "../dodal" + ], + "python.analysis.autoImportCompletions": true, + "terminal.integrated.gpuAcceleration": "off", + "esbonio.sphinx.confDir": "" + } +} diff --git a/.vscode/mx-bluesky.code-workspace b/.vscode/mx-bluesky.code-workspace index 7bd39b4906..20c4b869c5 100644 --- a/.vscode/mx-bluesky.code-workspace +++ b/.vscode/mx-bluesky.code-workspace @@ -13,7 +13,9 @@ "editor.defaultFormatter": "ms-python.black-formatter" }, "python.defaultInterpreterPath": ".venv/bin/python", - "python.analysis.extraPaths": ["../dodal"], + "python.analysis.extraPaths": [ + "../dodal" + ], "python.analysis.autoImportCompletions": true, "terminal.integrated.gpuAcceleration": "off", "esbonio.sphinx.confDir": "" diff --git a/docs/developer/general/how-to/get-started.md b/docs/developer/general/how-to/get-started.md index 7f3e9bbc30..53e0a8a952 100644 --- a/docs/developer/general/how-to/get-started.md +++ b/docs/developer/general/how-to/get-started.md @@ -17,17 +17,17 @@ code . - Make sure you have the [devcontainers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) installed in vscode. - In vscode, press `shift+ctrl+p`, and type "Dev Containers: Open Folder in Container", then select the mx-bluesky folder. -- Once this has built, in vscode at the top right, click `File -> Open workspace from file`, then select `mx-bluesky/.vscode/mx-bluesky.code-workspace`. +- Once this has built, in vscode at the top right, click `File -> Open workspace from file`, then select `mx-bluesky/.vscode/mx-bluesky-dev-container.code-workspace`. - This should get dodal and mx-bluesky opened up in your workspace with all the correct settings. To prove to yourself that the environment is correct, type `tox -e tests` in a terminal in your devcontainer while inside the dodal and inside the mx-bluesky directory. ### Notes - The devcontainer initially takes quite a long time to build. It will be much faster every other time, and only needs to be rebuild if we change the container environment. - The first time you make a commit after building, you will need to follow some git prompts to set your git name and email. - +- The old `dls_dev_env.sh` script creates a virtual environment in `mx-bluesky/.venv`, while the devcontainer creates one in `mx-bluesky/venv`. This is the only reason why we need separate code-workspace files. ## Supported Python versions -As a standard for the python versions to support, we are using the [numpy deprecation policy] (https://numpy.org/neps/nep-0029-deprecation_policy.html) +As a standard for the python versions to support, we are using the [numpy deprecation policy](https://numpy.org/neps/nep-0029-deprecation_policy.html) Currently supported versions are: 3.11, 3.12. From 0894d531aa5df874dca2a53564c3426695eddfd9 Mon Sep 17 00:00:00 2001 From: Srishty Date: Mon, 22 Sep 2025 10:21:52 +0000 Subject: [PATCH 14/21] Resolve linting issues --- .../i04/test_plans/oav_automation.py | 38 ++++++------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/src/mx_bluesky/beamlines/i04/test_plans/oav_automation.py b/src/mx_bluesky/beamlines/i04/test_plans/oav_automation.py index 664769a060..c442252633 100644 --- a/src/mx_bluesky/beamlines/i04/test_plans/oav_automation.py +++ b/src/mx_bluesky/beamlines/i04/test_plans/oav_automation.py @@ -1,31 +1,25 @@ -from bluesky.utils import MsgGenerator import bluesky.plan_stubs as bps - -# import bluesky.preprocessors as bpp -# from bluesky.preprocessors import run_decorator, stage_wrapper, subs_decorator from bluesky.utils import MsgGenerator - from dodal.common import inject from dodal.devices.attenuator.attenuator import BinaryFilterAttenuator +from dodal.devices.oav.oav_detector import OAV from dodal.devices.zebra.zebra_controlled_shutter import ( ZebraShutter, - ZebraShutterState, ZebraShutterControl, + ZebraShutterState, ) -from dodal.devices.oav.oav_detector import OAV -from dodal.devices.oav.snapshots.snapshot_with_grid import SnapshotWithGrid -""" -My task: +# from dodal.devices.oav.snapshots.snapshot_with_grid import SnapshotWithGrid +""" +My task: Move the scintillator in and out Change transmission percentage Take OAV images Open and close fast shutter - """ -#def oav_automation_test() +# def oav_automation_test() def set_transmission_percentage( @@ -38,23 +32,19 @@ def set_transmission_percentage( def open_close_fast_shutter( shutter: ZebraShutter, shutter_state: ZebraShutterState, - ) -> MsgGenerator: - base_control_mode = yield from bps.rd(shutter.control_mode) yield from bps.abs_set(shutter.control_mode, ZebraShutterControl.MANUAL) - yield from bps.abs_set( - shutter, shutter_state - ) - + yield from bps.abs_set(shutter, shutter_state) + yield from bps.abs_set(shutter.control_mode, base_control_mode) + def take_OAV_image( - file_path: str , - file_name: str , - oav: OAV = inject("oav"), - + file_path: str, + file_name: str, + oav: OAV = inject("oav"), ) -> MsgGenerator: group = "path setting" yield from bps.abs_set(oav.grid_snapshot.filename, file_name, group=group) @@ -62,10 +52,6 @@ def take_OAV_image( yield from bps.wait(group) yield from bps.trigger(oav.grid_snapshot) - def move_scintillator(): pass - - - From 4e2ef1dc9362bf22a5974eebe9f9176df1aac5b7 Mon Sep 17 00:00:00 2001 From: Srishty Date: Mon, 22 Sep 2025 11:53:01 +0000 Subject: [PATCH 15/21] start adding scintillator --- src/mx_bluesky/beamlines/i04/test_plans/oav_automation.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/mx_bluesky/beamlines/i04/test_plans/oav_automation.py b/src/mx_bluesky/beamlines/i04/test_plans/oav_automation.py index c442252633..1dfe7a141a 100644 --- a/src/mx_bluesky/beamlines/i04/test_plans/oav_automation.py +++ b/src/mx_bluesky/beamlines/i04/test_plans/oav_automation.py @@ -3,6 +3,7 @@ from dodal.common import inject from dodal.devices.attenuator.attenuator import BinaryFilterAttenuator from dodal.devices.oav.oav_detector import OAV +from dodal.devices.scintillator import InOut, Scintillator from dodal.devices.zebra.zebra_controlled_shutter import ( ZebraShutter, ZebraShutterControl, @@ -53,5 +54,7 @@ def take_OAV_image( yield from bps.trigger(oav.grid_snapshot) -def move_scintillator(): - pass +def move_scintillator( + scintillator: Scintillator, scintillator_state: InOut +) -> MsgGenerator: + yield from bps.abs_set(scintillator, scintillator_state) From 4a9ee2456fbc14607295ae58eea60eada191a544 Mon Sep 17 00:00:00 2001 From: Srishty Date: Mon, 22 Sep 2025 14:04:17 +0000 Subject: [PATCH 16/21] Add injects and add beam feedback check and add scintillator --- .../beamlines/i04/test_plans/oav_automation.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/mx_bluesky/beamlines/i04/test_plans/oav_automation.py b/src/mx_bluesky/beamlines/i04/test_plans/oav_automation.py index 1dfe7a141a..c3fd77cfbf 100644 --- a/src/mx_bluesky/beamlines/i04/test_plans/oav_automation.py +++ b/src/mx_bluesky/beamlines/i04/test_plans/oav_automation.py @@ -4,6 +4,7 @@ from dodal.devices.attenuator.attenuator import BinaryFilterAttenuator from dodal.devices.oav.oav_detector import OAV from dodal.devices.scintillator import InOut, Scintillator +from dodal.devices.xbpm_feedback import XBPMFeedback from dodal.devices.zebra.zebra_controlled_shutter import ( ZebraShutter, ZebraShutterControl, @@ -20,7 +21,12 @@ Open and close fast shutter """ + # def oav_automation_test() +def feedback_check( + device: XBPMFeedback = inject("xbpm_feedback"), +): + yield from bps.trigger(device) def set_transmission_percentage( @@ -31,8 +37,8 @@ def set_transmission_percentage( def open_close_fast_shutter( - shutter: ZebraShutter, shutter_state: ZebraShutterState, + shutter: ZebraShutter = inject("fast_shutter"), ) -> MsgGenerator: base_control_mode = yield from bps.rd(shutter.control_mode) @@ -55,6 +61,6 @@ def take_OAV_image( def move_scintillator( - scintillator: Scintillator, scintillator_state: InOut + scintillator_state: InOut, scintillator: Scintillator = inject("scintillator") ) -> MsgGenerator: - yield from bps.abs_set(scintillator, scintillator_state) + yield from bps.abs_set(scintillator.selected_pos, scintillator_state) From e7f131d8a1f7d6b33796f6b19eaa68ab30f5f496 Mon Sep 17 00:00:00 2001 From: Srishty Date: Mon, 22 Sep 2025 14:44:47 +0000 Subject: [PATCH 17/21] Add imports to __init__.py --- .../beamlines/i04/test_plans/__init__.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/mx_bluesky/beamlines/i04/test_plans/__init__.py b/src/mx_bluesky/beamlines/i04/test_plans/__init__.py index e69de29bb2..3d393b9ab0 100644 --- a/src/mx_bluesky/beamlines/i04/test_plans/__init__.py +++ b/src/mx_bluesky/beamlines/i04/test_plans/__init__.py @@ -0,0 +1,15 @@ +from mx_bluesky.beamlines.i04.test_plans.oav_automation import ( + feedback_check, + move_scintillator, + open_close_fast_shutter, + set_transmission_percentage, + take_OAV_image, +) + +__all__ = [ + "feedback_check", + "move_scintillator", + "open_close_fast_shutter", + "set_transmission_percentage", + "take_OAV_image", +] From 3350ba204f4bf1301aaa4787121acbbe340ca559 Mon Sep 17 00:00:00 2001 From: Srishty Date: Tue, 23 Sep 2025 08:42:27 +0000 Subject: [PATCH 18/21] Change according to Dom's comments - with wait = True or use mv instead --- .../i04/test_plans/oav_automation.py | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/mx_bluesky/beamlines/i04/test_plans/oav_automation.py b/src/mx_bluesky/beamlines/i04/test_plans/oav_automation.py index c3fd77cfbf..756572c917 100644 --- a/src/mx_bluesky/beamlines/i04/test_plans/oav_automation.py +++ b/src/mx_bluesky/beamlines/i04/test_plans/oav_automation.py @@ -24,16 +24,16 @@ # def oav_automation_test() def feedback_check( - device: XBPMFeedback = inject("xbpm_feedback"), + feedback: XBPMFeedback = inject("xbpm_feedback"), ): - yield from bps.trigger(device) + yield from bps.trigger(feedback, wait=True) def set_transmission_percentage( percentage: float, attenuator: BinaryFilterAttenuator = inject("attenuator"), ) -> MsgGenerator: - yield from bps.abs_set(attenuator, percentage / 100) + yield from bps.mv(attenuator, percentage / 100) def open_close_fast_shutter( @@ -42,10 +42,10 @@ def open_close_fast_shutter( ) -> MsgGenerator: base_control_mode = yield from bps.rd(shutter.control_mode) - yield from bps.abs_set(shutter.control_mode, ZebraShutterControl.MANUAL) - yield from bps.abs_set(shutter, shutter_state) + yield from bps.abs_set(shutter.control_mode, ZebraShutterControl.MANUAL, wait=True) + yield from bps.abs_set(shutter, shutter_state, wait=True) - yield from bps.abs_set(shutter.control_mode, base_control_mode) + yield from bps.abs_set(shutter.control_mode, base_control_mode, wait=True) def take_OAV_image( @@ -54,13 +54,13 @@ def take_OAV_image( oav: OAV = inject("oav"), ) -> MsgGenerator: group = "path setting" - yield from bps.abs_set(oav.grid_snapshot.filename, file_name, group=group) - yield from bps.abs_set(oav.grid_snapshot.directory, file_path, group=group) + yield from bps.abs_set(oav.snapshot.filename, file_name, group=group) + yield from bps.abs_set(oav.snapshot.directory, file_path, group=group) yield from bps.wait(group) - yield from bps.trigger(oav.grid_snapshot) + yield from bps.trigger(oav.snapshot, wait=True) def move_scintillator( scintillator_state: InOut, scintillator: Scintillator = inject("scintillator") ) -> MsgGenerator: - yield from bps.abs_set(scintillator.selected_pos, scintillator_state) + yield from bps.mv(scintillator.selected_pos, scintillator_state) From 8a461bcdad0e7669de0ce8e65f813c9fa5bd6977 Mon Sep 17 00:00:00 2001 From: Srishty Date: Tue, 23 Sep 2025 11:57:17 +0100 Subject: [PATCH 19/21] hotfixes from beamline --- src/mx_bluesky/beamlines/i04/__init__.py | 12 ++++++++++++ .../beamlines/i04/test_plans/oav_automation.py | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/mx_bluesky/beamlines/i04/__init__.py b/src/mx_bluesky/beamlines/i04/__init__.py index 8827b7b06f..cf01ee9af4 100644 --- a/src/mx_bluesky/beamlines/i04/__init__.py +++ b/src/mx_bluesky/beamlines/i04/__init__.py @@ -7,9 +7,21 @@ thaw_and_stream_to_redis, ) +from mx_bluesky.beamlines.i04.test_plans.oav_automation import ( + feedback_check, + move_scintillator, + open_close_fast_shutter, + set_transmission_percentage, + take_OAV_image,) + __all__ = [ "thaw", "thaw_and_stream_to_redis", "i04_grid_detect_then_xray_centre", "thaw_and_murko_centre", + "feedback_check", + "move_scintillator", + "open_close_fast_shutter", + "set_transmission_percentage", + "take_OAV_image", ] diff --git a/src/mx_bluesky/beamlines/i04/test_plans/oav_automation.py b/src/mx_bluesky/beamlines/i04/test_plans/oav_automation.py index 756572c917..501af36c0a 100644 --- a/src/mx_bluesky/beamlines/i04/test_plans/oav_automation.py +++ b/src/mx_bluesky/beamlines/i04/test_plans/oav_automation.py @@ -38,7 +38,7 @@ def set_transmission_percentage( def open_close_fast_shutter( shutter_state: ZebraShutterState, - shutter: ZebraShutter = inject("fast_shutter"), + shutter: ZebraShutter = inject("sample_shutter"), ) -> MsgGenerator: base_control_mode = yield from bps.rd(shutter.control_mode) From fce5453e674a2aafd73d8a0fe2d202ba8e021654 Mon Sep 17 00:00:00 2001 From: Srishty Date: Tue, 23 Sep 2025 15:33:17 +0000 Subject: [PATCH 20/21] fix lint checks --- src/mx_bluesky/beamlines/i04/__init__.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/mx_bluesky/beamlines/i04/__init__.py b/src/mx_bluesky/beamlines/i04/__init__.py index cf01ee9af4..c3586fa9a8 100644 --- a/src/mx_bluesky/beamlines/i04/__init__.py +++ b/src/mx_bluesky/beamlines/i04/__init__.py @@ -1,18 +1,18 @@ from mx_bluesky.beamlines.i04.experiment_plans.i04_grid_detect_then_xray_centre_plan import ( i04_grid_detect_then_xray_centre, ) -from mx_bluesky.beamlines.i04.thawing_plan import ( - thaw, - thaw_and_murko_centre, - thaw_and_stream_to_redis, -) - from mx_bluesky.beamlines.i04.test_plans.oav_automation import ( feedback_check, move_scintillator, open_close_fast_shutter, set_transmission_percentage, - take_OAV_image,) + take_OAV_image, +) +from mx_bluesky.beamlines.i04.thawing_plan import ( + thaw, + thaw_and_murko_centre, + thaw_and_stream_to_redis, +) __all__ = [ "thaw", From 50ff42dccc020f9ede2efe58b9d7c6e6586690b1 Mon Sep 17 00:00:00 2001 From: Srishty Date: Tue, 23 Sep 2025 15:52:14 +0000 Subject: [PATCH 21/21] test --- src/mx_bluesky/beamlines/i04/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mx_bluesky/beamlines/i04/__init__.py b/src/mx_bluesky/beamlines/i04/__init__.py index c3586fa9a8..cfade94183 100644 --- a/src/mx_bluesky/beamlines/i04/__init__.py +++ b/src/mx_bluesky/beamlines/i04/__init__.py @@ -25,3 +25,5 @@ "set_transmission_percentage", "take_OAV_image", ] + +# testing my git script