Skip to content
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

BUG: preset formatting should be more error tolerant #1236

Open
tangkong opened this issue May 28, 2024 · 0 comments
Open

BUG: preset formatting should be more error tolerant #1236

tangkong opened this issue May 28, 2024 · 0 comments

Comments

@tangkong
Copy link
Contributor

Current Behavior

Preset position: {self.presets.state()}

this should refer to the "ERROR" preset and display the status instead of exploding

Also in this case the state repr fails:

In [2]: lib_y.presets.state()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Input In [2], in <cell line: 1>()
----> 1 lib_y.presets.state()

File /cds/group/pcds/pyps/apps/hutch-python/xcs/dev/devpath/pcdsdevices/interface.py:1301, in Presets.state(self)
   1299 state_name = method_name.replace('wm_', '', 1)
   1300 wm_state = getattr(device, method_name)
-> 1301 diff = abs(wm_state())
   1302 if diff < closest:
   1303     state = state_name

File /cds/group/pcds/pyps/apps/hutch-python/xcs/dev/devpath/pcdsdevices/interface.py:1263, in Presets._make_wm_pre.<locals>.wm_pre(self)
   1251 """
   1252 Check the offset from the {} preset position.
   1253
   (...)
   1259     is in the positive direction from us.
   1260 """
   1262 pos = self.presets._cache[preset_type][name]['value']
-> 1263 return pos - self.wm()

TypeError: unsupported operand type(s) for -: 'float' and 'NoneType'

Expected Behavior

Error presets don't crash everything

Context / environment

From debugging some issues in XCS

Steps to Reproduce (for bugs)

slack thread

  1. Initialize an IMS motor
  2. Somehow don't let its readback callback complete (such that self.position == None)
  3. motor.presets.state()

Suggested Solution

Fix it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant