Skip to content

Commit

Permalink
Merge pull request #712 from henrypinkard/main
Browse files Browse the repository at this point in the history
correct fix for python backend
  • Loading branch information
henrypinkard authored Oct 5, 2023
2 parents de3b62a + cb4127e commit 4248193
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pycromanager/acquisition/acq_eng_py/main/acq_notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ def __init__(self, type, id, phase=None):
elif phase in [AcqNotification.Camera.PRE_SNAP, AcqNotification.Camera.POST_EXPOSURE,
AcqNotification.Camera.PRE_SEQUENCE_STARTED]:
self.type = AcqNotification.Camera
self.id = json.loads(id) # convert from '{'time': 5}' to {'time': 5}
self.id = json.loads(id) if isinstance(id, str) else id # convert from '{'time': 5}' to {'time': 5}
elif phase in [AcqNotification.Hardware.PRE_HARDWARE, AcqNotification.Hardware.POST_HARDWARE]:
self.type = AcqNotification.Hardware
self.id = json.loads(id) # convert from '{'time': 5}' to {'time': 5}
self.id = json.loads(id) if isinstance(id, str) else id # convert from '{'time': 5}' to {'time': 5}
elif phase == AcqNotification.Image.IMAGE_SAVED:
self.type = AcqNotification.Image
self.id = id
Expand Down
6 changes: 6 additions & 0 deletions pycromanager/acquisition/python_backend_acquisitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,19 @@ def __init__(
napari_viewer=None,
image_saved_fn: callable=None,
debug: int=False,
# Specificly so the directory arg can be absorbed and ignored without error,
**kwargs
):
# Get a dict of all named argument values (or default values when nothing provided)
arg_names = [k for k in signature(PythonBackendAcquisition.__init__).parameters.keys() if k != 'self']
l = locals()
named_args = {arg_name: (l[arg_name] if arg_name in l else
dict(signature(PythonBackendAcquisition.__init__).parameters.items())[arg_name].default)
for arg_name in arg_names }
if 'kwargs' in named_args:
if 'directory' in named_args['kwargs'] and named_args['kwargs']['directory'] is not None:
raise Exception('The directory argument is not supported in Python backend acquisitions')
del named_args['kwargs']
super().__init__(**named_args)
self._dataset = RAMDataStorage()
self._finished = False
Expand Down
2 changes: 1 addition & 1 deletion scripts/python_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

mm_app_path = r"C:\Users\henry\Micro-Manager-nightly"
config = mm_app_path + r"\MMConfig_demo.cfg"
start_headless(mm_app_path, config, python_backend=False)
start_headless(mm_app_path, config, python_backend=True)

with Acquisition() as acq:
acq.acquire(multi_d_acquisition_events(num_time_points=10))
Expand Down

0 comments on commit 4248193

Please sign in to comment.