You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Make device_factory decorator to ease making and connecting ophyd-async Devices #483
#415 (comment) summarizes a discussion on Device connection. bluesky/ophyd-async#265 will implement the ophyd-async supporting features of idempotent connect. The strategy we would like for dodal is:
Each beamline module decorates its device factories with a device_factory
This factory makes, names, caches and optionally connects a device
In script use can pass connect=True to the device to connect in the foreground, requires a RunEngine to have been made
In blueapi use can find all the eager devices and connect them at startup
Can also connect them in a plan with the ensure_connected plan stub
This ticket is for:
New ADR
Describing how Devices should be connected in dodal, from scripts and under blueapi
Need to add type hints to this so it knows the type of device it is making from the function it is decorating and check with @callumforrester that get_device_factories is what blueapi actually needs
Acceptance Criteria
ADR written so we know why this was done
device_factory available to use in beamline modules
@coretl what is the role of keeping the lazy devices in a global dict? why is the key a complex object?
def get_device_factories() -> Dict[DeviceFactory, bool]: return _device_is_lazy.copy() @callumforrester how would blueapi use this? Maybe this should be stateful in some class, not a function in beamline_utils?
Activity
stan-dot commentedon Jun 6, 2024
so the idea is that all
device()...line ini22.pyor other beamline gets this decorator, right?coretl commentedon Jun 7, 2024
yes
stan-dot commentedon Jun 18, 2024
@coretl what is the role of keeping the lazy devices in a global dict? why is the key a complex object?
def get_device_factories() -> Dict[DeviceFactory, bool]: return _device_is_lazy.copy()@callumforrester how would blueapi use this? Maybe this should be stateful in some class, not a function in
beamline_utils?stan-dot commentedon Jun 18, 2024
there is loads of global state in there! very surprising.
stan-dot commentedon Jun 18, 2024
classes graph
stan-dot commentedon Jun 18, 2024
already_existing_device: AnyDevice | None = ACTIVE_DEVICES.get(name)this line in device_instantiation makes most of the difference
coretl commentedon Jun 18, 2024
As written in the original issue:
So it looks like this:
{device.connect() for device, lazy in get_device_factories().items() if not lazy}{device.connect() for device in whatever_function_you _use_to_inject_devices_in_plan_args}But this is all specified in DiamondLightSource/blueapi#440