Add Long name to OphydObj#1187
Conversation
|
Possibly one question to resolve in this PR is whether the long_name should be saved anywhere. Currently, it's not going to be read into Tiled at all when you read/describe an object. I think this is the desired behavior, we would just need to emphasize in the docs that long_name is for display only. |
|
My crystal ball tells me there will be a request to save |
|
So the next question becomes where and how Name is only saved implicitly, by being the key that is used to identify everything in the documents. I was going to go through the list of pros and cons of making a long_name ring_current = EpicsSignalRO(<prefix>, name="ring_current", long_name= "NSLS-II Ring Current (mA)")And it's clear here that the So in this framework, does anybody have any ideas for how we'd get the I suppose, if we wanted to be maximalist about things, I could modify In [11]: ring_current.describe()
Out[11]:
{'ring_current': {'source': 'PV:SIM_SST:current',
'long_name': 'NSLS-II Ring Current (mA)',
'dtype': 'number',
'shape': [],
'units': '',
'lower_ctrl_limit': 0.0,
'upper_ctrl_limit': 0.0,
'precision': 2}}This to me seems like a pretty major change, even though it's probably backwards compatible, and probably won't break anything (unless someone's iterating through describe in such a way that an unexpected key causes problems). It would be a large change in philosophy, in the sense that we are no longer pretending that all information is coming from EPICS records. |
Example of AttributeSignal that derives from not a Device: class_name = Cpt(
# fmt: off
AttributeSignal,
attr="__class__.__name__",
doc="Diffractometer class name",
write_access=False,
# fmt: on
) |
|
Sorry, I see your point now. The |
|
In that example, An |
|
Any thoughts on adding the new attribute to |
|
I think it's a good idea, conversation with @danielballan reminded me that |
|
@coretl You lost me with the reference to |
I'm agreeing that it can go under describe. The reference to which is defined here: So we should eventually add it as an optional entry there, so that downstream consumers know "if there is a field called long_name, this is what you can use it for" |
|
@coretl I understand now, thanks. Wasn't familiar with the EventModel terminology. I'm going to go ahead and add If anyone has a different opinion, I could add a check for the underlying |
|
There is a bit of a wrinkle now, in that the really aggressively signal-based nature of Ophyd comes back to bite us. If you gave you device as a whole a In [5]: tes.describe()
Out[5]:
OrderedDict([('tes_mca_counts',
{'source': 'PV:SIM_SST:tesmca:COUNTS',
'dtype': 'integer',
'shape': [],
'units': '',
'lower_ctrl_limit': 0,
'upper_ctrl_limit': 0}),
('tes_mca_spectrum',
{'source': 'PV:SIM_SST:tesmca:SPECTRUM',
'dtype': 'array',
'shape': [800],
'units': '',
'lower_ctrl_limit': 0,
'upper_ctrl_limit': 0})])
In [6]: tes.long_name
Out[6]: 'Microcalorimeter Detector'
In [7]: tes
Out[7]: EpicsMCABase(prefix='SIM_SST:tesmca:', name='tes_mca', read_attrs=['counts', 'spectrum'], configuration_attrs=['exposure_time', 'llim', 'ulim', 'nbins', 'energies'])This kind of cuts to the core of the Ophyd model (and, I would say, exposes some of the inadequacy in the model) where a |
|
@tacaswell any ideas? |
|
The major problem is actually this: If you're going to pass a Ophyd doesn't really have the concept of a "detector" structure that would have a primary "data" signal that the Now, I suppose I could modify all of my own detector classes to just pass the device |
|
I think Lines 252 to 274 in 5c03c3f long_name should be added there. It is not immediately clear to be what the "right" way to do this propagation is though.
Another option is to let https://github.com/bluesky/event-model/blob/fc6e30eae896073eda4013f7c4af3362fead61c1/event_model/documents/event_descriptor.py#L139-L147 The
Look at the extra work that is done in |
|
I didn't want |
|
One possible thing to do would be to propagate So then you could define |
|
Concatenating with It might also be worth coming up with someway to spell "the long_name was set correctly in the kwargs passed to |
|
@tacaswell I still don't quite get this, the verbs we support are |
|
Right, we can easily add Right now the |
|
Finally coming back to this, thinking about the propagation of long_name. I think if a Component's |
|
So, I have no idea why tests for python 3.9 immediately segfaulted, nor why python 3.10 was unable to even connect to github to check out the code, but I doubt it's anything I did, and I suspect that the tests would pass if re-run. Anybody up for a review? @coretl @tacaswell |
coretl
left a comment
There was a problem hiding this comment.
Looks reasonable to me, I guess we still need the corresponding event model and bluesky repo changes to make use of this?
|
This will end up in the |
For the Signals I can see that this ends up in the descriptor. But what about the Device? It has a long name, but no In the call yesterday we discussed adding extra metadata (like |
|
This PR does not resolve the issue of That could be @tacaswell 's suggestion of having a new top-level key in the Descriptors, or it could be some other place to stash the information, a special attribute signal that gets auto-created for Devices that holds |
…dded to test_device
…where it is now inherited from Signal due to upstream changes
|
Coming back to this I think at a minimum we need:
|
As discussed in #1161 this adds an attribute
long_nameto the base OphydObj, and also slightly modifies the Signal classes to passlong_namethrough.If
long_nameis not set, it will default to returningname, so that you can just use the attribute as a display label without worrying about whether or not it was set.long_namecan be passed into components. It is not concatenated with its parent device'slong_name, which I think would be undesirable behavior. It is something that should be very intentionally set to provide a self-contained descriptive label for whatever it is passed to.