Skip to content

Allow HasName to be used with DeviceManager #1997

Description

@oliwenmandiamond

In #1798 and through out other beamlines, we have a mix of global state and dependency injection being used for the daq config server config client. The global state is used because in MX, they need access to the config server inside plans independent of devices. DeviceManager and BlueAPI currently only supports the concept of a Device from ophyd-async.

Instead, I'm proposing broadening this restriction to include the Bluesky protocol HasName inside DeviceManager (V2 = TypeVar("V2", bound=OphydV2Device | HasName)) (will also need BlueAPI to support DiamondLightSource/blueapi#1462) so we can make still make a clear distinction between what is a Device and what isn't while also making other objects findable and therefore injectable inside plans and can remove the use of troublesome global states.

For example:

class InjectableConfigClient(HasName):
    def __init__(self, url: str, name):
        self.client = ConfigClient(url)
        self._name = name

    @property
    def name(self) -> str:
        return self._name
...

devices = DeviceManager()

@devices.factory()
def config_client() -> InjectableConfigClient:
    return InjectableConfigClient("https://daq-config.diamond.ac.uk", "config_client")

Then in a plan repository, we can then do this for example

@plan
def my_plan(config_client: InjectableConfigClient = inject("config_client")) -> MsgGenerator:
     config_client.client.reset_cache()

This will make plans working with BlueAPI much more flexible.

One thing is that isn't really as much of DeviceManager with this change and I would argue more of BeamlineManager (maybe rename...?)

Activity

  1. added
    enhancement
    on Mar 30, 2026
  2. changed the title [-]Allow more than just Devices to be discoverable for BlueAPI[/-] [+]Allow HasName to be used with DeviceManager[/+] on Mar 30, 2026
  3. tpoliaw commented on Mar 31, 2026

    @tpoliaw
    Contributor

    The main issue I can see with this is that the DeviceManager also runs a load of logic around connecting devices which clearly won't be supported by a HasName type.

    I can see the benefit of having non-devices be available though so will have a think about how to support it. Maybe via a separate environment_context list or similar. Maybe renaming/aliasing fixtures and making them available to blueapi?

  4. oliwenmandiamond commented on Mar 31, 2026

    @oliwenmandiamond
    ContributorAuthor

    Yes I think making fixtures available via BlueAPI would be good idea! Then we can just use the fixture name as the name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions