Problem
Wire device metadata (in wire_metadata.yaml) stores associated devices as colon-delimited strings encoding two pieces of information — the device name and its area:
WS01:
detectors:
- PMTINJ03:DL1
- PMTINJ05:DL1
- PMT21350:LI21
default_detector: PMTINJ03:DL1
Every consumer of this metadata must manually split these strings to extract the device name and area:
slac_measurements/wires/collection.py:153-154
for ds in self.beam_profile_device.metadata.detectors:
name, area = ds.split(":")
detector = _instantiate_device(name, area)
slacwire/widgets/measurement.py:85-86
for detector_string in detectors:
detector, area = detector_string.split(":")
This pattern is repeated across at least 6 locations in slac-measurements and slacwire. It is error-prone, not self-documenting, and couples the metadata format to string parsing logic throughout the codebase.
Proposed Solution
Replace colon-delimited strings with bare device names and use Beampath.find_device() for resolution.
After the recent Beampath refactor, find_device(device_name) searches all areas and returns the area, device type, and device object making the area encoding in metadata redundant:
result = beampath.find_device("PMTINJ03")
# Returns: ("DL1", "pmts", <PMT object>)
The metadata would simplify to:
WS01:
detectors:
- PMTINJ03
- PMTINJ05
- PMT21350
default_detector: PMTINJ03
Consumer code becomes:
detectors = [
beampath.find_device(name)
for name in self.beam_profile_device.metadata.detectors
]
Benefits
- Eliminates repeated string-splitting logic across the codebase
- Single source of truth for device-to-area mapping (the Beampath object)
- Metadata becomes simpler and less brittle
- Device lookup is type-safe and returns a full device object rather than raw strings
Affected Files
slac-db/slac_db/package_data/wire_metadata.yaml — metadata source
slac-devices/slac_devices/wire.py — WireMetadata model (type annotations change from List[str] to device-name-only semantics)
slac-measurements/slac_measurements/wires/collection.py — primary consumer with multiple split sites
slacwire/slacwire/widgets/measurement.py — GUI consumer
slacwire/slacwire/ws_gui.py — GUI consumer
Problem
Wire device metadata (in
wire_metadata.yaml) stores associated devices as colon-delimited strings encoding two pieces of information — the device name and its area:Every consumer of this metadata must manually split these strings to extract the device name and area:
This pattern is repeated across at least 6 locations in
slac-measurementsandslacwire. It is error-prone, not self-documenting, and couples the metadata format to string parsing logic throughout the codebase.Proposed Solution
Replace colon-delimited strings with bare device names and use
Beampath.find_device()for resolution.After the recent Beampath refactor,
find_device(device_name)searches all areas and returns the area, device type, and device object making the area encoding in metadata redundant:The metadata would simplify to:
Consumer code becomes:
Benefits
Affected Files
slac-db/slac_db/package_data/wire_metadata.yaml— metadata sourceslac-devices/slac_devices/wire.py— WireMetadata model (type annotations change from List[str] to device-name-only semantics)slac-measurements/slac_measurements/wires/collection.py— primary consumer with multiple split sitesslacwire/slacwire/widgets/measurement.py— GUI consumerslacwire/slacwire/ws_gui.py— GUI consumer