spc-group / haven

Bluesky tools for beamlines managed by the spectroscopy group
https://haven-spc.readthedocs.io/en/latest/
Other
2 stars 6 forks source link

Allow device names with spaces to be sent to the queueserver #202

Open canismarko opened 5 months ago

canismarko commented 5 months ago

Message sent on Mattermost:

I'm trying to use procedurally generated devices with the queueserver, but it doesn't work if the device.name has spaces in it. E.g.

In my --startup-script, I have something like the following. devices is a list of devices generated from a config file, and the names are read from PVs so could sometimes have spaces.

for obj in devices:
    globals()[obj.name] = obj

This works fine, unless obj.name contains spaces, then it just pasess the string as is to the plan, and the plan doesn't work.

I get this is a weird use case. I could modify the bit that builds devices to strip out the spaces. Figured I'd see if there's an easy way to get queueserver to okay with the spaces, though.

canismarko commented 5 months ago

One idea is that plan annotations might provide this functionality. By explicitly declaring device types (either DEVICE or bluesky.protocols.Readable, etc) we might be able to coerce the queueserver into resolving these names despite the spaces.

canismarko commented 5 months ago

I'm going to wait until https://github.com/spc-group/haven/pull/198 is closed before working on this.

canismarko commented 5 months ago

This function might be useful here as well.

https://github.com/BCDA-APS/apstools/blob/ece96632cb919c34c18bc200645189a5632fa576/apstools/utils/misc.py#L386

Thanks to @prjemian for the suggestion.

canismarko commented 5 months ago

Tested plan annotations. They don't solve this "spaces in the device name" problem.

For now I've implemented a workaround where all the device names that are generated dynamically (e.g. ion chambers, motors) are sanitized first.

Should be good enough for now, but we should also avoid spaces in hardware descriptions in general.