DiamondLightSource / dodal

Ophyd devices and other utils that could be used across DLS beamlines
Apache License 2.0
2 stars 8 forks source link

Find a good way to keep beamline and simulator devices in step #6

Open DominicOram opened 2 years ago

DominicOram commented 2 years ago

As a developer/scientist I would like to make to make sure that the devices for the simulated beamline are kept the same as those for the real one, with as much ease as possible. Currently to add a new device to e.g. i03/s03 I need to add the following to i03.py:

BEAMLINE_PREFIX = "BL03I"

def device():
     return MyDevice(prefix=f"{BEAMLINE_PREFIX}-BLAH")

Then the following to s03.py:

BEAMLINE_PREFIX = "BL03S"

def device():
     return MyDevice(prefix=f"{BEAMLINE_PREFIX}-BLAH")

Which is an exact replica, except the BEAMLINE_PREFIX. Ideally I should just need to add to i03.py and s03.py will update itself.

DominicOram commented 2 years ago

Originally I had something like:

from dodal import i03
i03.BEAMLINE_PREFIX = "BL03S"
i03.INSERTION_PREFIX = "SR03S"

from dodal.i03 import *

in s03.py but this causes big issues if importing s03 and i03 together. Alternatives could be to change the structure of i03.py into a class?

DominicOram commented 2 years ago

We might also want a fake_i03 that has all the i03 devices but as ophyd fake devices

DominicOram commented 1 year ago

As discussed with @callumforrester we can just do this with an env variable. We can check BEAMLINE and use i03 if it is that, otherwise s03