-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document why we choose to do Device load/save in the plan rather than in the Device #737
Comments
Thanks, @coretl I can see the value in that. The first point doesn't apply to us, but doesn't hurt either.
I think this is the challenge I'm facing. Seems like doing this in the queueserver means that I couldn't use area detectors without a queueserver, or else we have to "just know" that this plan needs to be run when operating directly in an ipython terminal. I asked some of my group members to work through these steps for usability testing, and it was awkward enough that I want to automate executing the Maybe I want a wrapper that looks for devices (in the stage message?) that have a Maybe there are reasons to set ndattributes both in the device class, and as a plan, depending on the situation. |
I realize that det_hdf_and_stats = settings_from_yaml(det, "/path/to/det_hdf_and_stats.yaml")
def setup_my_det_plan():
settings = (
det_hdf_and_stats
| ndstats_sum_settings(det.stats)
)
yield from apply_settings_if_different(settings, apply_areadetector_settings) However, I realize that getting people to remember to run this when they start using bluesky is a bit of an ask, especially if you haven't got queueserver on top. I wonder whether we can have 2 options:
I'll try and think of a neat way to do the second while still using the Settings objects created from the plans... |
Can't you have it both ways? Write as a plan stub and also call it as the session starts ( We're starting to adopt a philosophy of everything is a plan (or plan stub) so users see one, clear way to write their code. (Previously, when we also showed how to create ophyd-style code for command-line use, this proved confusing to all but our expert users.) This philosophy enables easier use of queueserver as an option. |
The example above shows device creation. It could be extended to include setup plan stubs. |
I think the core issue I'm facing is that I don't want to lock-in the names of data keys that end up in the catalog based on a device name at startup, because starting a second instance of python that runs this startup code but with a different device name will clobber the PVs set by the first instance. APS 25-ID has 3 hutches that can run simultaneously, and detectors that may move between them making this a real possibility. But maybe my use case is not incompatible with doing this all at startup. ADHDFWriter.open() creates an HDFDataset for each attribute, and it currently uses the XML attribute name for both the data_key and dataset attributes. To avoid naming collisions in case there are two detectors in one scan and to ensure the dataset names in tiled are clear, I'm setting these NDAttribute names to be Instead, if I could create HDFDataset(
data_key=f"{name}-{datakey}",
dataset=f"/entry/instrument/NDAttributes/{datakey}",
...
) I think this would give equivalent results in the case of a single python session, and would produce the expected catalog columns in the case of two sessions with the same detector but named differently between the them. One difference would be that the HDF5 datasets produced by the detector don't contain the detector name, but I don't see that being an issue as long as tiled knows where they are. The way it's written now, I would need to vendor the entire If it's not reasonable to change this as the default behavior, could the creation of the Or maybe there's a reason this won't work that I haven't thought of. I'll test this and see. |
We need to support the ability to not have Would that work? The only thing that I'm not sure about is whether areaDetector allows attribute names with |
Yes, I think this would work! I tested this on our Xspress IOC. I added a bunch of params like: NDAttributeParam(name='{name}-element0-deadtime_factor', param='XSP3_CHAN_DTFACTOR', datatype=<NDAttributeDataType.DOUBLE: 'DOUBLE'>, addr=0, description='Chan 0 DTC Factor') This produces valid XML, and if I set the NDAttributesFile PV and trigger the detector, I get datasets like If I then make the change to suggested to the |
From @canismarko
Answer:
There are a few reasons we went for setup in plans rather than in the Device, all of them are judgement calls and not particularly clear cut:
The downside of putting it in the plan is working out when to call it. Is this something we could push to queueserver? When it goes from user-controlled to consuming from the queue it runs a "get my beamline into a good state" plan?
@prjemian may have some thoughts on this too
Acceptance Criteria
The text was updated successfully, but these errors were encountered: