-
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
Add long names #627
Add long names #627
Changes from all commits
5b94a78
4a9c69d
03d69aa
c17aa28
3f0df86
a47a751
63832eb
9024491
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
627 Add long_name for SignalPanel | ||
################# | ||
|
||
API Breaks | ||
---------- | ||
- N/A | ||
|
||
Features | ||
-------- | ||
- Add `long_name` support for `device.signal` or `device.component.signal` that replace `label_text` for rows in `SignalPanel` | ||
|
||
Bugfixes | ||
-------- | ||
- N/A | ||
|
||
Maintenance | ||
----------- | ||
- N/A | ||
|
||
Contributors | ||
------------ | ||
- aberges-SLAC |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -235,16 +235,65 @@ def _got_signal_widget_info(self, obj, info): | |||||||||||||||||||||||||||||||||||||||||
for _, sig_info in signal_pairs): | ||||||||||||||||||||||||||||||||||||||||||
self.loading_complete.emit([name for name, _ in signal_pairs]) | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
def _create_row_label(self, attr, dotted_name, tooltip): | ||||||||||||||||||||||||||||||||||||||||||
"""Create a row label (i.e., the one used to display the name).""" | ||||||||||||||||||||||||||||||||||||||||||
label_text = self.label_text_from_attribute(attr, dotted_name) | ||||||||||||||||||||||||||||||||||||||||||
def _create_row_label(self, attr, dotted_name, tooltip, long_name=None): | ||||||||||||||||||||||||||||||||||||||||||
""" | ||||||||||||||||||||||||||||||||||||||||||
Create a row label (i.e., the one used to display the name). | ||||||||||||||||||||||||||||||||||||||||||
If an alternative (human-readable) long name is defined, use that instead | ||||||||||||||||||||||||||||||||||||||||||
and add the dotted_name to the tooltip for hutch python ease of use. | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
Parameters | ||||||||||||||||||||||||||||||||||||||||||
----------- | ||||||||||||||||||||||||||||||||||||||||||
attr: any | ||||||||||||||||||||||||||||||||||||||||||
Name of the signal | ||||||||||||||||||||||||||||||||||||||||||
dotted_name: any | ||||||||||||||||||||||||||||||||||||||||||
Full dotted name of the signal | ||||||||||||||||||||||||||||||||||||||||||
tooltip: str | ||||||||||||||||||||||||||||||||||||||||||
Doc string to add to signal | ||||||||||||||||||||||||||||||||||||||||||
long_name: str, optional | ||||||||||||||||||||||||||||||||||||||||||
Long form (human readable) name to use for the signal row label text. | ||||||||||||||||||||||||||||||||||||||||||
""" | ||||||||||||||||||||||||||||||||||||||||||
if long_name: | ||||||||||||||||||||||||||||||||||||||||||
label_text = long_name | ||||||||||||||||||||||||||||||||||||||||||
else: | ||||||||||||||||||||||||||||||||||||||||||
label_text = self.label_text_from_attribute(attr, dotted_name) | ||||||||||||||||||||||||||||||||||||||||||
label = SignalPanelRowLabel(label_text) | ||||||||||||||||||||||||||||||||||||||||||
label.setObjectName(dotted_name) | ||||||||||||||||||||||||||||||||||||||||||
if tooltip is not None: | ||||||||||||||||||||||||||||||||||||||||||
label.setToolTip(tooltip) | ||||||||||||||||||||||||||||||||||||||||||
if long_name: | ||||||||||||||||||||||||||||||||||||||||||
_tooltip = dotted_name + '<br>' + round(1.75*len(dotted_name))*'-' + '<br>' + tooltip | ||||||||||||||||||||||||||||||||||||||||||
else: | ||||||||||||||||||||||||||||||||||||||||||
_tooltip = tooltip | ||||||||||||||||||||||||||||||||||||||||||
label.setToolTip(_tooltip) | ||||||||||||||||||||||||||||||||||||||||||
return label | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
def add_signal(self, signal, name=None, *, tooltip=None): | ||||||||||||||||||||||||||||||||||||||||||
def _get_long_name(self, device, attr, dotted_name): | ||||||||||||||||||||||||||||||||||||||||||
""" | ||||||||||||||||||||||||||||||||||||||||||
Check the signal for its long_name, if it exists. | ||||||||||||||||||||||||||||||||||||||||||
Until Ophyd makes it a standard signal, need to manually check | ||||||||||||||||||||||||||||||||||||||||||
the device and its components for the name. | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
Parameters | ||||||||||||||||||||||||||||||||||||||||||
----------- | ||||||||||||||||||||||||||||||||||||||||||
device: (any) | ||||||||||||||||||||||||||||||||||||||||||
The Ophyd.Device with component signals | ||||||||||||||||||||||||||||||||||||||||||
attr: (str) | ||||||||||||||||||||||||||||||||||||||||||
The str name of the signal attribute | ||||||||||||||||||||||||||||||||||||||||||
dotted_name: (str) | ||||||||||||||||||||||||||||||||||||||||||
The full dotted name to the signal | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
Returns | ||||||||||||||||||||||||||||||||||||||||||
-------- | ||||||||||||||||||||||||||||||||||||||||||
str or None | ||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+277
to
+286
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Super petty spacing nitpick to match the other docstrings
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this ever got committed 👀 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. whoops There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't even remember getting this message on the commit o.O |
||||||||||||||||||||||||||||||||||||||||||
""" | ||||||||||||||||||||||||||||||||||||||||||
try: | ||||||||||||||||||||||||||||||||||||||||||
if hasattr(getattr(device, attr), 'long_name'): | ||||||||||||||||||||||||||||||||||||||||||
return getattr(device, attr).long_name | ||||||||||||||||||||||||||||||||||||||||||
except AttributeError: | ||||||||||||||||||||||||||||||||||||||||||
# Then maybe we have a nested component and can't touch the signal | ||||||||||||||||||||||||||||||||||||||||||
if hasattr(getattr(device, dotted_name), 'long_name'): | ||||||||||||||||||||||||||||||||||||||||||
return getattr(device, dotted_name).long_name | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
def add_signal(self, signal, name=None, long_name=None, *, tooltip=None): | ||||||||||||||||||||||||||||||||||||||||||
""" | ||||||||||||||||||||||||||||||||||||||||||
Add a signal to the panel. | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
|
@@ -277,7 +326,7 @@ def add_signal(self, signal, name=None, *, tooltip=None): | |||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
logger.debug("Adding signal %s (%s)", signal.name, name) | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
label = self._create_row_label(name, name, tooltip) | ||||||||||||||||||||||||||||||||||||||||||
label = self._create_row_label(attr=name, dotted_name=name, long_name=long_name, tooltip=tooltip) | ||||||||||||||||||||||||||||||||||||||||||
loading = utils.TyphosLoading( | ||||||||||||||||||||||||||||||||||||||||||
timeout_message='Connection timed out.' | ||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||
|
@@ -332,8 +381,11 @@ def _add_component(self, device, attr, dotted_name, component): | |||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
logger.debug("Adding component %s", dotted_name) | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
# Workaround until Ophyd.Component.long_name PR comes through | ||||||||||||||||||||||||||||||||||||||||||
long_name = self._get_long_name(device, attr, dotted_name) | ||||||||||||||||||||||||||||||||||||||||||
label = self._create_row_label( | ||||||||||||||||||||||||||||||||||||||||||
attr, dotted_name, tooltip=component.doc or '') | ||||||||||||||||||||||||||||||||||||||||||
attr=attr, dotted_name=dotted_name, long_name=long_name, | ||||||||||||||||||||||||||||||||||||||||||
tooltip=component.doc or '') | ||||||||||||||||||||||||||||||||||||||||||
row = self.add_row(label, None) # utils.TyphosLoading()) | ||||||||||||||||||||||||||||||||||||||||||
self.signal_name_to_info[dotted_name] = dict( | ||||||||||||||||||||||||||||||||||||||||||
row=row, | ||||||||||||||||||||||||||||||||||||||||||
|
@@ -662,8 +714,10 @@ def _maybe_add_signal(self, device, attr, dotted_name, component): | |||||||||||||||||||||||||||||||||||||||||
logger.warning('Failed to get signal %r from device %s: %s', | ||||||||||||||||||||||||||||||||||||||||||
dotted_name, device.name, ex, exc_info=True) | ||||||||||||||||||||||||||||||||||||||||||
return | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
return self.add_signal(signal, name=attr, tooltip=component.doc) | ||||||||||||||||||||||||||||||||||||||||||
# Workaround until Ophyd.Component.long_name PR comes through | ||||||||||||||||||||||||||||||||||||||||||
long_name = self._get_long_name(device, attr, dotted_name) | ||||||||||||||||||||||||||||||||||||||||||
return self.add_signal(signal=signal, name=attr, long_name=long_name, | ||||||||||||||||||||||||||||||||||||||||||
tooltip=component.doc) | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
return self._add_component(device, attr, dotted_name, component) | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing here is the pre-release notes docs step, same as how we've done it in pcdsdevices with pre-release-notes.sh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah derp forgot to commit that, let me fix that after above changes