From c2a475fe62280a25469232ba4b5b863371af390f Mon Sep 17 00:00:00 2001 From: Henry Pinkard <7969470+henrypinkard@users.noreply.github.com> Date: Thu, 5 Oct 2023 15:13:02 -0700 Subject: [PATCH] correct fix for python backend --- .../acquisition/acq_eng_py/main/acq_notification.py | 4 ++-- pycromanager/acquisition/python_backend_acquisitions.py | 6 ++++++ scripts/python_backend.py | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/pycromanager/acquisition/acq_eng_py/main/acq_notification.py b/pycromanager/acquisition/acq_eng_py/main/acq_notification.py index efed5751..2be866e2 100644 --- a/pycromanager/acquisition/acq_eng_py/main/acq_notification.py +++ b/pycromanager/acquisition/acq_eng_py/main/acq_notification.py @@ -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 diff --git a/pycromanager/acquisition/python_backend_acquisitions.py b/pycromanager/acquisition/python_backend_acquisitions.py index b52e5c6e..a5b4a186 100644 --- a/pycromanager/acquisition/python_backend_acquisitions.py +++ b/pycromanager/acquisition/python_backend_acquisitions.py @@ -29,6 +29,8 @@ 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'] @@ -36,6 +38,10 @@ def __init__( 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 diff --git a/scripts/python_backend.py b/scripts/python_backend.py index 3024e19b..7b3e50a9 100644 --- a/scripts/python_backend.py +++ b/scripts/python_backend.py @@ -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))