aps-8id-dys / bluesky

XPCS bluesky instrument configuration
Other
2 stars 0 forks source link

ophyd name kwarg values should be valid python object names #67

Closed prjemian closed 1 week ago

prjemian commented 2 weeks ago

The name="VALUE" kwarg should be a valid Python name.

Names such as these should be changed: https://github.com/aps-8id-dys/bluesky/blob/7ccd08c563eabc008954e55a2de48c468d7ff52a/src/instrument/devices/slit.py#L43-L47

While this is a naming convention that is not checked by the ophyd code, the names are used later to retrieve and reference data from the databroker or tiled. Names which are not suitable as Python object names are problematic to the end users.

This regular expression (derived from NeXus) is a good test for names: ^[a-zA-Z_]([a-zA-Z0-9_]*)?$

It has been recommended that the name match the Python object name unless a compelling reason suggestion otherwise.

prjemian commented 2 weeks ago

Here's a test of that regexp:

image

prjemian commented 2 weeks ago

Here's the list from the current main branch:

(base) 8idiuser@agate ~/bluesky $ git grep name= | grep \-
src/instrument/devices/bd_5a.py:    name="bd-5a", prefix="8iddSoft:CR8-D1:US", h_base_motor="m9", v_base_motor="m10"
src/instrument/devices/damm.py:damm = Damm(name="damm", prefix="8iddSoft:CR8-D1:US", x_motor="m2", y_motor="m3")
src/instrument/devices/fl.py:fl2 = EpicsMotor("8ideSoft:CR8-E2:m7", name="fl2")
src/instrument/devices/fl.py:fl3 = EpicsMotor("8idiSoft:CR8-I2:m7", name="fl3")
src/instrument/devices/flag_4.py:flag4 = EpicsMotor("8iddSoft:CR8-D1:m1", name="flag_4")
src/instrument/devices/slit.py:sl4 = ID8Optics2Slit2D_HV("8iddSoft:Slit1", name="sl-4")
src/instrument/devices/slit.py:sl5 = ID8Optics2Slit2D_HV("8ideSoft:Slit1", name="sl-5")
src/instrument/devices/slit.py:sl7 = ID8Optics2Slit2D_HV("8ideSoft:Slit2", name="sl-7")
src/instrument/devices/slit.py:sl8 = ID8Optics2Slit2D_HV("8idiSoft:Slit1", name="sl-8")
src/instrument/devices/slit.py:sl9 = ID8Optics2Slit2D_HV("8idiSoft:Slit2", name="sl-9")
src/instrument/devices/slit_base.py:    name="SL 4 Base", prefix="8iddSoft:CR8-D1:US", h_motor="m15", v_motor="m16"
src/instrument/devices/slit_base.py:    name="SL 5 Base", prefix="8ideSoft:CR8-E2:US", h_motor="m5", v_motor="m6"
src/instrument/devices/slit_base.py:    name="SL 7 Base", prefix="8ideSoft:CR8-E2:US", h_motor="m15", v_motor="m16"
src/instrument/devices/slit_base.py:    name="SL 8 Base", prefix="8idiSoft:CR8-I2:US", h_motor="m5", v_motor="m6"
src/instrument/devices/slit_base.py:    name="SL 9 Base", prefix="8idiSoft:CR8-I2:US", h_motor="m15", v_motor="m16"

The damm, fl2, fl3, & flag4 objects are ok, their PVs have the only -. The other should be changed.

Consider making the fl2, fl3, & flag4 names more consistent.

prjemian commented 2 weeks ago

Note the names in slit_base.py should be changed since they have embedded spaces.