7. Sub-package Structure#
Date: 2024-04-22
Status#
Accepted
Context#
4. Repository Structure proposed a top level repository structure. This builds upon it, suggesting a top level structure divided into:
ophyd_async.core
: Core classes likeDevice
,Signal
andAsyncStatus
ophyd_async.epics
: Epics specific signals and devicesophyd_async.tango
: Tango specific signals and devicesophyd_async.fastcs
: FastCS (EPICS or Tango) devices like PandAophyd_async.planstubs
: Plan stubs for various flyscan functionalityophyd_async.sim
: Simulated devices for demos and tests
This ADR proposes a public sub-package structure. The internal private structure should be flat, but can change according to the number of classes in a public package.
Decision#
core#
There will be a flat public namespace under core, with contents reimported from an underscore prefixed python files, e.g.:
_status.py
forAsyncStatus
,WatchableAsyncStatus
, etc._protocol.py
forAsyncReadable
,AsyncStageable
, etc._device.py
forDevice
,DeviceVector
, etc._signal.py
forSignal
,SignalBackend
,observe_signal
, etc._mock.py
forMockSignalBackend
,get_mock_put
, etc._readable.py
forStandardReadable
,ConfigSignal
,HintedSignal
, etc._detector.py
forStandardDetector
,DetectorWriter
,DetectorController
,TriggerInfo
, etc._flyer.py
forStandardFlyer
,FlyerControl
, etc.
There are some renames that will be required, e.g. HardwareTriggeredFlyable
-> StandardFlyer
epics#
Epics modules consist of 2 sorts of classes:
IO
classes, which areDevice
subclasses containingSignals
that map as closely as possible to the EPICS template hierarchy. Their name matches the EPICS template with the suffixIO
.Control
andWriter
classes that plug intoStandardDetector
andStandardFlyer
telling them which logic to use during various bluesky verbs.
There should be an additional level of packages that correspond to the epics support module, and contain classes that map to the EPICS database and logic classes e.g.:
epics.signal
: containingepics_signal_rw
,CaSignalBackend
, etc.epics.adcore
: containingADDriverIO
,NDFileHdfIO
,ADHdfWriter
etc.epics.adpilatus
: containingADPilatusIO
,PilatusControl
etc.
The name of the module is the EPICS module lowercased with dashes and other special characters converted to underscores.
They can be imported from modules:
from ophyd_async.epics import adcore, adpilatus
drv = adpilatus.ADPilatusIO(prefix + "DRV:")
hdf = adcore.NDFileHDFIO(prefix + "HDF:")
The structure is left to an individual module’s size. For instance motor
will probably be a single motor.py
, while ADCore
will likely be an ADCore/
directory with _io.py
, _writer.py
, _control.py
.
Detector modules should include a reference StandardDetector
subclass, but without making any site specific decisions about PV naming.
tango#
This has not been created at the time of writing, but it is envisioned that it will follow the EPICS structure where it makes sense.
fastcs#
There will be one subpackage for each FastCS Device. At the time of writing there are none of these, but PandA and Odin will shortly be converted to FastCS, so it makes sense to make:
fastcs.panda
fastcs.odin
in preparation.
For PandA its namespace should contain CommonPandaBlocks
, SeqBlock
, PandaHdfWriter
, PandaPcapController
, etc. These should be included in files like _control.py
, _writer.py
, _block.py
, _table.py
and imported into the panda
namespace.
planstubs#
There will be some planstubs for shared setup that may reach across modules like epics
and fastcs/panda
, these should live in a planstubs/
package.
sim#
There will be 2 subpackages:
sim.demo
for demo devices likePatternDetector
andSimMotor
used in tutorials.sim.testing
for devices that will support tests inophyd-async
andbluesky
. Some test fixtures could be moved here
There should probably be one file per Device, in an underscore prefixed file reimported into the public namespace, e.g. demo/_sim_motor.py
and demo/_pattern_detector.py
.
Consequences#
The public import paths are fixed, but the underlying implementation can move from modules to packages without change to the public interface.