From 6d61d1dc467d76cea775a63b3991e559a818e8a9 Mon Sep 17 00:00:00 2001 From: "Ware, Joseph (DLSLtd,RAL,LSCI)" Date: Thu, 14 Nov 2024 12:27:44 +0000 Subject: [PATCH 01/12] Remove dls-bluesky-core as dependency and move to bluesky>=1.13.0 --- docs/explanations/lifecycle.md | 4 ++-- pyproject.toml | 6 ++---- src/blueapi/config.py | 4 ++-- src/blueapi/startup/example_plans.py | 6 +++--- tests/unit_tests/core/test_context.py | 3 ++- tests/unit_tests/test_config.py | 16 ++++++++-------- 6 files changed, 19 insertions(+), 20 deletions(-) diff --git a/docs/explanations/lifecycle.md b/docs/explanations/lifecycle.md index 862f3a754..f0455d28b 100644 --- a/docs/explanations/lifecycle.md +++ b/docs/explanations/lifecycle.md @@ -6,8 +6,8 @@ of being written, loaded and run. Take the following plan. from typing import Any, List, Mapping, Optional, Union import bluesky.plans as bp - from blueapi.core import MsgGenerator - from dls_bluesky_core.core import inject + from bluesky.utils import MsgGenerator + from dodal.common import inject from bluesky.protocols import Readable diff --git a/pyproject.toml b/pyproject.toml index a84e0b62b..4e14e5373 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,7 @@ classifiers = [ ] description = "Lightweight bluesky-as-a-service wrapper application. Also usable as a library." dependencies = [ - "bluesky==1.13.0a3", + "bluesky>=1.13", "ophyd", "nslsii", "pyepics", @@ -27,8 +27,7 @@ dependencies = [ "fastapi>=0.112.0", "uvicorn", "requests", - "dls-bluesky-core", #requires ophyd-async - "dls-dodal>=1.31.0", + "dls-dodal>=1.36.0", "super-state-machine", # https://github.com/DiamondLightSource/blueapi/issues/553 "GitPython", "bluesky-stomp>=0.1.2", @@ -150,5 +149,4 @@ extend-immutable-calls = [ "fastapi.Depends", "fastapi.Body", "fastapi.Task", - "dls_bluesky_core.core.inject", ] diff --git a/src/blueapi/config.py b/src/blueapi/config.py index 16e470c0d..468e00f98 100644 --- a/src/blueapi/config.py +++ b/src/blueapi/config.py @@ -51,8 +51,8 @@ class EnvironmentConfig(BlueapiBaseModel): kind=SourceKind.DEVICE_FUNCTIONS, module="blueapi.startup.example_devices" ), Source(kind=SourceKind.PLAN_FUNCTIONS, module="blueapi.startup.example_plans"), - Source(kind=SourceKind.PLAN_FUNCTIONS, module="dls_bluesky_core.plans"), - Source(kind=SourceKind.PLAN_FUNCTIONS, module="dls_bluesky_core.stubs"), + Source(kind=SourceKind.PLAN_FUNCTIONS, module="dodal.plans"), + Source(kind=SourceKind.PLAN_FUNCTIONS, module="dodal.plan_stubs.wrapped"), ] events: WorkerEventConfig = Field(default_factory=WorkerEventConfig) diff --git a/src/blueapi/startup/example_plans.py b/src/blueapi/startup/example_plans.py index b3d969521..5e119709b 100644 --- a/src/blueapi/startup/example_plans.py +++ b/src/blueapi/startup/example_plans.py @@ -1,7 +1,7 @@ from bluesky.protocols import Movable, Readable -from dls_bluesky_core.core import inject -from dls_bluesky_core.plans import count -from dls_bluesky_core.stubs import move +from dodal.common import inject +from dodal.plans import count +from dodal.plan_stubs.wrapped import move from blueapi.core import MsgGenerator diff --git a/tests/unit_tests/core/test_context.py b/tests/unit_tests/core/test_context.py index 0540401f2..8b704e48f 100644 --- a/tests/unit_tests/core/test_context.py +++ b/tests/unit_tests/core/test_context.py @@ -5,7 +5,8 @@ import pytest from bluesky.protocols import Descriptor, Movable, Readable, Reading, SyncOrAsync -from dls_bluesky_core.core import MsgGenerator, PlanGenerator, inject +from bluesky.utils import MsgGenerator +from dodal.common import PlanGenerator, inject from ophyd.sim import SynAxis, SynGauss from pydantic import TypeAdapter, ValidationError from pytest import LogCaptureFixture diff --git a/tests/unit_tests/test_config.py b/tests/unit_tests/test_config.py index 5e2ec84f9..a5e0b32ad 100644 --- a/tests/unit_tests/test_config.py +++ b/tests/unit_tests/test_config.py @@ -204,8 +204,8 @@ def temp_yaml_config_file( "env": { "sources": [ {"kind": "dodal", "module": "dodal.adsim"}, - {"kind": "planFunctions", "module": "dls_bluesky_core.plans"}, - {"kind": "planFunctions", "module": "dls_bluesky_core.stubs"}, + {"kind": "planFunctions", "module": "dodal.plans"}, + {"kind": "planFunctions", "module": "dodal.plan_stubs.wrapped"}, ], }, "api": {"host": "0.0.0.0", "port": 8000}, @@ -215,8 +215,8 @@ def temp_yaml_config_file( "env": { "sources": [ {"kind": "dodal", "module": "dodal.adsim"}, - {"kind": "planFunctions", "module": "dls_bluesky_core.plans"}, - {"kind": "planFunctions", "module": "dls_bluesky_core.stubs"}, + {"kind": "planFunctions", "module": "dodal.plans"}, + {"kind": "planFunctions", "module": "dodal.plan_stubs.wrapped"}, ], "events": {"broadcast_status_events": True}, }, @@ -258,8 +258,8 @@ def test_config_yaml_parsed(temp_yaml_config_file): }, "sources": [ {"kind": "dodal", "module": "dodal.adsim"}, - {"kind": "planFunctions", "module": "dls_bluesky_core.plans"}, - {"kind": "planFunctions", "module": "dls_bluesky_core.stubs"}, + {"kind": "planFunctions", "module": "dodal.plans"}, + {"kind": "planFunctions", "module": "dodal.plan_stubs.wrapped"}, ], }, "api": { @@ -287,8 +287,8 @@ def test_config_yaml_parsed(temp_yaml_config_file): "env": { "sources": [ {"kind": "dodal", "module": "dodal.adsim"}, - {"kind": "planFunctions", "module": "dls_bluesky_core.plans"}, - {"kind": "planFunctions", "module": "dls_bluesky_core.stubs"}, + {"kind": "planFunctions", "module": "dodal.plans"}, + {"kind": "planFunctions", "module": "dodal.plan_stubs.wrapped"}, ], "events": {"broadcast_status_events": True}, }, From efe0fd799edb7807247835c0b2beb120b0a0e922 Mon Sep 17 00:00:00 2001 From: "Ware, Joseph (DLSLtd,RAL,LSCI)" Date: Thu, 14 Nov 2024 12:32:18 +0000 Subject: [PATCH 02/12] Update specific version of event-model in asyncapi --- docs/reference/asyncapi.yaml | 20 ++++++++++---------- pyproject.toml | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/reference/asyncapi.yaml b/docs/reference/asyncapi.yaml index 963998e35..2588dc506 100644 --- a/docs/reference/asyncapi.yaml +++ b/docs/reference/asyncapi.yaml @@ -45,7 +45,7 @@ components: name: type: string doc: - $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.21.0/event_model/schemas/run_start.json" + $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.22.1/event_model/schemas/run_start.json" taggedStopDocument: messageId: runStop summary: Indicates the completion of a Bluesky run based on a previously specified Plan; describes end conditions and metadata @@ -57,7 +57,7 @@ components: name: type: string doc: - $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.21.0/event_model/schemas/run_stop.json" + $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.22.1/event_model/schemas/run_stop.json" taggedDescriptorDocument: messageId: eventStreamDescriptor summary: Describes the devices to be within a scientifically related stream of measurements @@ -69,7 +69,7 @@ components: name: type: string doc: - $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.21.0/event_model/schemas/event_descriptor.json" + $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.22.1/event_model/schemas/event_descriptor.json" taggedEventDocument: messageId: dataEvent summary: Describes a point measurement for a number of scientifically related devices @@ -81,7 +81,7 @@ components: name: type: string doc: - $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.21.0/event_model/schemas/event.json" + $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.22.1/event_model/schemas/event.json" taggedEventPage: messageId: eventPage deprecated: true @@ -94,7 +94,7 @@ components: name: type: string doc: - $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.21.0/event_model/schemas/event_page.json" + $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.22.1/event_model/schemas/event_page.json" taggedResourceDocument: messageId: resource summary: Describes an external resource (file, database entry etc.) that is to be referenced by later datum @@ -106,7 +106,7 @@ components: name: type: string doc: - $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.21.0/event_model/schemas/resource.json" + $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.22.1/event_model/schemas/resource.json" taggedDatumDocument: messageId: datum summary: Describes how to access a point measurement within an external resource @@ -118,7 +118,7 @@ components: name: type: string doc: - $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.21.0/event_model/schemas/datum.json" + $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.22.1/event_model/schemas/datum.json" taggedDatumPage: messageId: datumPage deprecated: true @@ -131,7 +131,7 @@ components: name: type: string doc: - $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.21.0/event_model/schemas/datum_page.json" + $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.22.1/event_model/schemas/datum_page.json" taggedResourceStream: messageId: streamResource summary: Describes an external resource (file, database entry etc.) that is to be referenced by later Stream Datum @@ -143,7 +143,7 @@ components: name: type: string doc: - $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.21.0/event_model/schemas/stream_resource.json" + $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.22.1/event_model/schemas/stream_resource.json" taggedDatumStream: messageId: streamDatum summary: Describes how to access a slice of an external resource @@ -155,7 +155,7 @@ components: name: type: string doc: - $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.21.0/event_model/schemas/stream_datum.json" + $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.22.1/event_model/schemas/stream_datum.json" workerStateEvent: messageId: stateEvent headers: diff --git a/pyproject.toml b/pyproject.toml index 4e14e5373..d42b3a62e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,7 +31,7 @@ dependencies = [ "super-state-machine", # https://github.com/DiamondLightSource/blueapi/issues/553 "GitPython", "bluesky-stomp>=0.1.2", - "event-model==1.21", # https://github.com/DiamondLightSource/blueapi/issues/684 + "event-model==1.22.1", # https://github.com/DiamondLightSource/blueapi/issues/684 "opentelemetry-distro>=0.48b0", "opentelemetry-instrumentation-fastapi>=0.48b0", "observability-utils>=0.1.4" From 8e716622f2c49e5f417fedfa9763820b25360811 Mon Sep 17 00:00:00 2001 From: "Ware, Joseph (DLSLtd,RAL,LSCI)" Date: Thu, 14 Nov 2024 12:38:22 +0000 Subject: [PATCH 03/12] Update dev-requirements --- dev-requirements.txt | 138 +++++++++++++++++++------------------------ 1 file changed, 60 insertions(+), 78 deletions(-) diff --git a/dev-requirements.txt b/dev-requirements.txt index 58c2ea6b5..9739d422d 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,8 +1,8 @@ accessible-pygments==0.0.5 -aioca==1.8 +aioca==1.8.1 aiofiles==24.1.0 aiohappyeyeballs==2.4.3 -aiohttp==3.10.10 +aiohttp==3.11.0 aiosignal==1.3.1 alabaster==1.0.0 annotated-types==0.7.0 @@ -11,47 +11,40 @@ appdirs==1.4.4 asciitree==0.3.3 asgiref==3.8.1 asttokens==2.4.1 -async-timeout==4.0.3 attrs==24.2.0 -autodoc_pydantic==2.2.0 babel==2.16.0 beautifulsoup4==4.12.3 bidict==0.23.1 -black==24.10.0 -bluesky==1.13.0a3 +bluesky==1.13 bluesky-kafka==0.10.0 bluesky-live==0.0.8 bluesky-stomp==0.1.2 -boltons==24.0.0 -bump-pydantic==0.8.0 +boltons==24.1.0 cachetools==5.5.0 caproto==1.1.1 certifi==2024.8.30 cfgv==3.4.0 -chardet==5.2.0 charset-normalizer==3.4.0 click==8.1.7 cloudpickle==3.1.0 colorama==0.4.6 -colorlog==6.8.2 +colorlog==6.9.0 comm==0.2.2 compress-pickle==2.1.0 confluent-kafka==2.6.0 -contourpy==1.3.0 +contourpy==1.3.1 copier==9.4.1 coverage==7.6.4 cycler==0.12.1 -dask==2024.10.0 +dask==2024.11.2 databroker==1.2.5 dataclasses-json==0.6.7 decorator==5.1.1 deepdiff==8.0.1 deepmerge==2.0 Deprecated==1.2.14 -diff_cover==9.2.0 distlib==0.3.9 -dls-bluesky-core==0.0.4 -dls-dodal==1.33.0 +dls-dodal==1.36.0 dnspython==2.7.0 docopt==0.6.2 doct==1.1.0 @@ -60,59 +53,55 @@ dunamai==1.22.0 email_validator==2.2.0 entrypoints==0.4 epicscorelibs==7.0.7.99.1.1 -event-model==1.21.0 -exceptiongroup==1.2.2 +event-model==1.22.1 executing==2.1.0 -fastapi==0.115.3 +fastapi==0.115.5 fastapi-cli==0.0.5 fasteners==0.19 filelock==3.16.1 flexcache==0.3 -flexparser==0.3.1 +flexparser==0.4 fonttools==4.54.1 frozenlist==1.5.0 fsspec==2024.10.0 funcy==2.0 gitdb==4.0.11 GitPython==3.1.43 -googleapis-common-protos==1.65.0 +googleapis-common-protos==1.66.0 graypy==2.1.0 -grpcio==1.66.2 +grpcio==1.67.1 h11==0.14.0 h5py==3.12.1 HeapDict==1.0.1 historydict==1.2.6 httpcore==1.0.6 -httptools==0.6.1 +httptools==0.6.4 httpx==0.27.2 humanize==4.11.0 -identify==2.6.1 +identify==2.6.2 idna==3.10 imageio==2.36.0 imagesize==1.4.1 -importlib_metadata==8.4.0 +importlib_metadata==8.5.0 importlib_resources==6.4.5 iniconfig==2.0.0 intake==0.6.4 ipython==8.18.0 ipywidgets==8.1.5 itsdangerous==2.2.0 -jedi==0.19.1 +jedi==0.19.2 Jinja2==3.1.4 jinja2-ansible-filters==1.3.2 -jsonpointer==3.0.0 jsonschema==4.23.0 jsonschema-specifications==2024.10.1 jupyterlab_widgets==3.0.13 kiwisolver==1.4.7 ldap3==2.9.1 -libcst==1.4.0 -livereload==2.7.0 locket==1.0.0 lz4==4.3.3 markdown-it-py==3.0.0 MarkupSafe==3.0.2 -marshmallow==3.23.0 +marshmallow==3.23.1 matplotlib==3.9.2 matplotlib-inline==0.1.7 mdit-py-plugins==0.4.2 @@ -123,36 +112,37 @@ mongoquery==1.4.2 msgpack==1.1.0 msgpack-numpy==0.4.8 multidict==6.1.0 -mypy==1.13.0 +mypy==1.13.0 mypy-extensions==1.0.0 myst-parser==4.0.0 networkx==3.4.2 nodeenv==1.9.1 nose2==0.15.1 -nslsii==0.10.5 -numcodecs==0.13.1 +nslsii==0.10.7 +numcodecs==0.14.0 numpy==1.26.4 observability-utils==0.1.4 +opencv-python==4.10.0.84 opencv-python-headless==4.10.0.84 -opentelemetry-api==1.27.0 -opentelemetry-distro==0.48b0 -opentelemetry-exporter-otlp==1.27.0 -opentelemetry-exporter-otlp-proto-common==1.27.0 -opentelemetry-exporter-otlp-proto-grpc==1.27.0 -opentelemetry-exporter-otlp-proto-http==1.27.0 -opentelemetry-instrumentation==0.48b0 -opentelemetry-instrumentation-asgi==0.48b0 -opentelemetry-instrumentation-fastapi==0.48b0 -opentelemetry-proto==1.27.0 -opentelemetry-sdk==1.27.0 -opentelemetry-semantic-conventions==0.48b0 -opentelemetry-util-http==0.48b0 +opentelemetry-api==1.28.1 +opentelemetry-distro==0.49b1 +opentelemetry-exporter-otlp==1.28.1 +opentelemetry-exporter-otlp-proto-common==1.28.1 +opentelemetry-exporter-otlp-proto-grpc==1.28.1 +opentelemetry-exporter-otlp-proto-http==1.28.1 +opentelemetry-instrumentation==0.49b1 +opentelemetry-instrumentation-asgi==0.49b1 +opentelemetry-instrumentation-fastapi==0.49b1 +opentelemetry-proto==1.28.1 +opentelemetry-sdk==1.28.1 +opentelemetry-semantic-conventions==0.49b1 +opentelemetry-util-http==0.49b1 ophyd==1.9.0 -ophyd-async==0.6.0 +ophyd-async==0.8.0a4 orderly-set==5.2.2 -orjson==3.10.10 +orjson==3.10.11 p4p==4.2.0 -packaging==24.1 +packaging==24.2 pandas==2.2.3 parso==0.8.4 partd==1.4.2 @@ -163,17 +153,17 @@ picobox==4.0.0 pika==1.3.2 pillow==11.0.0 PIMS==0.7 -Pint==0.24.3 +Pint==0.24.4 pipdeptree==2.23.4 platformdirs==4.3.6 pluggy==1.5.0 plumbum==1.9.0 ply==3.11 pre_commit==4.0.1 -prettytable==3.11.0 +prettytable==3.12.0 prompt-toolkit==3.0.36 propcache==0.2.0 -protobuf==4.25.5 +protobuf==5.28.3 psutil==6.1.0 ptyprocess==0.7.0 pure_eval==0.2.3 @@ -182,8 +172,8 @@ py==1.11.0 pyasn1==0.6.1 pycryptodome==3.21.0 pydantic==2.9.2 -pydantic-extra-types==2.9.0 -pydantic-settings==2.6.0 +pydantic-extra-types==2.10.0 +pydantic-settings==2.6.1 pydantic_core==2.23.4 pydantic_numpy==5.0.2 pydata-sphinx-theme==0.16.0 @@ -192,32 +182,31 @@ Pygments==2.18.0 pymongo==4.10.1 pyOlog==4.5.0 pyparsing==3.2.0 -pyright==1.1.386 pytest==8.3.3 pytest-asyncio==0.24.0 -pytest-cov==5.0.0 -pytest-random-order==1.1.1 +pytest-cov==6.0.0 python-dateutil==2.9.0.post0 python-dotenv==1.0.1 -python-multipart==0.0.9 +python-multipart==0.0.17 pytz==2024.2 PyYAML==6.0.2 -pyyaml-include==2.1 questionary==2.0.1 redis==5.2.0 redis-json-dict==0.2.1 referencing==0.35.1 requests==2.32.3 responses==0.25.3 -rich==13.7.1 -rpds-py==0.20.0 +rich==13.9.4 +rpds-py==0.21.0 ruamel.yaml==0.18.6 ruamel.yaml.clib==0.2.12 -ruff==0.7.1 +ruff==0.7.3 scanspec==0.7.6 semver==3.0.2 +setuptools==75.5.0 setuptools-dso==2.11 shellingham==1.5.4 +shortuuid==1.0.13 six==1.16.0 slicerator==1.1.0 smmap==5.0.1 @@ -226,11 +215,8 @@ snowballstemmer==2.2.0 soupsieve==2.6 Sphinx==8.1.3 sphinx-autobuild==2024.10.3 -sphinx-autodoc-typehints==2.3.0 sphinx-click==6.0.0 sphinx-copybutton==0.5.2 -sphinx-jsonschema==1.19.1 -sphinx-pydantic==0.1.1 sphinx_design==0.6.1 sphinx_mdinclude==0.6.2 sphinxcontrib-applehelp==2.0.0 @@ -238,27 +224,23 @@ sphinxcontrib-devhelp==2.0.0 sphinxcontrib-htmlhelp==2.1.0 sphinxcontrib-httpdomain==1.8.1 sphinxcontrib-jsmath==1.0.1 -sphinxcontrib-mermaid==1.0.0 sphinxcontrib-openapi==0.8.4 sphinxcontrib-qthelp==2.0.0 sphinxcontrib-serializinghtml==2.0.0 stack-data==0.6.3 -starlette==0.41.0 -stomp-py==8.1.2 +starlette==0.41.2 +stomp.py==8.2.0 suitcase-mongo==0.6.0 suitcase-msgpack==0.3.0 suitcase-utils==0.5.4 super-state-machine==2.0.2 tifffile==2024.9.20 -tomli==2.0.1 toolz==1.0.0 -tornado==6.4.1 tox==3.28.0 tox-direct==0.4 -tqdm==4.66.5 +tqdm==4.67.0 traitlets==5.14.3 -typer==0.12.4 -types-aiofiles==24.1.0.20240626 +typer==0.13.0 types-mock==5.1.0.20240425 types-PyYAML==6.0.12.20240917 types-requests==2.32.0.20241016 @@ -270,18 +252,18 @@ tzlocal==5.2 ujson==5.10.0 urllib3==2.2.3 uvicorn==0.32.0 -uvloop==0.19.0 -virtualenv==20.27.0 +uvloop==0.21.0 +virtualenv==20.27.1 watchfiles==0.24.0 wcwidth==0.2.13 websocket-client==1.8.0 -websockets==13.1 +websockets==14.1 widgetsnbextension==4.0.13 -workflows==2.27 +workflows==2.28 wrapt==1.16.0 xarray==2024.10.0 -yarl==1.16.0 +yarl==1.17.1 zarr==2.18.3 zict==2.2.0 -zipp==3.20.2 +zipp==3.21.0 zocalo==1.1.1 From 05e03ead764303be07e4dea268cb5f0de92d1057 Mon Sep 17 00:00:00 2001 From: "Ware, Joseph (DLSLtd,RAL,LSCI)" Date: Thu, 14 Nov 2024 12:45:24 +0000 Subject: [PATCH 04/12] Missed references --- helm/blueapi/values.yaml | 4 ++-- src/blueapi/core/bluesky_types.py | 3 ++- tests/unit_tests/core/fake_plan_module.py | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/helm/blueapi/values.yaml b/helm/blueapi/values.yaml index fe35c33e2..5bae760e5 100644 --- a/helm/blueapi/values.yaml +++ b/helm/blueapi/values.yaml @@ -108,9 +108,9 @@ worker: - kind: planFunctions module: blueapi.startup.example_plans - kind: planFunctions - module: dls_bluesky_core.plans + module: dodal.plans - kind: planFunctions - module: dls_bluesky_core.stubs + module: dodal.plan_stubs.wrapped stomp: auth: username: guest diff --git a/src/blueapi/core/bluesky_types.py b/src/blueapi/core/bluesky_types.py index 1a2978213..690b2ec71 100644 --- a/src/blueapi/core/bluesky_types.py +++ b/src/blueapi/core/bluesky_types.py @@ -24,7 +24,8 @@ Triggerable, WritesExternalAssets, ) -from dls_bluesky_core.core import MsgGenerator, PlanGenerator +from bluesky.utils import MsgGenerator +from dodal.common import PlanGenerator from ophyd_async.core import Device as AsyncDevice from pydantic import BaseModel, Field diff --git a/tests/unit_tests/core/fake_plan_module.py b/tests/unit_tests/core/fake_plan_module.py index 5fe5f1279..2bda43f92 100644 --- a/tests/unit_tests/core/fake_plan_module.py +++ b/tests/unit_tests/core/fake_plan_module.py @@ -1 +1 @@ -from dls_bluesky_core.plans import scan # noqa: F401 +from dodal.plans import spec_scan # noqa: F401 From e305a25a2b37bcc2c78a14e3e456848778fb2342 Mon Sep 17 00:00:00 2001 From: "Ware, Joseph (DLSLtd,RAL,LSCI)" Date: Thu, 14 Nov 2024 12:46:42 +0000 Subject: [PATCH 05/12] Mild improvement to asyncapi schema --- docs/reference/asyncapi.yaml | 44 +++++++----------------------------- 1 file changed, 8 insertions(+), 36 deletions(-) diff --git a/docs/reference/asyncapi.yaml b/docs/reference/asyncapi.yaml index 2588dc506..93bbb25db 100644 --- a/docs/reference/asyncapi.yaml +++ b/docs/reference/asyncapi.yaml @@ -30,8 +30,6 @@ channels: - $ref: "#/components/messages/taggedDatumDocument" - $ref: "#/components/messages/taggedResourceStream" - $ref: "#/components/messages/taggedDatumStream" - - $ref: "#/components/messages/taggedEventPage" - - $ref: "#/components/messages/taggedDatumPage" components: messages: # Defined as Components to allow referencing from other APIs. # TODO: Define protocol specific correlationId bindings taggedStartDocument: @@ -43,7 +41,7 @@ components: type: object properties: name: - type: string + const: "start" doc: $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.22.1/event_model/schemas/run_start.json" taggedStopDocument: @@ -55,7 +53,7 @@ components: type: object properties: name: - type: string + const: "stop" doc: $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.22.1/event_model/schemas/run_stop.json" taggedDescriptorDocument: @@ -67,7 +65,7 @@ components: type: object properties: name: - type: string + const: "descriptor" doc: $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.22.1/event_model/schemas/event_descriptor.json" taggedEventDocument: @@ -79,22 +77,9 @@ components: type: object properties: name: - type: string + const: "event" doc: $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.22.1/event_model/schemas/event.json" - taggedEventPage: - messageId: eventPage - deprecated: true - summary: Page style collection of events - headers: - $ref: "#/components/schemas/contextHeaders" - payload: - type: object - properties: - name: - type: string - doc: - $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.22.1/event_model/schemas/event_page.json" taggedResourceDocument: messageId: resource summary: Describes an external resource (file, database entry etc.) that is to be referenced by later datum @@ -104,7 +89,7 @@ components: type: object properties: name: - type: string + const: "resource" doc: $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.22.1/event_model/schemas/resource.json" taggedDatumDocument: @@ -116,22 +101,9 @@ components: type: object properties: name: - type: string + const: "datum" doc: $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.22.1/event_model/schemas/datum.json" - taggedDatumPage: - messageId: datumPage - deprecated: true - summary: Page style collection of datum - headers: - $ref: "#/components/schemas/contextHeaders" - payload: - type: object - properties: - name: - type: string - doc: - $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.22.1/event_model/schemas/datum_page.json" taggedResourceStream: messageId: streamResource summary: Describes an external resource (file, database entry etc.) that is to be referenced by later Stream Datum @@ -141,7 +113,7 @@ components: type: object properties: name: - type: string + const: "stream_resource" doc: $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.22.1/event_model/schemas/stream_resource.json" taggedDatumStream: @@ -153,7 +125,7 @@ components: type: object properties: name: - type: string + const: "stream_datum" doc: $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.22.1/event_model/schemas/stream_datum.json" workerStateEvent: From fbc0a6f7ecb95a402df057fd896a80a9351d91f3 Mon Sep 17 00:00:00 2001 From: "Ware, Joseph (DLSLtd,RAL,LSCI)" Date: Thu, 14 Nov 2024 12:50:59 +0000 Subject: [PATCH 06/12] Restore inject immutable call for linting --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index d42b3a62e..a8a22e2d4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -149,4 +149,5 @@ extend-immutable-calls = [ "fastapi.Depends", "fastapi.Body", "fastapi.Task", + "dodal.common.inject", ] From 43a3abe0ba12e403c975dc24344903fb2c25f44d Mon Sep 17 00:00:00 2001 From: "Ware, Joseph (DLSLtd,RAL,LSCI)" Date: Thu, 14 Nov 2024 12:52:08 +0000 Subject: [PATCH 07/12] Renamed spec_scan in dodal --- tests/unit_tests/core/test_context.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit_tests/core/test_context.py b/tests/unit_tests/core/test_context.py index 8b704e48f..d01db462e 100644 --- a/tests/unit_tests/core/test_context.py +++ b/tests/unit_tests/core/test_context.py @@ -148,7 +148,7 @@ def test_add_plan_from_module(empty_context: BlueskyContext) -> None: import tests.unit_tests.core.fake_plan_module as plan_module empty_context.with_plan_module(plan_module) - assert {"scan"} == empty_context.plans.keys() + assert {"spec_scan"} == empty_context.plans.keys() def test_add_named_device(empty_context: BlueskyContext, sim_motor: SynAxis) -> None: @@ -278,7 +278,7 @@ def test_add_devices_and_plans_from_modules_with_config( "motor_bundle_a", "motor_bundle_b", } == empty_context.devices.keys() - assert {"scan"} == empty_context.plans.keys() + assert {"spec_scan"} == empty_context.plans.keys() def test_function_spec(empty_context: BlueskyContext) -> None: From 8d7627f87d26a91353123591b3a330c5500930c7 Mon Sep 17 00:00:00 2001 From: "Ware, Joseph (DLSLtd,RAL,LSCI)" Date: Thu, 14 Nov 2024 13:35:20 +0000 Subject: [PATCH 08/12] Update expected plans for system tests --- tests/system_tests/plans.json | 70 +++++++++++++++++------------------ 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/tests/system_tests/plans.json b/tests/system_tests/plans.json index d0bba9319..76d17457a 100644 --- a/tests/system_tests/plans.json +++ b/tests/system_tests/plans.json @@ -2,8 +2,8 @@ "plans": [ { "name": "count", - "description": "\n Take `n` readings from a device\n\n Args:\n detectors (Set[Readable]): Readable devices to read\n num (int, optional): Number of readings to take. Defaults to 1.\n delay (Optional[Union[float, List[float]]], optional): Delay between readings.\n Defaults to None.\n metadata (Optional[Mapping[str, Any]], optional): Key-value metadata to include\n in exported data.\n Defaults to None.\n\n Returns:\n MsgGenerator: _description_\n\n Yields:\n Iterator[MsgGenerator]: _description_\n ", - "parameter_schema": { + "description": "Reads from a number of devices.\n Wraps bluesky.plans.count(det, num, delay, md=metadata) exposing only serializable\n parameters and metadata.", + "schema": { "additionalProperties": false, "properties": { "detectors": { @@ -28,9 +28,6 @@ "type": "number" }, "type": "array" - }, - { - "type": "null" } ], "title": "Delay" @@ -56,8 +53,8 @@ }, { "name": "move", - "description": "\n Move a device, wrapper for `bp.mv`.\n\n Args:\n moves (Mapping[Movable, Any]): Mapping of Movables to target positions\n group (Optional[Group], optional): The message group to associate with the\n setting, for sequencing. Defaults to None.\n\n Returns:\n MsgGenerator: Plan\n\n Yields:\n Iterator[MsgGenerator]: Bluesky messages\n ", - "parameter_schema": { + "description": "\n Move a device, wrapper for `bp.mv`.\n\n Args:\n moves (Mapping[Movable, T]): Mapping of Movables to target positions\n group (Group | None, optional): The message group to associate with the\n setting, for sequencing. Defaults to None.\n\n Returns:\n MsgGenerator: Plan\n\n Yields:\n Iterator[MsgGenerator]: Bluesky messages\n ", + "schema": { "additionalProperties": false, "properties": { "moves": { @@ -86,7 +83,7 @@ { "name": "stp_snapshot", "description": "\n Moves devices for pressure and temperature (defaults fetched from the context)\n and captures a single frame from a collection of devices\n\n Args:\n detectors (List[Readable]): A list of devices to read while the sample is at STP\n temperature (Optional[Movable]): A device controlling temperature of the sample,\n defaults to fetching a device name \"sample_temperature\" from the context\n pressure (Optional[Movable]): A device controlling pressure on the sample,\n defaults to fetching a device name \"sample_pressure\" from the context\n Returns:\n MsgGenerator: Plan\n Yields:\n Iterator[MsgGenerator]: Bluesky messages\n ", - "parameter_schema": { + "schema": { "additionalProperties": false, "properties": { "detectors": { @@ -113,9 +110,9 @@ } }, { - "name": "scan", - "description": "\n Scan wrapping `bp.scan_nd`\n\n Args:\n detectors: Set of readable devices, will take a reading at\n each point\n axes_to_move: All axes involved in this scan, names and\n objects\n spec: ScanSpec modelling the path of the scan\n metadata: Key-value metadata to include\n in exported data, defaults to\n None.\n\n Returns:\n MsgGenerator: Plan\n\n Yields:\n Iterator[MsgGenerator]: Bluesky messages\n ", - "parameter_schema": { + "name": "spec_scan", + "description": "Generic plan for reading `detectors` at every point of a ScanSpec `Spec`.\n A `Spec` is an N-dimensional path.\n ", + "schema": { "$defs": { "Circle": { "additionalProperties": false, @@ -141,7 +138,7 @@ }, "radius": { "description": "Radius of the circle", - "exclusiveMinimum": 0.0, + "exclusiveMinimum": 0, "title": "Radius", "type": "number" }, @@ -288,18 +285,18 @@ }, "x_radius": { "description": "The radius along the x axis of the ellipse", - "exclusiveMinimum": 0.0, + "exclusiveMinimum": 0, "title": "X Radius", "type": "number" }, "y_radius": { "description": "The radius along the y axis of the ellipse", - "exclusiveMinimum": 0.0, + "exclusiveMinimum": 0, "title": "Y Radius", "type": "number" }, "angle": { - "default": 0.0, + "default": 0, "description": "The angle of the ellipse (degrees)", "title": "Angle", "type": "number" @@ -579,7 +576,7 @@ "type": "number" }, "angle": { - "default": 0.0, + "default": 0, "description": "Clockwise rotation angle of the rectangle", "title": "Angle", "type": "number" @@ -798,7 +795,7 @@ "type": "integer" }, "rotate": { - "default": 0.0, + "default": 0, "description": "How much to rotate the angle of the spiral", "title": "Rotate", "type": "number" @@ -990,13 +987,6 @@ "type": "array", "uniqueItems": true }, - "axes_to_move": { - "additionalProperties": { - "type": "bluesky.protocols.Movable" - }, - "title": "Axes To Move", - "type": "object" - }, "spec": { "$ref": "#/$defs/Spec" }, @@ -1014,17 +1004,16 @@ }, "required": [ "detectors", - "axes_to_move", "spec" ], - "title": "scan", + "title": "spec_scan", "type": "object" } }, { "name": "set_absolute", - "description": "\n Set a device, wrapper for `bp.abs_set`.\n\n Args:\n movable (Movable): The device to set\n value (T): The new value\n group (Optional[Group], optional): The message group to associate with the\n setting, for sequencing. Defaults to None.\n wait (bool, optional): The group should wait until all setting is complete\n (e.g. a motor has finished moving). Defaults to False.\n\n Returns:\n MsgGenerator: Plan\n\n Yields:\n Iterator[MsgGenerator]: Bluesky messages\n ", - "parameter_schema": { + "description": "\n Set a device, wrapper for `bp.abs_set`.\n\n Args:\n movable (Movable): The device to set\n value (T): The new value\n group (Group | None, optional): The message group to associate with the\n setting, for sequencing. Defaults to None.\n wait (bool, optional): The group should wait until all setting is complete\n (e.g. a motor has finished moving). Defaults to False.\n\n Returns:\n MsgGenerator: Plan\n\n Yields:\n Iterator[MsgGenerator]: Bluesky messages\n ", + "schema": { "additionalProperties": false, "properties": { "movable": { @@ -1060,8 +1049,8 @@ }, { "name": "set_relative", - "description": "\n Change a device, wrapper for `bp.rel_set`.\n\n Args:\n movable (Movable): The device to set\n value (T): The new value\n group (Optional[Group], optional): The message group to associate with the\n setting, for sequencing. Defaults to None.\n wait (bool, optional): The group should wait until all setting is complete\n (e.g. a motor has finished moving). Defaults to False.\n\n Returns:\n MsgGenerator: Plan\n\n Yields:\n Iterator[MsgGenerator]: Bluesky messages\n ", - "parameter_schema": { + "description": "\n Change a device, wrapper for `bp.rel_set`.\n\n Args:\n movable (Movable): The device to set\n value (T): The new value\n group (Group | None, optional): The message group to associate with the\n setting, for sequencing. Defaults to None.\n wait (bool, optional): The group should wait until all setting is complete\n (e.g. a motor has finished moving). Defaults to False.\n\n Returns:\n MsgGenerator: Plan\n\n Yields:\n Iterator[MsgGenerator]: Bluesky messages\n ", + "schema": { "additionalProperties": false, "properties": { "movable": { @@ -1097,8 +1086,8 @@ }, { "name": "move_relative", - "description": "\n Move a device relative to its current position, wrapper for `bp.mvr`.\n\n Args:\n moves (Mapping[Movable, Any]): Mapping of Movables to target deltas\n group (Optional[Group], optional): The message group to associate with the\n setting, for sequencing. Defaults to None.\n\n Returns:\n MsgGenerator: Plan\n\n Yields:\n Iterator[MsgGenerator]: Bluesky messages\n ", - "parameter_schema": { + "description": "\n Move a device relative to its current position, wrapper for `bp.mvr`.\n\n Args:\n moves (Mapping[Movable, T]): Mapping of Movables to target deltas\n group (Group | None, optional): The message group to associate with the\n setting, for sequencing. Defaults to None.\n\n Returns:\n MsgGenerator: Plan\n\n Yields:\n Iterator[MsgGenerator]: Bluesky messages\n ", + "schema": { "additionalProperties": false, "properties": { "moves": { @@ -1127,7 +1116,7 @@ { "name": "sleep", "description": "\n Suspend all action for a given time, wrapper for `bp.sleep`\n\n Args:\n time (float): Time to wait in seconds\n\n Returns:\n MsgGenerator: Plan\n\n Yields:\n Iterator[MsgGenerator]: Bluesky messages\n ", - "parameter_schema": { + "schema": { "additionalProperties": false, "properties": { "time": { @@ -1144,8 +1133,8 @@ }, { "name": "wait", - "description": "\n Wait for a group status to complete, wrapper for `bp.wait`\n\n Args:\n group (Optional[Group], optional): The name of the group to wait for, defaults\n to None.\n\n Returns:\n MsgGenerator: Plan\n\n Yields:\n Iterator[MsgGenerator]: Bluesky messages\n ", - "parameter_schema": { + "description": "\n Wait for a group status to complete, wrapper for `bp.wait`.\n Does not expose move_on, as when used as a stub will not fail on Timeout.\n\n Args:\n group (Group | None, optional): The name of the group to wait for, defaults\n to None, in which case waits for all\n groups that have not yet been awaited.\n timeout (float | None, default=None): a timeout in seconds\n\n\n Returns:\n MsgGenerator: Plan\n\n Yields:\n Iterator[MsgGenerator]: Bluesky messages\n ", + "schema": { "additionalProperties": false, "properties": { "group": { @@ -1158,6 +1147,17 @@ } ], "title": "Group" + }, + "timeout": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "null" + } + ], + "title": "Timeout" } }, "title": "wait", From ff4b683e7ecedc1971eb060707cf097105bbdf31 Mon Sep 17 00:00:00 2001 From: "Ware, Joseph (DLSLtd,RAL,LSCI)" Date: Thu, 14 Nov 2024 13:39:48 +0000 Subject: [PATCH 09/12] lint --- src/blueapi/startup/example_plans.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/blueapi/startup/example_plans.py b/src/blueapi/startup/example_plans.py index 5e119709b..2915707a5 100644 --- a/src/blueapi/startup/example_plans.py +++ b/src/blueapi/startup/example_plans.py @@ -1,7 +1,7 @@ from bluesky.protocols import Movable, Readable from dodal.common import inject -from dodal.plans import count from dodal.plan_stubs.wrapped import move +from dodal.plans import count from blueapi.core import MsgGenerator From 2050595d0633492c7523f06e76450eece3c20c06 Mon Sep 17 00:00:00 2001 From: "Ware, Joseph (DLSLtd,RAL,LSCI)" Date: Thu, 14 Nov 2024 13:42:13 +0000 Subject: [PATCH 10/12] post copier template event-model path --- docs/reference/asyncapi.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/reference/asyncapi.yaml b/docs/reference/asyncapi.yaml index 93bbb25db..96d314297 100644 --- a/docs/reference/asyncapi.yaml +++ b/docs/reference/asyncapi.yaml @@ -43,7 +43,7 @@ components: name: const: "start" doc: - $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.22.1/event_model/schemas/run_start.json" + $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.22.1/src/event_model/schemas/run_start.json" taggedStopDocument: messageId: runStop summary: Indicates the completion of a Bluesky run based on a previously specified Plan; describes end conditions and metadata @@ -55,7 +55,7 @@ components: name: const: "stop" doc: - $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.22.1/event_model/schemas/run_stop.json" + $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.22.1/src/event_model/schemas/run_stop.json" taggedDescriptorDocument: messageId: eventStreamDescriptor summary: Describes the devices to be within a scientifically related stream of measurements @@ -67,7 +67,7 @@ components: name: const: "descriptor" doc: - $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.22.1/event_model/schemas/event_descriptor.json" + $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.22.1/src/event_model/schemas/event_descriptor.json" taggedEventDocument: messageId: dataEvent summary: Describes a point measurement for a number of scientifically related devices @@ -79,7 +79,7 @@ components: name: const: "event" doc: - $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.22.1/event_model/schemas/event.json" + $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.22.1/src/event_model/schemas/event.json" taggedResourceDocument: messageId: resource summary: Describes an external resource (file, database entry etc.) that is to be referenced by later datum @@ -91,7 +91,7 @@ components: name: const: "resource" doc: - $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.22.1/event_model/schemas/resource.json" + $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.22.1/src/event_model/schemas/resource.json" taggedDatumDocument: messageId: datum summary: Describes how to access a point measurement within an external resource @@ -103,7 +103,7 @@ components: name: const: "datum" doc: - $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.22.1/event_model/schemas/datum.json" + $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.22.1/src/event_model/schemas/datum.json" taggedResourceStream: messageId: streamResource summary: Describes an external resource (file, database entry etc.) that is to be referenced by later Stream Datum @@ -115,7 +115,7 @@ components: name: const: "stream_resource" doc: - $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.22.1/event_model/schemas/stream_resource.json" + $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.22.1/src/event_model/schemas/stream_resource.json" taggedDatumStream: messageId: streamDatum summary: Describes how to access a slice of an external resource @@ -127,7 +127,7 @@ components: name: const: "stream_datum" doc: - $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.22.1/event_model/schemas/stream_datum.json" + $ref: "https://raw.githubusercontent.com/bluesky/event-model/refs/tags/v1.22.1/src/event_model/schemas/stream_datum.json" workerStateEvent: messageId: stateEvent headers: From 7fdae64086d215423a1a942c2ec006f2613646cb Mon Sep 17 00:00:00 2001 From: "Ware, Joseph (DLSLtd,RAL,LSCI)" Date: Thu, 14 Nov 2024 15:45:05 +0000 Subject: [PATCH 11/12] Adjust count params --- tests/unit_tests/worker/test_task_worker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit_tests/worker/test_task_worker.py b/tests/unit_tests/worker/test_task_worker.py index 1b42af09e..3801eb7a1 100644 --- a/tests/unit_tests/worker/test_task_worker.py +++ b/tests/unit_tests/worker/test_task_worker.py @@ -383,7 +383,7 @@ def assert_running_count_plan_produces_ordered_worker_and_data_events( task: Task | None = None, timeout: float = 5.0, ) -> None: - default_task = Task(name="count", params={"detectors": ["image_det"], "num": 1}) + default_task = Task(name="count", params={"detectors": {"image_det"}, "num": 1}) task = task or default_task event_streams: list[EventStream[Any, int]] = [ From 7063c1aad00838f754c4e40141c836c13dfd2171 Mon Sep 17 00:00:00 2001 From: "Ware, Joseph (DLSLtd,RAL,LSCI)" Date: Thu, 14 Nov 2024 16:28:32 +0000 Subject: [PATCH 12/12] Mock path provider for configured plan --- tests/unit_tests/worker/test_task_worker.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/unit_tests/worker/test_task_worker.py b/tests/unit_tests/worker/test_task_worker.py index 3801eb7a1..1eae7280c 100644 --- a/tests/unit_tests/worker/test_task_worker.py +++ b/tests/unit_tests/worker/test_task_worker.py @@ -2,11 +2,13 @@ import threading from collections.abc import Callable, Iterable from concurrent.futures import Future +from pathlib import Path from queue import Full from typing import Any, TypeVar from unittest.mock import ANY, MagicMock, patch import pytest +from dodal.common.types import UpdatingPathProvider from observability_utils.tracing import ( JsonObjectSpanExporter, asserting_span_exporter, @@ -341,7 +343,18 @@ def begin_task_and_wait_until_complete( # -def test_worker_and_data_events_produce_in_order(worker: TaskWorker) -> None: +@pytest.fixture +def path_provider(tmp_path: Path): + # Prevents issue with leftover state from beamline tests + with patch("dodal.plan_stubs.data_session.get_path_provider") as mock: + mock.return_value = MagicMock(spec=UpdatingPathProvider, return_value=tmp_path) + mock.return_value.data_session.return_value = "foo" + yield + + +def test_worker_and_data_events_produce_in_order( + worker: TaskWorker, path_provider +) -> None: assert_running_count_plan_produces_ordered_worker_and_data_events( [ WorkerEvent(