aps-8id-dys / ipython-8idiuser

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

lambdadet.stage() does not work #275

Closed qzhang234 closed 2 years ago

qzhang234 commented 3 years ago

I tried to run AD_Acquire after changing the imm1 plugin and run into a crash. Upon some inspection, it seems like the crash was caused by lambdadet.stage(). More specifically, the line that causes the crash is super().stage().

In that vein, I noticed that lambdadet.imm1.stage_sigs was properly defined, however lambdadet.stage_sigs itself is empty. Could this be the root of the staging problem?

Any pointers would be extremely helpful.

Terminal output ``` In [18]: lambdadet.staging_setup_DM?? In [19]: lambdadet.staging_setup_DM('/home/8ididata/2021-2/rigaku202108', 'A001', 100, 0.1, 0.11) In [20]: lambdadet.stage_sigs Out[20]: OrderedDict() In [21]: lambdadet.imm1.stage_sigs Out[21]: OrderedDict([('enable', 1), ('blocking_callbacks', 'Yes'), ('parent.cam.array_callbacks', 1), ('file_path', '/data/2021-2/rigaku202108'), ('file_name', 'A001'), ('num_capture', 100), ('file_number', 1), ('file_format', 'IMM_Cmprs'), ('capture', 1)]) In [22]: In [22]: In [22]: In [22]: lambdadet.unstage() Out[22]: [StatsLocal(prefix='8LAMBDA1:Stats1:', name='lambdadet_stats1', parent='lambdadet', read_attrs=[], configuration_attrs=['mean_value']), Lambda750kCamLocal(prefix='8LAMBDA1:cam1:', name='lambdadet_cam', parent='lambdadet', read_attrs=['num_images'], configuration_attrs=['acquire', 'acquire_period', 'acquire_time', 'array_callbacks', 'bad_frame_counter', 'config_file_path', 'data_type', 'firmware_version', 'image_mode', 'operating_mode', 'serial_number', 'detector_state', 'state', 'status_msg', 'temperature', 'trigger_mode', 'array_size_x', 'array_size_y']), IMMnLocal(prefix='8LAMBDA1:IMM1:', name='lambdadet_imm1', parent='lambdadet', read_attrs=['num_captured'], configuration_attrs=['capture', 'file_format']), Lambda750kLocal(prefix='8LAMBDA1:', name='lambdadet', read_attrs=['imm1', 'imm1.num_captured', 'cam', 'cam.num_images', 'stats1', 'image'], configuration_attrs=['imm1', 'imm1.capture', 'imm1.file_format', 'cam', 'cam.acquire', 'cam.acquire_period', 'cam.acquire_time', 'cam.array_callbacks', 'cam.bad_frame_counter', 'cam.config_file_path', 'cam.data_type', 'cam.firmware_version', 'cam.image_mode', 'cam.operating_mode', 'cam.serial_number', 'cam.detector_state', 'cam.state', 'cam.status_msg', 'cam.temperature', 'cam.trigger_mode', 'cam.array_size_x', 'cam.array_size_y', 'stats1', 'stats1.mean_value'])] In [23]: In [23]: In [23]: lambdadet.stage() --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) in ----> 1 lambdadet.stage() ~/.ipython-bluesky/profile_bluesky/startup/instrument/devices/lambda_750k.py in stage(self) 403 404 def stage(self): --> 405 super().stage() 406 root = os.path.join("/", "home", "8ididata/") 407 print(root) ~/.conda/envs/bluesky_2021_1/lib/python3.8/site-packages/ophyd/device.py in stage(self) 557 device = getattr(self, attr) 558 if hasattr(device, 'stage'): --> 559 device.stage() 560 devices_staged.append(device) 561 except Exception: ~/.conda/envs/bluesky_2021_1/lib/python3.8/site-packages/ophyd/device.py in stage(self) 530 if isinstance(k, str): 531 # Device.__getattr__ handles nested attr lookup --> 532 stage_sigs[getattr(self, k)] = v 533 else: 534 stage_sigs[k] = v ~/.conda/envs/bluesky_2021_1/lib/python3.8/site-packages/ophyd/device.py in __getattr__(self, name) 1195 # Components will be instantiated through the descriptor mechanism in 1196 # the Component class, so anything reaching this point is an error. -> 1197 raise AttributeError(name) 1198 1199 def _instantiate_component(self, attr): AttributeError: enable In [24]: ```
qzhang234 commented 3 years ago

I'm on branch 274-imm1-plugin-change by the way and I just pushed my most recent changes.

prjemian commented 3 years ago

The empty lambdadet.stage_sigs dictionary is not the problem. The lambdadet.imm1.stage() method is failing on the attribute enable. You can test this by typing this command:

lambdadet.imm1.stage()

which, if it behaves as shown above, will raise an AttributeError on the enable attribute.

What do these commands return?

print(f"{lambdadet.imm1.enable.get() = }")
print(f"{lambdadet.imm1.enable.enum_strs = }")
prjemian commented 3 years ago

stage_sigs set here: https://github.com/aps-8id-dys/ipython-8idiuser/blob/0c0f6450d2565c16e41c2f842606aadfdbb6565d/profile_bluesky/startup/instrument/devices/lambda_750k.py#L394

The enable Component attribute is defined here: https://github.com/aps-8id-dys/ipython-8idiuser/blob/0c0f6450d2565c16e41c2f842606aadfdbb6565d/profile_bluesky/startup/instrument/devices/ad_imm_plugins.py#L51-L53

qzhang234 commented 3 years ago

@prjemian Here are the terminal outputs from staging and enable. lambdadet.imm1.stage() does not return an error, but lambdadet.imm1.stage_sigs is empty, which I believe is the reason for the error when trying to inquire attribute imm1.enable.

Bluesky terminal output ``` In [1]: In [1]: In [1]: pwd Out[1]: '/home/beams10/8IDIUSER/bluesky_data/2021/2021-2' In [2]: In [2]: lambdadet.imm1.unstage() Out[2]: [IMMnLocal(prefix='8LAMBDA1:IMM1:', name='lambdadet_imm1', parent='lambdadet', read_attrs=['num_captured'], configuration_attrs=['capture', 'file_format'])] In [3]: lambdadet.imm1.stage() Out[3]: [IMMnLocal(prefix='8LAMBDA1:IMM1:', name='lambdadet_imm1', parent='lambdadet', read_attrs=['num_captured'], configuration_attrs=['capture', 'file_format'])] In [4]: In [4]: print(f"{lambdadet.imm1.enable.get() = }") --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) in ----> 1 print(f"{lambdadet.imm1.enable.get() = }") ~/.conda/envs/bluesky_2021_1/lib/python3.8/site-packages/ophyd/device.py in __getattr__(self, name) 1195 # Components will be instantiated through the descriptor mechanism in 1196 # the Component class, so anything reaching this point is an error. -> 1197 raise AttributeError(name) 1198 1199 def _instantiate_component(self, attr): AttributeError: enable In [5]: print(f"{lambdadet.imm1.enable.enum_strs = }") --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) in ----> 1 print(f"{lambdadet.imm1.enable.enum_strs = }") ~/.conda/envs/bluesky_2021_1/lib/python3.8/site-packages/ophyd/device.py in __getattr__(self, name) 1195 # Components will be instantiated through the descriptor mechanism in 1196 # the Component class, so anything reaching this point is an error. -> 1197 raise AttributeError(name) 1198 1199 def _instantiate_component(self, attr): AttributeError: enable In [6]: print(lambdadet.imm1.stage_sigs) OrderedDict() In [7]: ```
prjemian commented 3 years ago

So there is lambdadet.imm1.enable attribute, that's what this says. Why?

qzhang234 commented 3 years ago

Sorry I don't know enough to answer this question. What does enable do? And is the imm plugin lambdadet.imm1 not supposed to have the enable attribute?

qzhang234 commented 3 years ago

@prjemian I modified the self._file_path part in lambda_750k.py, and now the error from lambdadet.stage() has changed. For some reason during staging process, it is trying to write to 8LAMBDA1:IMM1:FilePath_RBV, which is a readback value.

Any suggestions?

Terminal output ``` In [1]: lambdadet.staging_setup_DM('/home/8ididata/2021-2/rigaku202108', 'A001', 100, 0.1, 0.11) In [2]: lambdadet.unstage() Out[2]: [StatsLocal(prefix='8LAMBDA1:Stats1:', name='lambdadet_stats1', parent='lambdadet', read_attrs=[], configuration_attrs=['mean_value']), Lambda750kCamLocal(prefix='8LAMBDA1:cam1:', name='lambdadet_cam', parent='lambdadet', read_attrs=['num_images'], configuration_attrs=['acquire', 'acquire_period', 'acquire_time', 'array_callbacks', 'bad_frame_counter', 'config_file_path', 'data_type', 'firmware_version', 'image_mode', 'operating_mode', 'serial_number', 'detector_state', 'state', 'status_msg', 'temperature', 'trigger_mode', 'array_size_x', 'array_size_y']), IMMoutLocal(prefix='8LAMBDA1:IMM1:', name='lambdadet_imm1', parent='lambdadet', read_attrs=['num_captured', 'unique_id'], configuration_attrs=['auto_increment', 'blocking_callbacks', 'capture', 'enable', 'file_name', 'file_number', 'file_path', 'num_capture', 'num_pixels']), Lambda750kLocal(prefix='8LAMBDA1:', name='lambdadet', read_attrs=['imm1', 'imm1.num_captured', 'imm1.unique_id', 'cam', 'cam.num_images', 'stats1', 'image'], configuration_attrs=['imm1', 'imm1.auto_increment', 'imm1.blocking_callbacks', 'imm1.capture', 'imm1.enable', 'imm1.file_name', 'imm1.file_number', 'imm1.file_path', 'imm1.num_capture', 'imm1.num_pixels', 'cam', 'cam.acquire', 'cam.acquire_period', 'cam.acquire_time', 'cam.array_callbacks', 'cam.bad_frame_counter', 'cam.config_file_path', 'cam.data_type', 'cam.firmware_version', 'cam.image_mode', 'cam.operating_mode', 'cam.serial_number', 'cam.detector_state', 'cam.state', 'cam.status_msg', 'cam.temperature', 'cam.trigger_mode', 'cam.array_size_x', 'cam.array_size_y', 'stats1', 'stats1.mean_value'])] In [3]: lambdadet.stage() --------------------------------------------------------------------------- TimeoutError Traceback (most recent call last) in ----> 1 lambdadet.stage() ~/.ipython-bluesky/profile_bluesky/startup/instrument/devices/lambda_750k.py in stage(self) 403 404 def stage(self): --> 405 super().stage() 406 root = os.path.join("/", "home", "8ididata/") 407 print(root) ~/.conda/envs/bluesky_2021_1/lib/python3.8/site-packages/ophyd/device.py in stage(self) 557 device = getattr(self, attr) 558 if hasattr(device, 'stage'): --> 559 device.stage() 560 devices_staged.append(device) 561 except Exception: ~/.conda/envs/bluesky_2021_1/lib/python3.8/site-packages/ophyd/device.py in stage(self) 548 self.name, 549 val, original_vals[sig]) --> 550 set_and_wait(sig, val) 551 # It worked -- now add it to this list of sigs to unstage. 552 self._original_vals[sig] = original_vals[sig] ~/.conda/envs/bluesky_2021_1/lib/python3.8/site-packages/ophyd/utils/epics_pvs.py in set_and_wait(signal, val, poll_time, timeout, rtol, atol) 263 current_value = signal.get() 264 if expiration_time is not None and ttime.time() > expiration_time: --> 265 raise TimeoutError("Attempted to set %r to value %r and timed " 266 "out after %r seconds. Current value is %r." % 267 (signal, val, timeout, current_value)) TimeoutError: Attempted to set EpicsSignalWithRBV(read_pv='8LAMBDA1:IMM1:FilePath_RBV', name='lambdadet_imm1_file_path', parent='lambdadet_imm1', value='/home/8ididata/2021-2/rigaku202108/', timestamp=1631084519.440673, auto_monitor=True, string=True, write_pv='8LAMBDA1:IMM1:FilePath', limits=False, put_complete=False) to value '/home/8ididata/2021-2/rigaku202108' and timed out after 10 seconds. Current value is '/home/8ididata/2021-2/rigaku202108/'. In [4]: !ls /home/8ididata/2021-2/rigaku202108/ A121_00001_att00_Test A123_00001_att00_Test A124_00002_att00_Test A125_00003_att00_Test A127_00001_att00_Test deleteme.txt A121_00002_att00_Test A123_00002_att00_Test A124_00003_att00_Test A126_00001_att00_Test A127_00002_att00_Test A121_00003_att00_Test A123_00003_att00_Test A125_00001_att00_Test A126_00002_att00_Test A127_00003_att00_Test A122_00001_att00_Test A124_00001_att00_Test A125_00002_att00_Test A126_00003_att00_Test cluster_results In [5]: ```
qzhang234 commented 3 years ago

@prjemian Never mind, I missed a / after rigaku202108. After fixing that, lambdadet.stage() works without error. The issue is now resolved.

I pushed the most recent code.

Should I close the issue or should I wait after you resolve the lua issue?

Terminal output ``` In [10]: In [10]: lambdadet.unstage() Out[10]: [StatsLocal(prefix='8LAMBDA1:Stats1:', name='lambdadet_stats1', parent='lambdadet', read_attrs=[], configuration_attrs=['mean_value']), Lambda750kCamLocal(prefix='8LAMBDA1:cam1:', name='lambdadet_cam', parent='lambdadet', read_attrs=['num_images'], configuration_attrs=['acquire', 'acquire_period', 'acquire_time', 'array_callbacks', 'bad_frame_counter', 'config_file_path', 'data_type', 'firmware_version', 'image_mode', 'operating_mode', 'serial_number', 'detector_state', 'state', 'status_msg', 'temperature', 'trigger_mode', 'array_size_x', 'array_size_y']), IMMoutLocal(prefix='8LAMBDA1:IMM1:', name='lambdadet_imm1', parent='lambdadet', read_attrs=['num_captured', 'unique_id'], configuration_attrs=['auto_increment', 'blocking_callbacks', 'capture', 'enable', 'file_name', 'file_number', 'file_path', 'num_capture', 'num_pixels']), Lambda750kLocal(prefix='8LAMBDA1:', name='lambdadet', read_attrs=['imm1', 'imm1.num_captured', 'imm1.unique_id', 'cam', 'cam.num_images', 'stats1', 'image'], configuration_attrs=['imm1', 'imm1.auto_increment', 'imm1.blocking_callbacks', 'imm1.capture', 'imm1.enable', 'imm1.file_name', 'imm1.file_number', 'imm1.file_path', 'imm1.num_capture', 'imm1.num_pixels', 'cam', 'cam.acquire', 'cam.acquire_period', 'cam.acquire_time', 'cam.array_callbacks', 'cam.bad_frame_counter', 'cam.config_file_path', 'cam.data_type', 'cam.firmware_version', 'cam.image_mode', 'cam.operating_mode', 'cam.serial_number', 'cam.detector_state', 'cam.state', 'cam.status_msg', 'cam.temperature', 'cam.trigger_mode', 'cam.array_size_x', 'cam.array_size_y', 'stats1', 'stats1.mean_value'])] In [11]: In [11]: lambdadet.stage() /home/8ididata/ /home/8ididata/2021-2/rigaku202108/A001_00000-00000.imm In [12]: lambdadet.imm1.enable.get() Out[12]: 'Enable' In [13]: ```
qzhang234 commented 2 years ago

This issue is no longer relevant