Skip to content

Commit

Permalink
Move DataManagement and Preprocessors to Dodal
Browse files Browse the repository at this point in the history
  • Loading branch information
DiamondJoseph committed Apr 24, 2024
1 parent 4d52871 commit 950d315
Show file tree
Hide file tree
Showing 9 changed files with 1 addition and 693 deletions.
7 changes: 0 additions & 7 deletions src/blueapi/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,6 @@ class StompConfig(BaseModel):
auth: BasicAuthentication | None = None


class DataWritingConfig(BlueapiBaseModel):
visit_service_url: str | None = None # e.g. "http://localhost:8088/api"
visit_directory: Path = Path("/tmp/0-0")
group_name: str = "example"


class WorkerEventConfig(BlueapiBaseModel):
"""
Config for event broadcasting via the message bus
Expand All @@ -78,7 +72,6 @@ class EnvironmentConfig(BlueapiBaseModel):
Source(kind=SourceKind.PLAN_FUNCTIONS, module="dls_bluesky_core.plans"),
Source(kind=SourceKind.PLAN_FUNCTIONS, module="dls_bluesky_core.stubs"),
]
data_writing: DataWritingConfig = Field(default_factory=DataWritingConfig)
events: WorkerEventConfig = Field(default_factory=WorkerEventConfig)


Expand Down
14 changes: 1 addition & 13 deletions src/blueapi/core/context.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import functools
import logging
from collections.abc import Callable, Sequence
from collections.abc import Callable
from dataclasses import dataclass, field
from importlib import import_module
from inspect import Parameter, signature
Expand Down Expand Up @@ -29,10 +28,8 @@
BLUESKY_PROTOCOLS,
Device,
HasName,
MsgGenerator,
Plan,
PlanGenerator,
PlanWrapper,
is_bluesky_compatible_device,
is_bluesky_plan_generator,
)
Expand All @@ -52,22 +49,13 @@ class BlueskyContext:
run_engine: RunEngine = field(
default_factory=lambda: RunEngine(context_managers=[])
)
plan_wrappers: Sequence[PlanWrapper] = field(default_factory=list)
plans: dict[str, Plan] = field(default_factory=dict)
devices: dict[str, Device] = field(default_factory=dict)
plan_functions: dict[str, PlanGenerator] = field(default_factory=dict)
sim: bool = field(default=False)

_reference_cache: dict[type, type] = field(default_factory=dict)

def wrap(self, plan: MsgGenerator) -> MsgGenerator:
wrapped_plan = functools.reduce(
lambda wrapped, next_wrapper: next_wrapper(wrapped),
self.plan_wrappers,
plan,
)
yield from wrapped_plan

def find_device(self, addr: str | list[str]) -> Device | None:
"""
Find a device in this context, allows for recursive search.
Expand Down
Empty file.
127 changes: 0 additions & 127 deletions src/blueapi/data_management/visit_directory_provider.py

This file was deleted.

41 changes: 0 additions & 41 deletions src/blueapi/preprocessors/attach_metadata.py

This file was deleted.

40 changes: 0 additions & 40 deletions src/blueapi/service/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,8 @@
from blueapi.config import ApplicationConfig
from blueapi.core import BlueskyContext
from blueapi.core.event import EventStream
from blueapi.data_management.visit_directory_provider import (
LocalVisitServiceClient,
VisitDirectoryProvider,
VisitServiceClient,
VisitServiceClientBase,
)
from blueapi.messaging import StompMessagingTemplate
from blueapi.messaging.base import MessagingTemplate
from blueapi.preprocessors.attach_metadata import attach_metadata
from blueapi.service.handler_base import BlueskyHandler
from blueapi.service.model import DeviceModel, PlanModel, WorkerTask
from blueapi.worker.event import WorkerState
Expand Down Expand Up @@ -150,42 +143,9 @@ def setup_handler(
) -> None:
global HANDLER

provider = None
plan_wrappers = []
if config:
visit_service_client: VisitServiceClientBase
if config.env.data_writing.visit_service_url is not None:
visit_service_client = VisitServiceClient(
config.env.data_writing.visit_service_url
)
else:
visit_service_client = LocalVisitServiceClient()

provider = VisitDirectoryProvider(
data_group_name=config.env.data_writing.group_name,
data_directory=config.env.data_writing.visit_directory,
client=visit_service_client,
)

# Make all dodal devices created by the context use provider if they can
try:
from dodal.parameters.gda_directory_provider import (
set_directory_provider_singleton,
)

set_directory_provider_singleton(provider)
except ImportError:
logging.error(
"Unable to set directory provider for ophyd-async devices, "
"a newer version of dodal is required"
)

plan_wrappers.append(lambda plan: attach_metadata(plan, provider))

handler = Handler(
config,
context=BlueskyContext(
plan_wrappers=plan_wrappers,
sim=False,
),
)
Expand Down
66 changes: 0 additions & 66 deletions tests/data_management/test_visit_directory_provider.py

This file was deleted.

Empty file removed tests/preprocessors/__init__.py
Empty file.
Loading

0 comments on commit 950d315

Please sign in to comment.