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

ENH: for LCLS-I att, give proper error for uninterruptable move #1183

Merged
merged 4 commits into from
Nov 10, 2023

Conversation

ZLLentz
Copy link
Member

@ZLLentz ZLLentz commented Nov 10, 2023

Description

  • Adds PVPositionerNoInterrupt: a utility class for PV positioners that cannot start a new move until the previous move completes.
  • Applies PVPositionerNoInterrupt to AttBase to gain this behavior for LCLS-I style attenuators.

Motivation and Context

For the LCLSI attenuators, if you try to start a new move during the previous move, you get a confusing and useless error. This new error makes it very clear that cannot do this.

As implemented, the IOC will not consider new move requests during the previous move, so nothing of value is lost here.

https://jira.slac.stanford.edu/browse/ECS-4099

How Has This Been Tested?

  • Added a few unit tests
  • Interactively checked the error message via the testclass
In [1]: from pcdsdevices.tests.test_pv_positioner import PVPositionerNoInterruptLocal

In [2]: loc = PVPositionerNoInterruptLocal(name='loc')

In [3]: loc.done.put(0)

In [4]: loc.move(100, wait=False)
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Input In [4], in <cell line: 1>()
----> 1 loc.move(100, wait=False)

File ~/github/pcdsdevices/pcdsdevices/pv_positioner.py:230, in PVPositionerNoInterrupt.move(self, position, wait, timeout, moved_cb)
    228     except Exception:
    229         progress = ""
--> 230     raise RuntimeError(
    231         f"The {self.name} device cannot start a new move because the "
    232         "previous move has not completed. This is not an "
    233         "interruptable positioner. Try waiting after the previous "
    234         f"move or for the move's status to complete. {progress}"
    235     )
    236 else:
    237     return super().move(position, wait=wait, timeout=timeout, moved_cb=moved_cb)

RuntimeError: The loc device cannot start a new move because the previous move has not completed. This is not an interruptable positioner. Try waiting after the previous move or for the move's status to complete. Position = None, goal = 0.0.
  • It would be a good idea to try this in XPP if/when it is possible

Where Has This Been Documented?

pre-release notes and the aforementioned Jira ticket only

Pre-merge checklist

  • Code works interactively
  • Code contains descriptive docstrings, including context and API
  • New/changed functions and methods are covered in the test suite where possible
  • Test suite passes locally
  • Test suite passes on GitHub Actions
  • Ran docs/pre-release-notes.sh and created a pre-release documentation page
  • Pre-release docs include context, functional descriptions, and contributors as appropriate

@ZLLentz ZLLentz marked this pull request as ready for review November 10, 2023 00:15
klauer
klauer previously approved these changes Nov 10, 2023
Copy link
Contributor

@klauer klauer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

-------
status : MoveStatus
"""
if self.moving:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"previous move has not completed. This is not an "
"interruptable positioner. Try waiting after the previous "
f"move or for the move's status to complete. {progress}"
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the addition of "progress" here

I understand what the error message means - and it's likely clear enough for the end user as well. 👍

tangkong
tangkong previously approved these changes Nov 10, 2023
Copy link
Contributor

@tangkong tangkong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it, nice and simple. I was thinking we could also guard against puts to the PVs themselves, but maybe that's too far? (if a user is reaching to the setpoint directly, can they truly be stopped?)

pcdsdevices/pv_positioner.py Show resolved Hide resolved
@ZLLentz ZLLentz dismissed stale reviews from tangkong and klauer via c0b4fbf November 10, 2023 19:15
Copy link
Contributor

@klauer klauer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional docstring 👍

Copy link
Contributor

@vespos vespos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this addresses the original issue, while also making it transparent to the end user. We can test this implementation at XPP pretty much anytime until Wed 11/15.

@ZLLentz
Copy link
Member Author

ZLLentz commented Nov 10, 2023

This has the desired behavior in practice, with one caveat: it's possible to get into a state where moving=False and there is still a lingering MoveStatus that isn't complete. There's some race conditions for the case where you start a new move immediately after the previous move is complete. The IOC will lock up in this case as well, but here's my testing log that sort of shows what the python side does:

(pcds-5.8.0)zlentz@xpp-control:~/github/pcdsdevices(fix_att_move_err -)$ happi load xpp_attenuator
[2023-11-10 15:03:00] - INFO -  Creating shell with devices ('xpp_attenuator',)
Python 3.9.18 | packaged by conda-forge | (main, Aug 30 2023, 03:49:32)
Type 'copyright', 'credits' or 'license' for more information
IPython 8.4.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: xpp_attenuator.__class__.mro()
Out[1]:
[pcdsdevices.attenuator.Attenuator10,
 pcdsdevices.attenuator.AttBaseWith3rdHarmonicLP,
 pcdsdevices.attenuator.AttBaseWith3rdHarmonic,
 pcdsdevices.attenuator.AttBase,
 pcdsdevices.interface.FltMvInterface,
 pcdsdevices.interface.MvInterface,
 pcdsdevices.interface.BaseInterface,
 pcdsdevices.pv_positioner.PVPositionerNoInterrupt,
 ophyd.pv_positioner.PVPositioner,
 pcdsdevices.interface.LightpathInOutCptMixin,
 pcdsdevices.interface.LightpathMixin,
 ophyd.device.Device,
 ophyd.device.BlueskyInterface,
 ophyd.positioner.PositionerBase,
 ophyd.ophydobj.OphydObject,
 object]

In [2]: att = xpp_attenuator

In [3]: att(0); att(1)
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Input In [3], in <cell line: 1>()
----> 1 att(0); att(1)

File ~/github/pcdsdevices/pcdsdevices/interface.py:694, in MvInterface.__call__(self, position, timeout, wait, log)
    692     return self.wm()
    693 else:
--> 694     self.mv(position, timeout=timeout, wait=wait, log=log)

File ~/github/pcdsdevices/pcdsdevices/interface.py:671, in MvInterface.mv(self, position, timeout, wait, log)
    668     self._log_move(position)
    670 try:
--> 671     self.move(position, timeout=timeout, wait=wait)
    672 except ophyd.utils.LimitError:
    673     return

File ~/github/pcdsdevices/pcdsdevices/interface.py:627, in MvInterface.move(self, *args, **kwargs)
    625 def move(self, *args, **kwargs):
    626     try:
--> 627         st = super().move(*args, **kwargs)
    628     except ophyd.utils.LimitError as ex:
    629         # Pick out the position either in kwargs or args
    630         try:

File ~/github/pcdsdevices/pcdsdevices/pv_positioner.py:266, in PVPositionerNoInterrupt.move(self, position, wait, timeout, moved_cb)
    264     except Exception:
    265         progress = ""
--> 266     raise RuntimeError(
    267         f"The {self.name} device cannot start a new move because the "
    268         "previous move has not completed. This is not an "
    269         "interruptable positioner. Try waiting after the previous "
    270         f"move or for the move's status to complete. {progress}"
    271     )
    272 else:
    273     return super().move(position, wait=wait, timeout=timeout, moved_cb=moved_cb)

RuntimeError: The xpp_attenuator device cannot start a new move because the previous move has not completed. This is not an interruptable positioner. Try waiting after the previous move or for the move's status to complete. Position = 1.0, goal = 0.0.

In [4]: att(1); att.wait(); att(0); att.wait(); att(1)

In [5]: att(1); att.wait(); att(0); att.wait(); att(1)
^C---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
Input In [5], in <cell line: 1>()
----> 1 att(1); att.wait(); att(0); att.wait(); att(1)

File ~/github/pcdsdevices/pcdsdevices/interface.py:644, in MvInterface.wait(self, timeout)
    642 if self._last_status is None:
    643     return
--> 644 self._last_status.wait(timeout=timeout)

File /cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/status.py:431, in StatusBase.wait(self, timeout)
    405 def wait(self, timeout=None):
    406     """
    407     Block until the action completes.
    408
   (...)
    429         from ``WaitTimeoutError`` above.
    430     """
--> 431     if not self._event.wait(timeout=timeout):
    432         raise WaitTimeoutError("Status has not completed yet.")
    433     if self._exception is not None:

File /cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/threading.py:581, in Event.wait(self, timeout)
    579 signaled = self._flag
    580 if not signaled:
--> 581     signaled = self._cond.wait(timeout)
    582 return signaled

File /cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/threading.py:312, in Condition.wait(self, timeout)
    310 try:    # restore state no matter what (e.g., KeyboardInterrupt)
    311     if timeout is None:
--> 312         waiter.acquire()
    313         gotit = True
    314     else:

KeyboardInterrupt:

In [6]: att(1)
Device filter1 (Filter(XPP:ATT:01, name=xpp_attenuator_filter1)) stop failed
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1473, in stop
    dev.stop(success=success)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1329, in __getattr__
    raise AttributeError(name)
AttributeError: stop
Device filter2 (Filter(XPP:ATT:02, name=xpp_attenuator_filter2)) stop failed
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1473, in stop
    dev.stop(success=success)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1329, in __getattr__
    raise AttributeError(name)
AttributeError: stop
Device filter3 (Filter(XPP:ATT:03, name=xpp_attenuator_filter3)) stop failed
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1473, in stop
    dev.stop(success=success)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1329, in __getattr__
    raise AttributeError(name)
AttributeError: stop
Device filter4 (Filter(XPP:ATT:04, name=xpp_attenuator_filter4)) stop failed
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1473, in stop
    dev.stop(success=success)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1329, in __getattr__
    raise AttributeError(name)
AttributeError: stop
Device filter5 (Filter(XPP:ATT:05, name=xpp_attenuator_filter5)) stop failed
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1473, in stop
    dev.stop(success=success)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1329, in __getattr__
    raise AttributeError(name)
AttributeError: stop
Device filter6 (Filter(XPP:ATT:06, name=xpp_attenuator_filter6)) stop failed
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1473, in stop
    dev.stop(success=success)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1329, in __getattr__
    raise AttributeError(name)
AttributeError: stop
Device filter7 (Filter(XPP:ATT:07, name=xpp_attenuator_filter7)) stop failed
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1473, in stop
    dev.stop(success=success)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1329, in __getattr__
    raise AttributeError(name)
AttributeError: stop
Device filter8 (Filter(XPP:ATT:08, name=xpp_attenuator_filter8)) stop failed
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1473, in stop
    dev.stop(success=success)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1329, in __getattr__
    raise AttributeError(name)
AttributeError: stop
Device filter9 (Filter(XPP:ATT:09, name=xpp_attenuator_filter9)) stop failed
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1473, in stop
    dev.stop(success=success)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1329, in __getattr__
    raise AttributeError(name)
AttributeError: stop
Device filter10 (Filter(XPP:ATT:10, name=xpp_attenuator_filter10)) stop failed
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1473, in stop
    dev.stop(success=success)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1329, in __getattr__
    raise AttributeError(name)
AttributeError: stop
MoveStatus(done=True, pos=xpp_attenuator, elapsed=18.3, success=False, settle_time=0.0) encountered an error during _handle_failure()
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/status.py", line 259, in _run_callbacks
    self._handle_failure()
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/status.py", line 643, in _handle_failure
    self.device.stop()
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/pv_positioner.py", line 268, in stop
    super().stop(success=success)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1489, in stop
    raise ExceptionBundle(
ophyd.utils.errors.ExceptionBundle: 10 exception(s) were raised during stop:
filter1 raised AttributeError('stop')
filter2 raised AttributeError('stop')
filter3 raised AttributeError('stop')
filter4 raised AttributeError('stop')
filter5 raised AttributeError('stop')
filter6 raised AttributeError('stop')
filter7 raised AttributeError('stop')
filter8 raised AttributeError('stop')
filter9 raised AttributeError('stop')
filter10 raised AttributeError('stop')

In [7]: att(1)
Device filter1 (Filter(XPP:ATT:01, name=xpp_attenuator_filter1)) stop failed
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1473, in stop
    dev.stop(success=success)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1329, in __getattr__
    raise AttributeError(name)
AttributeError: stop
Device filter2 (Filter(XPP:ATT:02, name=xpp_attenuator_filter2)) stop failed
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1473, in stop
    dev.stop(success=success)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1329, in __getattr__
    raise AttributeError(name)
AttributeError: stop
Device filter3 (Filter(XPP:ATT:03, name=xpp_attenuator_filter3)) stop failed
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1473, in stop
    dev.stop(success=success)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1329, in __getattr__
    raise AttributeError(name)
AttributeError: stop
Device filter4 (Filter(XPP:ATT:04, name=xpp_attenuator_filter4)) stop failed
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1473, in stop
    dev.stop(success=success)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1329, in __getattr__
    raise AttributeError(name)
AttributeError: stop
Device filter5 (Filter(XPP:ATT:05, name=xpp_attenuator_filter5)) stop failed
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1473, in stop
    dev.stop(success=success)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1329, in __getattr__
    raise AttributeError(name)
AttributeError: stop
Device filter6 (Filter(XPP:ATT:06, name=xpp_attenuator_filter6)) stop failed
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1473, in stop
    dev.stop(success=success)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1329, in __getattr__
    raise AttributeError(name)
AttributeError: stop
Device filter7 (Filter(XPP:ATT:07, name=xpp_attenuator_filter7)) stop failed
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1473, in stop
    dev.stop(success=success)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1329, in __getattr__
    raise AttributeError(name)
AttributeError: stop
Device filter8 (Filter(XPP:ATT:08, name=xpp_attenuator_filter8)) stop failed
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1473, in stop
    dev.stop(success=success)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1329, in __getattr__
    raise AttributeError(name)
AttributeError: stop
Device filter9 (Filter(XPP:ATT:09, name=xpp_attenuator_filter9)) stop failed
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1473, in stop
    dev.stop(success=success)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1329, in __getattr__
    raise AttributeError(name)
AttributeError: stop
Device filter10 (Filter(XPP:ATT:10, name=xpp_attenuator_filter10)) stop failed
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1473, in stop
    dev.stop(success=success)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1329, in __getattr__
    raise AttributeError(name)
AttributeError: stop
MoveStatus(done=True, pos=xpp_attenuator, elapsed=12.2, success=False, settle_time=0.0) encountered an error during _handle_failure()
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/status.py", line 259, in _run_callbacks
    self._handle_failure()
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/status.py", line 643, in _handle_failure
    self.device.stop()
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/pv_positioner.py", line 268, in stop
    super().stop(success=success)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1489, in stop
    raise ExceptionBundle(
ophyd.utils.errors.ExceptionBundle: 10 exception(s) were raised during stop:
filter1 raised AttributeError('stop')
filter2 raised AttributeError('stop')
filter3 raised AttributeError('stop')
filter4 raised AttributeError('stop')
filter5 raised AttributeError('stop')
filter6 raised AttributeError('stop')
filter7 raised AttributeError('stop')
filter8 raised AttributeError('stop')
filter9 raised AttributeError('stop')
filter10 raised AttributeError('stop')

In [8]: att.move(1, wait=False)
Device filter1 (Filter(XPP:ATT:01, name=xpp_attenuator_filter1)) stop failed
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1473, in stop
    dev.stop(success=success)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1329, in __getattr__
    raise AttributeError(name)
AttributeError: stop
Device filter2 (Filter(XPP:ATT:02, name=xpp_attenuator_filter2)) stop failed
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1473, in stop
    dev.stop(success=success)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1329, in __getattr__
    raise AttributeError(name)
AttributeError: stop
Device filter3 (Filter(XPP:ATT:03, name=xpp_attenuator_filter3)) stop failed
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1473, in stop
    dev.stop(success=success)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1329, in __getattr__
    raise AttributeError(name)
AttributeError: stop
Device filter4 (Filter(XPP:ATT:04, name=xpp_attenuator_filter4)) stop failed
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1473, in stop
    dev.stop(success=success)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1329, in __getattr__
    raise AttributeError(name)
AttributeError: stop
Device filter5 (Filter(XPP:ATT:05, name=xpp_attenuator_filter5)) stop failed
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1473, in stop
    dev.stop(success=success)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1329, in __getattr__
    raise AttributeError(name)
AttributeError: stop
Device filter6 (Filter(XPP:ATT:06, name=xpp_attenuator_filter6)) stop failed
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1473, in stop
    dev.stop(success=success)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1329, in __getattr__
    raise AttributeError(name)
AttributeError: stop
Device filter7 (Filter(XPP:ATT:07, name=xpp_attenuator_filter7)) stop failed
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1473, in stop
    dev.stop(success=success)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1329, in __getattr__
    raise AttributeError(name)
AttributeError: stop
Device filter8 (Filter(XPP:ATT:08, name=xpp_attenuator_filter8)) stop failed
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1473, in stop
    dev.stop(success=success)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1329, in __getattr__
    raise AttributeError(name)
AttributeError: stop
Device filter9 (Filter(XPP:ATT:09, name=xpp_attenuator_filter9)) stop failed
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1473, in stop
    dev.stop(success=success)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1329, in __getattr__
    raise AttributeError(name)
AttributeError: stop
Device filter10 (Filter(XPP:ATT:10, name=xpp_attenuator_filter10)) stop failed
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1473, in stop
    dev.stop(success=success)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1329, in __getattr__
    raise AttributeError(name)
AttributeError: stop
MoveStatus(done=True, pos=xpp_attenuator, elapsed=31.8, success=False, settle_time=0.0) encountered an error during _handle_failure()
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/status.py", line 259, in _run_callbacks
    self._handle_failure()
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/status.py", line 643, in _handle_failure
    self.device.stop()
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/pv_positioner.py", line 268, in stop
    super().stop(success=success)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1489, in stop
    raise ExceptionBundle(
ophyd.utils.errors.ExceptionBundle: 10 exception(s) were raised during stop:
filter1 raised AttributeError('stop')
filter2 raised AttributeError('stop')
filter3 raised AttributeError('stop')
filter4 raised AttributeError('stop')
filter5 raised AttributeError('stop')
filter6 raised AttributeError('stop')
filter7 raised AttributeError('stop')
filter8 raised AttributeError('stop')
filter9 raised AttributeError('stop')
filter10 raised AttributeError('stop')
Out[8]: MoveStatus(done=False, pos=xpp_attenuator, elapsed=0.1, success=False, settle_time=0.0)

In [9]: att.moving
Out[9]: False

In [10]: att._last_status.set_finished()

In [11]: att.move(1, wait=False)
Subscription _req_done callback exception (Attenuator10(XPP:ATT, name=xpp_attenuator))
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/ophydobj.py", line 492, in inner
    cb(*args, **kwargs)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/status.py", line 381, in _finished
    self.set_exception(exc)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/status.py", line 317, in set_exception
    raise InvalidState(
ophyd.utils.errors.InvalidState: Either set_finished() or set_exception() has already been called on MoveStatus(done=True, pos=xpp_attenuator, elapsed=57.1, success=True, settle_time=0.0)
Out[11]: MoveStatus(done=False, pos=xpp_attenuator, elapsed=0.1, success=False, settle_time=0.0)

In [12]: att.move(1, wait=False)
Device filter1 (Filter(XPP:ATT:01, name=xpp_attenuator_filter1)) stop failed
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1473, in stop
    dev.stop(success=success)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1329, in __getattr__
    raise AttributeError(name)
AttributeError: stop
Device filter2 (Filter(XPP:ATT:02, name=xpp_attenuator_filter2)) stop failed
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1473, in stop
    dev.stop(success=success)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1329, in __getattr__
    raise AttributeError(name)
AttributeError: stop
Device filter3 (Filter(XPP:ATT:03, name=xpp_attenuator_filter3)) stop failed
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1473, in stop
    dev.stop(success=success)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1329, in __getattr__
    raise AttributeError(name)
AttributeError: stop
Device filter4 (Filter(XPP:ATT:04, name=xpp_attenuator_filter4)) stop failed
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1473, in stop
    dev.stop(success=success)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1329, in __getattr__
    raise AttributeError(name)
AttributeError: stop
Device filter5 (Filter(XPP:ATT:05, name=xpp_attenuator_filter5)) stop failed
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1473, in stop
    dev.stop(success=success)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1329, in __getattr__
    raise AttributeError(name)
AttributeError: stop
Device filter6 (Filter(XPP:ATT:06, name=xpp_attenuator_filter6)) stop failed
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1473, in stop
    dev.stop(success=success)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1329, in __getattr__
    raise AttributeError(name)
AttributeError: stop
Device filter7 (Filter(XPP:ATT:07, name=xpp_attenuator_filter7)) stop failed
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1473, in stop
    dev.stop(success=success)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1329, in __getattr__
    raise AttributeError(name)
AttributeError: stop
Device filter8 (Filter(XPP:ATT:08, name=xpp_attenuator_filter8)) stop failed
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1473, in stop
    dev.stop(success=success)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1329, in __getattr__
    raise AttributeError(name)
AttributeError: stop
Device filter9 (Filter(XPP:ATT:09, name=xpp_attenuator_filter9)) stop failed
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1473, in stop
    dev.stop(success=success)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1329, in __getattr__
    raise AttributeError(name)
AttributeError: stop
Device filter10 (Filter(XPP:ATT:10, name=xpp_attenuator_filter10)) stop failed
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1473, in stop
    dev.stop(success=success)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1329, in __getattr__
    raise AttributeError(name)
AttributeError: stop
MoveStatus(done=True, pos=xpp_attenuator, elapsed=6.9, success=False, settle_time=0.0) encountered an error during _handle_failure()
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/status.py", line 259, in _run_callbacks
    self._handle_failure()
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/status.py", line 643, in _handle_failure
    self.device.stop()
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/pv_positioner.py", line 268, in stop
    super().stop(success=success)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.0/lib/python3.9/site-packages/ophyd/device.py", line 1489, in stop
    raise ExceptionBundle(
ophyd.utils.errors.ExceptionBundle: 10 exception(s) were raised during stop:
filter1 raised AttributeError('stop')
filter2 raised AttributeError('stop')
filter3 raised AttributeError('stop')
filter4 raised AttributeError('stop')
filter5 raised AttributeError('stop')
filter6 raised AttributeError('stop')
filter7 raised AttributeError('stop')
filter8 raised AttributeError('stop')
filter9 raised AttributeError('stop')
filter10 raised AttributeError('stop')
Out[12]: MoveStatus(done=False, pos=xpp_attenuator, elapsed=0.1, success=False, settle_time=0.0)

In [13]: exit
(pcds-5.8.0)zlentz@xpp-control:~/github/pcdsdevices(fix_att_move_err -)$ happi load xpp_attenuator
[2023-11-10 15:07:26] - INFO -  Creating shell with devices ('xpp_attenuator',)
Python 3.9.18 | packaged by conda-forge | (main, Aug 30 2023, 03:49:32)
Type 'copyright', 'credits' or 'license' for more information
IPython 8.4.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: att = xpp_attenuator

In [2]: att(1)

In [3]: att(0)

In [4]: att(1)

In [5]: att(0); att(1)
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Input In [5], in <cell line: 1>()
----> 1 att(0); att(1)

File ~/github/pcdsdevices/pcdsdevices/interface.py:694, in MvInterface.__call__(self, position, timeout, wait, log)
    692     return self.wm()
    693 else:
--> 694     self.mv(position, timeout=timeout, wait=wait, log=log)

File ~/github/pcdsdevices/pcdsdevices/interface.py:671, in MvInterface.mv(self, position, timeout, wait, log)
    668     self._log_move(position)
    670 try:
--> 671     self.move(position, timeout=timeout, wait=wait)
    672 except ophyd.utils.LimitError:
    673     return

File ~/github/pcdsdevices/pcdsdevices/interface.py:627, in MvInterface.move(self, *args, **kwargs)
    625 def move(self, *args, **kwargs):
    626     try:
--> 627         st = super().move(*args, **kwargs)
    628     except ophyd.utils.LimitError as ex:
    629         # Pick out the position either in kwargs or args
    630         try:

File ~/github/pcdsdevices/pcdsdevices/pv_positioner.py:266, in PVPositionerNoInterrupt.move(self, position, wait, timeout, moved_cb)
    264     except Exception:
    265         progress = ""
--> 266     raise RuntimeError(
    267         f"The {self.name} device cannot start a new move because the "
    268         "previous move has not completed. This is not an "
    269         "interruptable positioner. Try waiting after the previous "
    270         f"move or for the move's status to complete. {progress}"
    271     )
    272 else:
    273     return super().move(position, wait=wait, timeout=timeout, moved_cb=moved_cb)

RuntimeError: The xpp_attenuator device cannot start a new move because the previous move has not completed. This is not an interruptable positioner. Try waiting after the previous move or for the move's status to complete. Position = 1.0, goal = 0.0.

In [6]: att(1); att.wait(); att(0)

In [7]: att(0)

In [8]: att(0); att.wait(); att(1)

In [9]: att(1)

In [10]: att(1)

In [11]: att(0)

In [12]: att(1)

In [13]: att.settle_time
Out[13]: 0.0

In [14]: att.settle_time??
Type:        property
String form: <property object at 0x7f11bc239b30>
Source:
# att.settle_time.fget
@property
def settle_time(self):
    """Amount of time to wait after moves to report status completion"""
    return self._settle_time

# att.settle_time.fset
@settle_time.setter
def settle_time(self, settle_time):
    self._settle_time = settle_time

In [15]: att.settle_time = 0.1

In [16]: att(0); att.wait(); att(1)

In [17]: att.settle_time = 1

In [18]: att(0); att.wait(); att(1)

In [19]:

@ZLLentz
Copy link
Member Author

ZLLentz commented Nov 10, 2023

I think I want to merge this as-is and consider what follow-up options exist for mitigating this behavior.

@ZLLentz ZLLentz merged commit f4121f6 into pcdshub:master Nov 10, 2023
9 checks passed
@ZLLentz
Copy link
Member Author

ZLLentz commented Nov 10, 2023

I've pulled some follow-up tasks into jira tickets, which despite being less transparent on the github end are more convenient internally for assignment/tracking:
https://jira.slac.stanford.edu/browse/ECS-4142
https://jira.slac.stanford.edu/browse/ECS-4143

@ZLLentz ZLLentz deleted the fix_att_move_err branch November 10, 2023 23:44
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

Successfully merging this pull request may close these issues.

4 participants