NSLS-II / Bug-Reports

Unified issue-tracker for bugs in the data acquisition, management, and analysis software at NSLS-II
BSD 3-Clause "New" or "Revised" License
2 stars 5 forks source link

unexpected behavior with pchain() #166

Open ambarb opened 7 years ago

ambarb commented 7 years ago

Let me say that I converted everything to a plan, but for testing purposes (and a little laziness) wanted to use pchain because i am not setting up something to run overnight. I had to remove an entire portion in order to get it to work approximated. But I converted line 344 to a plan and had no issues.

Printing occurred out of order with regard to the RE(pchain(...)). In a script, the print order occurs as expected and no errors with the epu2 scan included.

In [344]: RE(pchain(dscan(diag6_pid,-50,50,50),bp.sleep(3),print('\n\ncenter',gs.PS.cen,'\n\n'), bp.mv(diag6_pid,gs.PS.cen),bp.sleep(3),dscan(epu2.gap,-.5,.5,20),print(gs.PS.max[0])))

center None 

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/home/xf23id1/Beamline/Commissioning/2017_03/exit_arm.py in <module>()
----> 1 RE(pchain(dscan(diag6_pid,-50,50,50),bp.sleep(3),print('\n\ncenter',gs.PS.cen,'\n\n'), bp.mv(diag6_pid,gs.PS.cen),bp.sleep(3),dscan(epu2.gap,-.5,.5,20),print(gs.PS.max[0])))

TypeError: 'NoneType' object is not subscriptable

In [345]: RE(pchain(dscan(diag6_pid,-50,50,50),bp.sleep(3),print('\n\ncenter',gs.PS.cen,'\n\n'), bp.mv(diag6_pid,gs.PS.cen)))

center None 

Transient Scan ID: 76048 @ 2017/03/10 22:55:52
Persistent Unique Scan ID: '488ff550-0ef7-4ebc-bcd1-202369a27820'
+-----------+------------+-------------------+----------------+--------------------+--------------------+-----------------------+------------+------------+------------+
|   seq_num |       time | diag6_pid_actuate | diag6_pid_done | diag6_pid_readback | diag6_pid_setpoint | diag6_pid_stop_signal |   sclr_ch2 |   sclr_ch3 |   sclr_ch6 |
+-----------+------------+-------------------+----------------+--------------------+--------------------+-----------------------+------------+------------+------------+
|         1 | 22:55:59.9 |                 1 |              1 |           1130.000 |           1130.000 |                     1 |       1287 |        989 |      39203 |
|         2 | 22:56:02.4 |                 1 |              1 |           1132.000 |           1132.000 |                     1 |          0 |       1012 |      39261 |
|         3 | 22:56:04.9 |                 1 |              1 |           1134.000 |           1134.000 |                     1 |          0 |        989 |      39158 |
|         4 | 22:56:07.4 |                 1 |              1 |           1136.000 |           1136.000 |                     1 |          0 |        983 |      39167 |
|         5 | 22:56:10.4 |                 1 |              1 |           1138.000 |           1138.000 |                     1 |          0 |       1004 |      39215 |
|         6 | 22:56:13.0 |                 1 |              1 |           1140.000 |           1140.000 |                     1 |          0 |        988 |      39232 |
|         7 | 22:56:15.8 |                 1 |              1 |           1142.000 |           1142.000 |                     1 |          0 |        988 |      39205 |
|         8 | 22:56:17.8 |                 1 |              1 |           1144.000 |           1144.000 |                     1 |          0 |        980 |      39127 |
|         9 | 22:56:20.4 |                 1 |              1 |           1146.000 |           1146.000 |                     1 |        684 |        994 |      39259 |
|        10 | 22:56:22.7 |                 1 |              1 |           1148.000 |           1148.000 |                     1 |        989 |        989 |      39227 |
|        11 | 22:56:24.9 |                 1 |              1 |           1150.000 |           1150.000 |                     1 |       1389 |        974 |      39236 |
|        12 | 22:56:27.2 |                 1 |              1 |           1152.000 |           1152.000 |                     1 |       1962 |        990 |      39188 |
|        13 | 22:56:29.4 |                 1 |              1 |           1154.000 |           1154.000 |                     1 |       2519 |        991 |      39173 |
|        14 | 22:56:31.8 |                 1 |              1 |           1156.000 |           1156.000 |                     1 |       3142 |        993 |      39233 |
|        15 | 22:56:34.2 |                 1 |              1 |           1158.000 |           1158.000 |                     1 |       3843 |       1013 |      39144 |
|        16 | 22:56:36.6 |                 1 |              1 |           1160.000 |           1160.000 |                     1 |       5144 |        999 |      39187 |
|        17 | 22:56:38.8 |                 1 |              1 |           1162.000 |           1162.000 |                     1 |       6648 |        991 |      39175 |
|        18 | 22:56:41.0 |                 1 |              1 |           1164.000 |           1164.000 |                     1 |       7149 |        993 |      39170 |
|        19 | 22:56:43.2 |                 1 |              1 |           1166.000 |           1166.000 |                     1 |       8181 |        988 |      39228 |
|        20 | 22:56:45.8 |                 1 |              1 |           1168.000 |           1168.000 |                     1 |      10060 |        995 |      39132 |
|        21 | 22:56:48.2 |                 1 |              1 |           1170.000 |           1170.000 |                     1 |      11420 |        995 |      39104 |
|        22 | 22:56:50.4 |                 1 |              1 |           1172.000 |           1172.000 |                     1 |      13293 |        981 |      39135 |
|        23 | 22:56:52.8 |                 1 |              1 |           1174.000 |           1174.000 |                     1 |      13590 |        986 |      39114 |
|        24 | 22:56:55.2 |                 1 |              1 |           1176.000 |           1176.000 |                     1 |      14301 |       1004 |      38985 |
|        25 | 22:56:57.3 |                 1 |              1 |           1178.000 |           1178.000 |                     1 |      15516 |        989 |      39175 |
|        26 | 22:56:59.7 |                 1 |              1 |           1180.000 |           1180.000 |                     1 |      16077 |        981 |      39151 |
|        27 | 22:57:02.3 |                 1 |              1 |           1182.000 |           1182.000 |                     1 |      16524 |        996 |      39280 |
|        28 | 22:57:04.4 |                 1 |              1 |           1184.000 |           1184.000 |                     1 |      16492 |        987 |      39240 |
|        29 | 22:57:06.5 |                 1 |              1 |           1186.000 |           1186.000 |                     1 |      16275 |        997 |      39247 |
|        30 | 22:57:08.8 |                 1 |              1 |           1188.000 |           1188.000 |                     1 |      16743 |       1001 |      39222 |
|        31 | 22:57:11.2 |                 1 |              1 |           1190.000 |           1190.000 |                     1 |      14645 |        994 |      39150 |
|        32 | 22:57:13.4 |                 1 |              1 |           1192.000 |           1192.000 |                     1 |      13883 |        996 |      39159 |
|        33 | 22:57:15.9 |                 1 |              1 |           1194.000 |           1194.000 |                     1 |      13352 |        964 |      39209 |
|        34 | 22:57:18.5 |                 1 |              1 |           1196.000 |           1196.000 |                     1 |      12315 |        971 |      39131 |
|        35 | 22:57:21.0 |                 1 |              1 |           1198.000 |           1198.000 |                     1 |      11850 |        992 |      39021 |
|        36 | 22:57:23.3 |                 1 |              1 |           1200.000 |           1200.000 |                     1 |      10198 |        977 |      39006 |
|        37 | 22:57:25.4 |                 1 |              1 |           1202.000 |           1202.000 |                     1 |       8539 |        983 |      39085 |
|        38 | 22:57:27.5 |                 1 |              1 |           1204.000 |           1204.000 |                     1 |       7503 |        988 |      39072 |
|        39 | 22:57:29.5 |                 1 |              1 |           1206.000 |           1206.000 |                     1 |       6384 |        981 |      39059 |
|        40 | 22:57:31.5 |                 1 |              1 |           1208.000 |           1208.000 |                     1 |       5145 |        991 |      39027 |
|        41 | 22:57:33.6 |                 1 |              1 |           1210.000 |           1210.000 |                     1 |       4232 |        992 |      39160 |
|        42 | 22:57:35.8 |                 1 |              1 |           1212.000 |           1212.000 |                     1 |       3550 |        974 |      39231 |
|        43 | 22:57:37.8 |                 1 |              1 |           1214.000 |           1214.000 |                     1 |       2593 |        983 |      39145 |
|        44 | 22:57:39.9 |                 1 |              1 |           1216.000 |           1216.000 |                     1 |       1921 |        983 |      39180 |
|        45 | 22:57:41.9 |                 1 |              1 |           1218.000 |           1218.000 |                     1 |       1585 |        993 |      39150 |
|        46 | 22:57:43.9 |                 1 |              1 |           1220.000 |           1220.000 |                     1 |       1097 |        976 |      39165 |
|        47 | 22:57:45.7 |                 1 |              1 |           1222.000 |           1222.000 |                     1 |        780 |        982 |      39240 |
|        48 | 22:57:47.8 |                 1 |              1 |           1224.000 |           1224.000 |                     1 |        459 |        979 |      39142 |
|        49 | 22:57:49.9 |                 1 |              1 |           1226.000 |           1226.000 |                     1 |        306 |        977 |      39127 |
+-----------+------------+-------------------+----------------+--------------------+--------------------+-----------------------+------------+------------+------------+
|   seq_num |       time | diag6_pid_actuate | diag6_pid_done | diag6_pid_readback | diag6_pid_setpoint | diag6_pid_stop_signal |   sclr_ch2 |   sclr_ch3 |   sclr_ch6 |
+-----------+------------+-------------------+----------------+--------------------+--------------------+-----------------------+------------+------------+------------+
|        50 | 22:57:51.7 |                 1 |              1 |           1228.000 |           1228.000 |                     1 |        152 |        978 |      39020 |
|        51 | 22:57:53.6 |                 1 |              1 |           1230.000 |           1230.000 |                     1 |         26 |        970 |      39031 |
+-----------+------------+-------------------+----------------+--------------------+--------------------+-----------------------+------------+------------+------------+
generator dscan ['488ff5'] (scan num: 76048)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/home/xf23id1/Beamline/Commissioning/2017_03/exit_arm.py in <module>()
----> 1 RE(pchain(dscan(diag6_pid,-50,50,50),bp.sleep(3),print('\n\ncenter',gs.PS.cen,'\n\n'), bp.mv(diag6_pid,gs.PS.cen)))

/opt/conda_envs/collection-17Q1.0/lib/python3.5/site-packages/bluesky/run_engine.py in __call__(self, plan, subs, raise_if_interrupted, **metadata_kw)
    596                     # it (unless it is a canceled error)
    597                     if exc is not None:
--> 598                         raise exc
    599 
    600             if raise_if_interrupted and self._interrupted:

/opt/conda_envs/collection-17Q1.0/lib/python3.5/asyncio/tasks.py in _step(***failed resolving arguments***)
    237                 # We use the `send` method directly, because coroutines
    238                 # don't have `__iter__` and `__next__` methods.
--> 239                 result = coro.send(None)
    240             else:
    241                 result = coro.throw(exc)

/opt/conda_envs/collection-17Q1.0/lib/python3.5/site-packages/bluesky/run_engine.py in _run(self)
   1002             self.log.error("Run aborted")
   1003             self.log.error("%r", err)
-> 1004             raise err
   1005         finally:
   1006             # Some done_callbacks may still be alive in other threads.

/opt/conda_envs/collection-17Q1.0/lib/python3.5/site-packages/bluesky/run_engine.py in _run(self)
    900                         resp = self._response_stack.pop()
    901                         try:
--> 902                             msg = self._plan_stack[-1].send(resp)
    903                         # We have exhausted the top generator
    904                         except StopIteration:

/opt/conda_envs/collection-17Q1.0/lib/python3.5/site-packages/bluesky/plans.py in pchain(*args)
    286     rets = deque()
    287     for p in args:
--> 288         rets.append((yield from p))
    289     return tuple(rets)
    290 

TypeError: 'NoneType' object is not iterable

In [346]: gs.PS.cen
Out[346]: 1184.2630632514215

In [347]: RE(mv(diag6_pid,gs.PS.cen))
Out[347]: []
tacaswell commented 7 years ago

You can only put plans in pchain, not normal functions.

The issue is the print calls which return None which is not iterable.