DiamondLightSource / DiamondLightSource/dodal
Add an optional profiles argument for @devices.factory()
- Dominant language
- Python
- Stars
- 5
- Forks
- 13
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 10
Description
For I07, they have two end stations, eh1 and eh2. They can only have one experiment at a time.
If it's in eh1 it will use everything in eh1 only.
If it's in eh2 it will use everything in eh1 except the diffractometer and detectors and everything in eh2.
If there is an experiment in eh1 they may do commissioning in eh2 at the same time so would require only things in eh2.
So there are three cases:
- ["common", "eh1"]
- ["common", "eh2"]
- ["eh2"]
As of current, we have` DeviceManager.include(shared_devices)` for compulsory shared components between endstations of beamlines. However, we don't take into account any hardware which is optional. I think a solution to this is allow devices to have an optional argument for a profile when using factory. Then when using from BlueAPI end, you can select which profiles you want to load from DeviceManager.
E.g dodal side for a beamline:
```Python
devices = DeviceManager()
@devices.factory(profile="eh1")
def device1() -> Device:
return Device()
@devices.factory(profile="eh2")
def device2() -> Device:
return Device()
# Default is profile="common"
@devices.factory()
def common_device() -> Device:
return Device()
```
Then with `DeviceManager` when it comes to loading the devices from BlueAPI, we have the following options to load in with the specific group of devices we need:
EH1
```Python
devices.build_and_connect(profiles = ["eh1", "common"])
```
EH2
```Python
devices.build_and_connect(profiles = ["eh2", "common"])
```
EH2 commissioning only
```python
devices.build_and_connect(profiles = ["eh2"])
```
If beamlines are not interested in this feature, they can ignore it as the default will be `profiles = ["common"] ` so nothing changes for them as it will load in all devices.
Contributor guide
Assessment
This issue has not been assessed yet.