Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
2a03b7d
Proof of concept device manager
tpoliaw Sep 17, 2025
ee86c74
Use fixtures parameter instead of **kwargs
tpoliaw Sep 18, 2025
658a45f
Expand dependencies
tpoliaw Sep 23, 2025
318593b
Pre-optional handling
tpoliaw Sep 25, 2025
d81502b
'Working' optional dependencies
tpoliaw Sep 25, 2025
123e96f
Docs, comments and warnings
tpoliaw Sep 25, 2025
15d4dc4
Check for positional only arguments
tpoliaw Sep 26, 2025
f3832d6
Handle connections and support new loader in cli
tpoliaw Sep 26, 2025
5fe05c7
Convert adsim to new loading
tpoliaw Sep 26, 2025
cbfa2f6
Add auto_connect to device manager
tpoliaw Sep 29, 2025
784856b
Remove references to connecting from device manager
tpoliaw Sep 30, 2025
5d8bfa5
DeviceResult wrappers
tpoliaw Sep 30, 2025
05ed69b
Demo adsim
tpoliaw Sep 30, 2025
62f41f7
build_and_connect method
tpoliaw Sep 30, 2025
37cdb9e
Multiple manager CLI
tpoliaw Sep 30, 2025
7f15f34
FIXTUEES
tpoliaw Sep 30, 2025
db69729
Use device decorator for timeouts
tpoliaw Oct 1, 2025
636ba06
Type build_and_connect and rely on fixtures for path provider
tpoliaw Oct 1, 2025
23d5c1e
mostly reformatting
tpoliaw Oct 1, 2025
ab2346b
Make fixture generators lazy
tpoliaw Oct 1, 2025
7635976
Apologise for build_order method
tpoliaw Oct 1, 2025
c7fcad1
Return function from fixture decorator
tpoliaw Oct 1, 2025
5e88698
Add timeout parameter to build_and_connect
tpoliaw Oct 1, 2025
7f0b927
Remove dead comment
tpoliaw Oct 1, 2025
922f0f5
Use set in expand_dependencies to prevent repetition
tpoliaw Oct 1, 2025
71d72cd
Check for duplicate factory names
tpoliaw Oct 2, 2025
13f0380
Add Ophyd v1 support
tpoliaw Oct 21, 2025
cbe6012
Connect Ophyd v1 devices
tpoliaw Oct 23, 2025
f7679eb
Move device_manager to new module
tpoliaw Oct 23, 2025
794067b
Remove test code from device_manager module
tpoliaw Oct 23, 2025
7a8afda
Remove debugging and commented code
tpoliaw Oct 23, 2025
10ee736
Merge connectionspec and connectionparameters
tpoliaw Oct 23, 2025
1e71b35
Add or_raise method to DeviceBuildResult
tpoliaw Oct 23, 2025
5cd9eef
Add docstrings
tpoliaw Oct 23, 2025
22d40fb
Use or_raise to handle build errors
tpoliaw Oct 23, 2025
04ff9cf
Only set device name if required
tpoliaw Oct 23, 2025
622cca5
Add TODOs to remove v1 support
tpoliaw Oct 23, 2025
75263da
Make v1 device timeout configurable
tpoliaw Oct 23, 2025
a033594
Default to waiting for v1 device connection
tpoliaw Oct 23, 2025
3837ca6
Add repr to v1 device factory
tpoliaw Oct 23, 2025
cd4b876
Split DeviceBuildResult devices and connection specs
tpoliaw Oct 24, 2025
ba075e1
Remove device_type property from factories
tpoliaw Oct 24, 2025
1612853
Include fixture overrides in built devices
tpoliaw Oct 24, 2025
79f8bdf
Fix duplication in factory repr
tpoliaw Oct 24, 2025
6a81076
Add initial device_manager tests
tpoliaw Oct 24, 2025
3175300
Revert adsim changes for now
tpoliaw Oct 27, 2025
15d7dc1
Enough tests to get full coverage
tpoliaw Oct 27, 2025
28724b4
Create DeviceManager in fixture
tpoliaw Oct 27, 2025
9434201
Add test for docstrings
tpoliaw Oct 28, 2025
fef6959
Reformat tests
tpoliaw Oct 28, 2025
3609a8f
Linting et al
tpoliaw Nov 12, 2025
14f96a3
Support single device manager name in CLI
tpoliaw Nov 12, 2025
e3ee340
Ignore mock type warnings
tpoliaw Nov 12, 2025
45716f2
Appease pre-commit lints
tpoliaw Nov 12, 2025
897d129
Add tests for device manager use in CLI
tpoliaw Nov 13, 2025
f136601
Make 'devices' default name for device manager in CLI
tpoliaw Nov 19, 2025
f33a7b5
Clean up TODO comments
tpoliaw Nov 19, 2025
caa6319
Set return_value when creating mocks
tpoliaw Nov 19, 2025
815bd47
Fix typing in v1_init decorator
tpoliaw Nov 21, 2025
9c22d22
Use ParamSpec when passing through __call__
tpoliaw Nov 21, 2025
820049d
Handle or ignore var args
tpoliaw Nov 21, 2025
f626761
Update tests
tpoliaw Nov 21, 2025
6afc663
Rename ignore skip test
tpoliaw Nov 21, 2025
4b19585
Simplify LazyFixture __getitem__
tpoliaw Nov 21, 2025
0487c9b
Used UserDict as base class for LazyFixtures
tpoliaw Nov 21, 2025
8adcc77
Merge branch 'main' into device_context
rtuck99 Nov 24, 2025
9af2428
Make pyright happy
rtuck99 Nov 24, 2025
e4740e6
Example conversion to the new device manager
tpoliaw Oct 30, 2025
62ed2da
Fix device heirachy
DominicOram Nov 18, 2025
613bb09
Fix some tests
DominicOram Nov 18, 2025
0c7d789
Ignore device_manager factories in utils
tpoliaw Nov 19, 2025
b9b096f
Fix test_device_instantiation
rtuck99 Nov 21, 2025
aa3882c
Update beamline howto docs
rtuck99 Nov 21, 2025
42e4d40
Merge branch 'main' into i03-device-manager
DominicOram Nov 27, 2025
c943f7a
Fix merge
DominicOram Nov 27, 2025
97189cb
Remove spurious comments
DominicOram Nov 27, 2025
fae9575
Merge branch 'main' into i03-device-manager
DominicOram Nov 27, 2025
c360687
Merge branch 'main' into i03-device-manager
rtuck99 Dec 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions docs/how-to/create-beamline.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,36 +23,39 @@ The following example creates a fictitious beamline ``w41``, with a simulated tw

```python

from functools import cache
from pathlib import Path
from ophyd_async.core import PathProvider
from ophyd_async.epics.adaravis import AravisDetector

from dodal.common.beamlines.beamline_utils import (
device_factory,
get_path_provider,
set_path_provider,
)
from dodal.common.beamlines.beamline_utils import set_beamline as set_utils_beamline
from dodal.common.beamlines.device_helpers import CAM_SUFFIX, HDF5_SUFFIX
from dodal.common.visit import LocalDirectoryServiceClient, StaticVisitPathProvider
from dodal.common.visit import RemoteDirectoryServiceClient, StaticVisitPathProvider
from dodal.device_manager import DeviceManager
from dodal.devices.synchrotron import Synchrotron
from dodal.log import set_beamline as set_log_beamline
from dodal.utils import BeamlinePrefix
from dodal.utils import BeamlinePrefix, get_beamline_name

BL = get_beamline_name("s41") # Default used when not on a live beamline
PREFIX = BeamlinePrefix(BL)
set_log_beamline(BL) # Configure logging and util functions
set_utils_beamline(BL)

# Currently we must hard-code the visit, determining the visit is WIP.
set_path_provider(
StaticVisitPathProvider(
devices = DeviceManager()

@devices.fixture
@cache
def path_provider() -> PathProvider:
# Currently we must hard-code the visit, determining the visit is WIP.
return StaticVisitPathProvider(
BL,
# Root directory for all detectors
Path("/dls/w41/data/YYYY/cm12345-1"),
# Uses an existing GDA server to ensure filename uniqueness
client=RemoteDirectoryServiceClient("http://s41-control:8088/api"),
# Else if no GDA server use a LocalDirectoryServiceClient(),
)
)


"""
Define device factory functions below this point.
Expand All @@ -63,23 +66,22 @@ The following example creates a fictitious beamline ``w41``, with a simulated tw
"""
This decorator gives extra desirable behaviour to this factory function:
- it may be instantiated automatically, selectively on live beamline
- caching and re-using the result for subsequent calls
- it automatically names the device if no name is explicitly set
- it may be skipped when make_all_devices is called on this module
- it must be explicitly connected (which may be automated by tools)
- when connected it may connect to a simulated backend
- it may be connected concurrently (when automated by tools)
""""
@device_factory(skip = BL == "s41")
"""
@devices.factory(skip = BL == "s41")
def synchrotron() -> Synchrotron:
return Synchrotron()


@device_factory()
def d11() -> AravisDetector:
@devices.factory()
def d11(path_provider: PathProvider) -> AravisDetector:
return AravisDetector(
f"{PREFIX.beamline_prefix}-DI-DCAM-01:",
path_provider=get_path_provider(),
path_provider=path_provider,
drv_suffix=CAM_SUFFIX,
fileio_suffix=HDF5_SUFFIX,
)
Expand Down
Loading