aps-8id-dys / ipython-8idiuser

8-ID-I ipython configuration for bluesky (and other)
1 stars 1 forks source link

Eiger file always have FileNumber attached to it #286

Closed qzhang234 closed 2 years ago

qzhang234 commented 2 years ago

All files saved by Eiger has FileNumber attached at the end, which was not included in the file name variable (see screenshot attached). There is no mentioning of the PV dp_eiger_xrd4:HDF1:FileNumber anywhere in ad_eiger either, so chances are this might be defined in a base library.

@prjemian Any suggestions on how to edit that?

MicrosoftTeams-image MicrosoftTeams-image (1)

qzhang234 commented 2 years ago

@prjemian It appears that as long as I change the file format to %s%s.h5 it would look fine. However the moment I acquire again in AD_Acquire it flips back. How do I add the file format in the staging process?

MicrosoftTeams-image

prjemian commented 2 years ago

Set eiger.hdf1.stage_sigs["file_format"] = "%s%s.h5"

On Sun, May 22, 2022, 2:16 AM Qingteng Zhang @.***> wrote:

@prjemian https://github.com/prjemian It appears that as long as I change the file format to %s%s.h5 it would look fine. However the moment I acquire again in AD_Acquire it flips back. How do I add the file format in the staging process?

[image: MicrosoftTeams-image] https://user-images.githubusercontent.com/48140482/169683543-6838c0dc-7ea2-44c2-8eb4-5e83ec6b4682.png

— Reply to this email directly, view it on GitHub https://github.com/aps-8id-dys/ipython-8idiuser/issues/286#issuecomment-1133834816, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARMUMGXPJYM5JOWG52AQBTVLHNONANCNFSM5WSZ34FQ . You are receiving this because you were mentioned.Message ID: @.***>

qzhang234 commented 2 years ago

@prjemian I added this line in the base class LocalEigerDetectorBase and it's not working:

Code here

Looking at the variable name more closely, I realized that it should be file_template instead of file_format, so I tried that, but it's not working either. The error is attached in the pull down tab.

Any suggestions?

Error from IPython terminal ``` In [5]: RE(repeat_acq(file_header='C',acq_rep=3)) C022_00001_att00_Test (AD_Acquire): num_images=10000 (EigerDetector): num_images=10000 (EigerDetector): file_name=C022_00001_att00_Test (EigerDetector): hdf.image_dir=/home/8ididata/2022-1/bluesky202205/C022_00001_att00_Test/ (EigerDetector): hdf1 stage_sigs=OrderedDict([('enable', 1), ('create_directory', -3), ('auto_increment', 'Yes'), ('array_counter', 0), ('auto_save', 'Yes'), ('num_capture', 10000), ('file_template', '%s%s.h5'), ('file_write_mode', 'Stream'), ('blocking_callbacks', 'Yes'), ('parent.cam.array_callbacks', 1), ('file_name', 'C022_00001_att00_Test'), ('file_path', '/home/8ididata/2022-1/bluesky202205/C022_00001_att00_Test/'), ('capture', 1)]) Run aborted Traceback (most recent call last): File "/home/beams/8IDIUSER/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/run_engine.py", line 1513, in _run msg = self._plan_stack[-1].send(resp) File "/home/beams/8IDIUSER/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py", line 1307, in __call__ return (yield from plan) File "/home/beams/8IDIUSER/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py", line 1162, in baseline_wrapper return (yield from plan_mutator(plan, insert_baseline)) File "/home/beams/8IDIUSER/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py", line 170, in plan_mutator raise ex File "/home/beams/8IDIUSER/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py", line 123, in plan_mutator msg = plan_stack[-1].send(ret) File "/home/beams/8IDIUSER/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py", line 803, in monitor_during_wrapper return (yield from plan2) File "/home/beams/8IDIUSER/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py", line 170, in plan_mutator raise ex File "/home/beams/8IDIUSER/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py", line 123, in plan_mutator msg = plan_stack[-1].send(ret) File "/home/beams/8IDIUSER/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py", line 170, in plan_mutator raise ex File "/home/beams/8IDIUSER/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py", line 123, in plan_mutator msg = plan_stack[-1].send(ret) File "/home/beams/8IDIUSER/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py", line 861, in fly_during_wrapper return (yield from plan2) File "/home/beams/8IDIUSER/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py", line 170, in plan_mutator raise ex File "/home/beams/8IDIUSER/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py", line 123, in plan_mutator msg = plan_stack[-1].send(ret) File "/home/beams/8IDIUSER/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py", line 170, in plan_mutator raise ex File "/home/beams/8IDIUSER/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py", line 123, in plan_mutator msg = plan_stack[-1].send(ret) File "/home/beams10/8IDIUSER/bluesky_data/2022/2022-1/bp_AD_Acquire_Eiger.py", line 33, in repeat_acq yield from AD_Acquire( File "/home/beams10/8IDIUSER/.ipython-bluesky/profile_bluesky/startup/instrument/plans/xpcs_acquire.py", line 320, in AD_Acquire return (yield from full_acquire_procedure(md=md)) File "/home/beams/8IDIUSER/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/utils/__init__.py", line 1140, in dec_inner return (yield from plan) File "/home/beams/8IDIUSER/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py", line 952, in stage_wrapper return (yield from finalize_wrapper(inner(), unstage_devices())) File "/home/beams/8IDIUSER/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py", line 509, in finalize_wrapper ret = yield from plan File "/home/beams/8IDIUSER/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py", line 950, in inner return (yield from plan) File "/home/beams/8IDIUSER/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/utils/__init__.py", line 1140, in dec_inner return (yield from plan) File "/home/beams/8IDIUSER/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py", line 803, in monitor_during_wrapper return (yield from plan2) File "/home/beams/8IDIUSER/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py", line 78, in plan_mutator msg = plan_stack[-1].throw(exception) File "/home/beams/8IDIUSER/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py", line 78, in plan_mutator msg = plan_stack[-1].throw(exception) File "/home/beams10/8IDIUSER/.ipython-bluesky/profile_bluesky/startup/instrument/plans/xpcs_acquire.py", line 288, in full_acquire_procedure yield from inner_count([areadet], md=_md) File "/home/beams10/8IDIUSER/.ipython-bluesky/profile_bluesky/startup/instrument/plans/xpcs_acquire.py", line 241, in inner_count yield from bps.stage(obj) File "/home/beams/8IDIUSER/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/plan_stubs.py", line 696, in stage return (yield Msg('stage', obj)) File "/home/beams/8IDIUSER/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py", line 195, in plan_mutator inner_ret = yield msg File "/home/beams/8IDIUSER/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py", line 195, in plan_mutator inner_ret = yield msg File "/home/beams/8IDIUSER/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py", line 195, in plan_mutator inner_ret = yield msg [Previous line repeated 4 more times] File "/home/beams/8IDIUSER/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/run_engine.py", line 1573, in _run new_response = await coro(msg) File "/home/beams/8IDIUSER/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/run_engine.py", line 2322, in _stage result = obj.stage() File "/home/beams10/8IDIUSER/.ipython-bluesky/profile_bluesky/startup/instrument/devices/ad_eiger.py", line 69, in stage super().stage() File "/home/beams/8IDIUSER/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/ophyd/areadetector/base.py", line 289, in stage ret = super().stage(*args, **kwargs) File "/home/beams/8IDIUSER/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/ophyd/device.py", line 559, in stage device.stage() File "/home/beams/8IDIUSER/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/ophyd/areadetector/plugins.py", line 951, in stage return super().stage() File "/home/beams/8IDIUSER/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/ophyd/areadetector/plugins.py", line 134, in stage super().stage() File "/home/beams/8IDIUSER/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/ophyd/areadetector/base.py", line 289, in stage ret = super().stage(*args, **kwargs) File "/home/beams/8IDIUSER/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/apstools/devices/area_detector_support.py", line 406, in stage self._fn = template % (read_path, filename, file_number) TypeError: not all arguments converted during string formatting --------------------------------------------------------------------------- TypeError Traceback (most recent call last) Input In [5], in () ----> 1 RE(repeat_acq(file_header='C',acq_rep=3)) File ~/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/run_engine.py:892, in RunEngine.__call__(self, *args, **metadata_kw) 888 self._blocking_event.set() 890 self._task_fut.add_done_callback(set_blocking_event) --> 892 plan_return = self._resume_task(init_func=_build_task) 894 if self._interrupted: 895 raise RunEngineInterrupted(self.pause_msg) from None File ~/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/run_engine.py:1030, in RunEngine._resume_task(self, init_func) 1026 # if the main task exception is not None, re-raise 1027 # it (unless it is a canceled error) 1028 if (exc is not None 1029 and not isinstance(exc, _RunEnginePanic)): -> 1030 raise exc 1031 # Only try to get a result if there wasn't an error, 1032 # (other than a cancelled error) 1033 if exc is None: File ~/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/run_engine.py:1653, in RunEngine._run(self) 1651 exit_reason = str(err) 1652 self.log.exception("Run aborted") -> 1653 raise err 1654 finally: 1655 if not exit_reason: File ~/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/run_engine.py:1513, in RunEngine._run(self) 1510 # The normal case of clean operation 1511 else: 1512 try: -> 1513 msg = self._plan_stack[-1].send(resp) 1514 # We have exhausted the top generator 1515 except StopIteration: 1516 # pop the dead generator go back to the top File ~/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py:1307, in SupplementalData.__call__(self, plan) 1305 plan = monitor_during_wrapper(plan, self.monitors) 1306 plan = baseline_wrapper(plan, self.baseline) -> 1307 return (yield from plan) File ~/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py:1162, in baseline_wrapper(plan, devices, name) 1160 return (yield from plan) 1161 else: -> 1162 return (yield from plan_mutator(plan, insert_baseline)) File ~/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py:170, in plan_mutator(plan, msg_proc) 168 continue 169 else: --> 170 raise ex 171 # if inserting / mutating, put new generator on the stack 172 # and replace the current msg with the first element from the 173 # new generator 174 if id(msg) not in msgs_seen: 175 # Use the id as a hash, and hold a reference to the msg so that 176 # it cannot be garbage collected until the plan is complete. File ~/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py:123, in plan_mutator(plan, msg_proc) 121 ret = result_stack.pop() 122 try: --> 123 msg = plan_stack[-1].send(ret) 124 except StopIteration as e: 125 # discard the exhausted generator 126 exhausted_gen = plan_stack.pop() File ~/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py:803, in monitor_during_wrapper(plan, signals) 801 plan1 = plan_mutator(plan, insert_after_open) 802 plan2 = plan_mutator(plan1, insert_before_close) --> 803 return (yield from plan2) File ~/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py:170, in plan_mutator(plan, msg_proc) 168 continue 169 else: --> 170 raise ex 171 # if inserting / mutating, put new generator on the stack 172 # and replace the current msg with the first element from the 173 # new generator 174 if id(msg) not in msgs_seen: 175 # Use the id as a hash, and hold a reference to the msg so that 176 # it cannot be garbage collected until the plan is complete. File ~/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py:123, in plan_mutator(plan, msg_proc) 121 ret = result_stack.pop() 122 try: --> 123 msg = plan_stack[-1].send(ret) 124 except StopIteration as e: 125 # discard the exhausted generator 126 exhausted_gen = plan_stack.pop() File ~/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py:170, in plan_mutator(plan, msg_proc) 168 continue 169 else: --> 170 raise ex 171 # if inserting / mutating, put new generator on the stack 172 # and replace the current msg with the first element from the 173 # new generator 174 if id(msg) not in msgs_seen: 175 # Use the id as a hash, and hold a reference to the msg so that 176 # it cannot be garbage collected until the plan is complete. File ~/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py:123, in plan_mutator(plan, msg_proc) 121 ret = result_stack.pop() 122 try: --> 123 msg = plan_stack[-1].send(ret) 124 except StopIteration as e: 125 # discard the exhausted generator 126 exhausted_gen = plan_stack.pop() File ~/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py:861, in fly_during_wrapper(plan, flyers) 859 plan1 = plan_mutator(plan, insert_after_open) 860 plan2 = plan_mutator(plan1, insert_before_close) --> 861 return (yield from plan2) File ~/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py:170, in plan_mutator(plan, msg_proc) 168 continue 169 else: --> 170 raise ex 171 # if inserting / mutating, put new generator on the stack 172 # and replace the current msg with the first element from the 173 # new generator 174 if id(msg) not in msgs_seen: 175 # Use the id as a hash, and hold a reference to the msg so that 176 # it cannot be garbage collected until the plan is complete. File ~/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py:123, in plan_mutator(plan, msg_proc) 121 ret = result_stack.pop() 122 try: --> 123 msg = plan_stack[-1].send(ret) 124 except StopIteration as e: 125 # discard the exhausted generator 126 exhausted_gen = plan_stack.pop() File ~/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py:170, in plan_mutator(plan, msg_proc) 168 continue 169 else: --> 170 raise ex 171 # if inserting / mutating, put new generator on the stack 172 # and replace the current msg with the first element from the 173 # new generator 174 if id(msg) not in msgs_seen: 175 # Use the id as a hash, and hold a reference to the msg so that 176 # it cannot be garbage collected until the plan is complete. File ~/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py:123, in plan_mutator(plan, msg_proc) 121 ret = result_stack.pop() 122 try: --> 123 msg = plan_stack[-1].send(ret) 124 except StopIteration as e: 125 # discard the exhausted generator 126 exhausted_gen = plan_stack.pop() File /home/beams10/8IDIUSER/bluesky_data/2022/2022-1/bp_AD_Acquire_Eiger.py:33, in repeat_acq(file_header, acq_rep, sample_name, att_value) 29 acq_name = f'{acq_header}_{ii+1:05}_att{att_value:02}_{sample_name}' 31 print(acq_name) ---> 33 yield from AD_Acquire( 34 eiger, 35 file_name=acq_name, 36 acquire_time=1e-3, 37 acquire_period=1e-3, 38 num_images=10000, 39 path=f'/home/8ididata/{aps.aps_cycle.get()}/bluesky202205/', 40 submit_xpcs_job=False, 41 ) 43 bec.enable_plots() 44 bec.enable_table() File /home/beams10/8IDIUSER/.ipython-bluesky/profile_bluesky/startup/instrument/plans/xpcs_acquire.py:320, in AD_Acquire(areadet, file_name, acquire_time, acquire_period, num_images, path, submit_xpcs_job, atten, md) 317 logger.error(err) 319 logger.info("calling full_acquire_procedure()") --> 320 return (yield from full_acquire_procedure(md=md)) File ~/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/utils/__init__.py:1140, in make_decorator..dec_outer..dec..dec_inner(*inner_args, **inner_kwargs) 1138 plan = gen_func(*inner_args, **inner_kwargs) 1139 plan = wrapper(plan, *args, **kwargs) -> 1140 return (yield from plan) File ~/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py:952, in stage_wrapper(plan, devices) 949 yield from stage_devices() 950 return (yield from plan) --> 952 return (yield from finalize_wrapper(inner(), unstage_devices())) File ~/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py:509, in finalize_wrapper(plan, final_plan, pause_for_debug) 507 cleanup = True 508 try: --> 509 ret = yield from plan 510 except GeneratorExit: 511 cleanup = False File ~/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py:950, in stage_wrapper..inner() 948 def inner(): 949 yield from stage_devices() --> 950 return (yield from plan) File ~/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/utils/__init__.py:1140, in make_decorator..dec_outer..dec..dec_inner(*inner_args, **inner_kwargs) 1138 plan = gen_func(*inner_args, **inner_kwargs) 1139 plan = wrapper(plan, *args, **kwargs) -> 1140 return (yield from plan) File ~/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py:803, in monitor_during_wrapper(plan, signals) 801 plan1 = plan_mutator(plan, insert_after_open) 802 plan2 = plan_mutator(plan1, insert_before_close) --> 803 return (yield from plan2) File ~/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py:78, in plan_mutator(plan, msg_proc) 75 if exception is not None: 76 # if we have a stashed exception, pass it along 77 try: ---> 78 msg = plan_stack[-1].throw(exception) 79 except StopIteration as e: 80 # discard the exhausted generator 81 exhausted_gen = plan_stack.pop() File ~/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py:78, in plan_mutator(plan, msg_proc) 75 if exception is not None: 76 # if we have a stashed exception, pass it along 77 try: ---> 78 msg = plan_stack[-1].throw(exception) 79 except StopIteration as e: 80 # discard the exhausted generator 81 exhausted_gen = plan_stack.pop() File /home/beams10/8IDIUSER/.ipython-bluesky/profile_bluesky/startup/instrument/plans/xpcs_acquire.py:288, in AD_Acquire..full_acquire_procedure(md) 286 logger.debug("before count()") 287 # yield from bp.count([areadet], md=md) --> 288 yield from inner_count([areadet], md=_md) 289 logger.debug("after count()") 291 yield from update_metadata_postscan() File /home/beams10/8IDIUSER/.ipython-bluesky/profile_bluesky/startup/instrument/plans/xpcs_acquire.py:241, in AD_Acquire..inner_count(devices, md) 239 yield from bps.open_run(md=md) 240 for obj in devices: --> 241 yield from bps.stage(obj) 242 grp = bps._short_uid('trigger') 243 no_wait = True File ~/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/plan_stubs.py:696, in stage(obj) 679 def stage(obj): 680 """ 681 'Stage' a device (i.e., prepare it for use, 'arm' it). 682 (...) 694 :func:`bluesky.plan_stubs.unstage` 695 """ --> 696 return (yield Msg('stage', obj)) File ~/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py:195, in plan_mutator(plan, msg_proc) 191 continue 193 try: 194 # yield out the 'current message' and collect the return --> 195 inner_ret = yield msg 196 except GeneratorExit: 197 # special case GeneratorExit. We must clean up all of our plans 198 # and exit with out yielding anything else. 199 for p in plan_stack: File ~/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py:195, in plan_mutator(plan, msg_proc) 191 continue 193 try: 194 # yield out the 'current message' and collect the return --> 195 inner_ret = yield msg 196 except GeneratorExit: 197 # special case GeneratorExit. We must clean up all of our plans 198 # and exit with out yielding anything else. 199 for p in plan_stack: [... skipping similar frames: plan_mutator at line 195 (4 times)] File ~/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/preprocessors.py:195, in plan_mutator(plan, msg_proc) 191 continue 193 try: 194 # yield out the 'current message' and collect the return --> 195 inner_ret = yield msg 196 except GeneratorExit: 197 # special case GeneratorExit. We must clean up all of our plans 198 # and exit with out yielding anything else. 199 for p in plan_stack: File ~/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/run_engine.py:1573, in RunEngine._run(self) 1568 # try to finally run the command the user asked for 1569 try: 1570 # this is one of two places that 'async' 1571 # exceptions (coming in via throw) can be 1572 # raised -> 1573 new_response = await coro(msg) 1575 # special case `CancelledError` and let the outer 1576 # exception block deal with it. 1577 except asyncio.CancelledError: File ~/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/bluesky/run_engine.py:2322, in RunEngine._stage(self, msg) 2320 if not isinstance(obj, bs_protocols.Stageable): 2321 return [] -> 2322 result = obj.stage() 2323 self._staged.add(obj) # add first in case of failure below 2324 await self._reset_checkpoint_state_coro() File /home/beams10/8IDIUSER/.ipython-bluesky/profile_bluesky/startup/instrument/devices/ad_eiger.py:69, in TriggerDetectorState.stage(self) 68 def stage(self): ---> 69 super().stage() 70 self._detector_status.subscribe(self._acquire_changed) File ~/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/ophyd/areadetector/base.py:289, in ADBase.stage(self, *args, **kwargs) 288 def stage(self, *args, **kwargs): --> 289 ret = super().stage(*args, **kwargs) 290 try: 291 self.validate_asyn_ports() File ~/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/ophyd/device.py:559, in BlueskyInterface.stage(self) 557 device = getattr(self, attr) 558 if hasattr(device, 'stage'): --> 559 device.stage() 560 devices_staged.append(device) 561 except Exception: File ~/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/ophyd/areadetector/plugins.py:951, in HDF5Plugin.stage(self) 947 if np.array(self.array_size.get()).sum() == 0: 948 raise UnprimedPlugin(f"The plugin {self.dotted_name} on the " 949 f"area detector with name {self.root.name} " 950 f"has not been primed.") --> 951 return super().stage() File ~/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/ophyd/areadetector/plugins.py:134, in PluginBase.stage(self) 133 def stage(self): --> 134 super().stage() 136 if self._misconfigured is None: 137 # If plugin_type has not yet connected, ensure it has here 138 self.plugin_type.wait_for_connection() File ~/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/ophyd/areadetector/base.py:289, in ADBase.stage(self, *args, **kwargs) 288 def stage(self, *args, **kwargs): --> 289 ret = super().stage(*args, **kwargs) 290 try: 291 self.validate_asyn_ports() File ~/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/apstools/devices/area_detector_support.py:406, in AD_EpicsHdf5FileName.stage(self) 402 # AD does the file name templating in C 403 # We can't access that result until after acquisition 404 # so we apply the same template here in Python. 405 template = self.file_template.get() --> 406 self._fn = template % (read_path, filename, file_number) 407 self._fp = read_path 408 if not self.file_path_exists.get(): TypeError: not all arguments converted during string formatting In [6]: eiger.hdf1.stage_sigs Out[6]: OrderedDict([('enable', 1), ('create_directory', -3), ('auto_increment', 'Yes'), ('array_counter', 0), ('auto_save', 'Yes'), ('num_capture', 0), ('file_template', '%s%s_%4.4d.h5'), ('file_write_mode', 'Stream'), ('blocking_callbacks', 'Yes'), ('parent.cam.array_callbacks', 1), ('capture', 1)]) In [7]: ```
qzhang234 commented 2 years ago

@prjemian I noticed that I can set file_format to %s%s_%2.2d.h5, %s%s_%3.3d.h5, %s%s_%4.4d.h5, and AD_Acquire will run just fine, but I cannot set the file name to %s%s.

Looking at the error message more closely (screenshot attached), I believe it's a requirement from

~/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/apstools/devices/area_detector_support.py

Where file_template is supposed to have a number at the end. I do not have permission to modify this file (and I probably shouldn't) and I don't think it's possible to avoid calling area_detector_support.py in AD_Acquire.

image

Any recommendations?

prjemian commented 2 years ago

So, we need to outsmart that code by overriding it locally, and not including the file_number.

prjemian commented 2 years ago

It's the stage() method of AD_EpicsHdf5FileName() in file apstools.devices.area_detector_support.

So, after importing AD_EpicsHdf5FileName, we make a custom class based on that and write a new version of the stage() method that does everything except write the file_number. Then use that custom class.

@qzhang234 : Up to the challenge of writing that code here?

qzhang234 commented 2 years ago

@prjemian Thanks for the instructions! I have two questions:

prjemian commented 2 years ago

That's the right place to make the addition. Remove the pass at the end of line 102 since we now provide some content. Here's the stage() method: https://github.com/BCDA-APS/apstools/blob/1de05de8603c8a383e3604001d4c59ce2d5b3d61/apstools/devices/area_detector_support.py#L375-L415

This is the line to be changed in myHdf5EpicsIterativeWriter(): https://github.com/BCDA-APS/apstools/blob/1de05de8603c8a383e3604001d4c59ce2d5b3d61/apstools/devices/area_detector_support.py#L406

qzhang234 commented 2 years ago

I see. However would it work if I just copy the entire block of def stage() and modify the line that generates file name in myHdf5EpicsIterativeWriter?

Somehow I feel it would be too good to be true if I can modify the behavior of functions in inherited class that way. Just checking

prjemian commented 2 years ago

That's the way I'd do it.

qzhang234 commented 2 years ago

@prjemian I added the script (see code here) but I'm getting the same error. Looks like the file template is still pointing to the original one in area_detector_support.py so the overwrite did not take into effect.

Any suggestions?

Terminal_Output.txt

prjemian commented 2 years ago

I've got to look at your code. Logging in now.

qzhang234 commented 2 years ago

@prjemian Got it. Let me know if there's anything I can help

prjemian commented 2 years ago

Logged in, looking at /home/beams/8IDIUSER/.ipython-bluesky/profile_bluesky/startup/instrument/devices/ad_eiger.py now. Do not see any new code, only:

class myHdf5EpicsIterativeWriter(AD_EpicsHdf5FileName, FileStoreIterativeWrite):
    pass

at lines 104-5. Where are your changes?

prjemian commented 2 years ago
pearl% git grep file_format
ad_imm_plugins.py:#     file_format = Component(
ad_imm_plugins.py:    # # below is the old file_format to delete
ad_imm_plugins.py:    # # file_format = Component(
ad_imm_plugins.py:    #         if plugin.file_format.get() not in (1, "IMM_Cmprs"):
ad_imm_plugins.py:    #                 plugin.file_format,
ad_imm_plugins.py:    #         if plugin.file_format.get() not in (0, "IMM_Raw"):
ad_imm_plugins.py:    #                 plugin.file_format,
qzhang234 commented 2 years ago

@prjemian Sorry, I removed the change because I wanted to test the diagnostics for the scaler. The permalink in the previous comment should still work, and I just added the code back that overwrite the file template. Could you take a look again?

prjemian commented 2 years ago

Still not seeing any change:

/home/beams/8IDIUSER/.ipython-bluesky/profile_bluesky/startup/instrument
pearl% git grep file_format
devices/ad_imm_plugins.py:#     file_format = Component(
devices/ad_imm_plugins.py:    # # below is the old file_format to delete
devices/ad_imm_plugins.py:    # # file_format = Component(
devices/ad_imm_plugins.py:    #         if plugin.file_format.get() not in (1, "IMM_Cmprs"):
devices/ad_imm_plugins.py:    #                 plugin.file_format,
devices/ad_imm_plugins.py:    #         if plugin.file_format.get() not in (0, "IMM_Raw"):
devices/ad_imm_plugins.py:    #                 plugin.file_format,
qzhang234 commented 2 years ago

Shouldn't it be file_template?

image

prjemian commented 2 years ago

You are correct!

prjemian commented 2 years ago

Like this:

pearl% git grep file_template
devices/ad_eiger.py:        template = self.file_template.get()
devices/ad_eiger.py:        self.hdf1.stage_sigs["file_template"] = "%s%s.h5"
qzhang234 commented 2 years ago

@prjemian … And this version shows the same error (see file attached). I'll comment out this part for tonight and run the long scan test tonight. Would you be able to log in again to take a look sometime tomorrow?

Output_Terminal.txt

qzhang234 commented 2 years ago

Closing this issue for now as it is lower-priority right now. Will reopen after the stability problem #287 is fixed.

prjemian commented 2 years ago

Re-open to save for later.

qzhang234 commented 2 years ago

@prjemian Problem solved today. Closing the issue.