haesleinhuepf / napari-assistant

BSD 3-Clause "New" or "Revised" License
20 stars 5 forks source link

Workflow loading throws error when using clesperanto functions #9

Closed haesleinhuepf closed 2 years ago

haesleinhuepf commented 2 years ago

I just tried saving and loading a workflow that containted clesperanto functions.

Loading doesn't work. There is this error instead:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
File c:\structure\code\napari-assistant\napari_assistant\_gui\_Assistant.py:310, in Assistant.load_workflow(self=, filename='C:/structure/code/napari-segment-blobs-and-things-with-membranes/test.yaml')
    307     filename, _ = QFileDialog.getOpenFileName(self, "Import workflow ...", ".", "*.yaml")
    308 self.workflow = _io_yaml_v1.load_workflow(filename)
--> 310 initialise_root_functions(self.workflow,
        self.workflow = 
        self = 
        self._viewer = Viewer(axes=Axes(visible=False, labels=True, colored=True, dashed=False, arrows=True), camera=Camera(center=(29.5, 255.5, 255.5), zoom=1.0557617187500001, angles=(4.790685039054108, -6.611146334177069, 136.73847153098146), perspective=0.0, interactive=True), cursor=Cursor(position=(49.23985573484544, 316.8327878819127, 524.145081062303), scaled=True, size=1, style=), dims=Dims(ndim=3, ndisplay=3, last_used=0, range=((0.0, 60.0, 1.0), (0.0, 256.0, 1.0), (0.0, 256.0, 1.0)), current_step=(30, 128, 128), order=(0, 1, 2), axis_labels=('0', '1', '2')), grid=GridCanvas(stride=-1, shape=(-1, -1), enabled=True), layers=[], scale_bar=ScaleBar(visible=False, colored=False, ticks=True, position=, font_size=10, unit=None), text_overlay=TextOverlay(visible=False, color=(0.5, 0.5, 0.5, 1.0), font_size=10, position=, text=''), overlays=Overlays(interaction_box=InteractionBox(points=None, show=False, show_handle=False, show_vertices=False, selection_box_drag=None, selection_box_final=None, transform_start=, transform_drag=, transform_final=, transform=, allow_new_selection=True, selected_vertex=None)), help='', status='nuclei [ 49 317 524]', tooltip=Tooltip(visible=False, text=''), theme='dark', title='napari', mouse_move_callbacks=[.mouse_move at 0x00000247AA2385E0>], mouse_drag_callbacks=[.mouse_drag at 0x00000247AA226700>], mouse_double_click_callbacks=[], mouse_wheel_callbacks=[], _persisted_mouse_event={}, _mouse_drag_gen={}, _mouse_wheel_gen={}, keymap={'Shift': .hold_to_lock_aspect_ratio at 0x00000247AA226A60>, 'Control-Shift-R': , 'Control-Shift-A': })
    311                           self._viewer)
    312 load_remaining_workflow(workflow=self.workflow,
    313                         viewer=self._viewer)

File c:\structure\code\napari-assistant\napari_assistant\_workflow_io_utility.py:75, in initialise_root_functions(workflow=, viewer=Viewer(axes=Axes(visible=False, labels=True, col...._transform_active_layer at 0x00000247A9B8DEE0>}))
     72     viewer.window.add_dock_widget(widget, name = wf_step_name[10:] + ' - SELECT INPUT')
     74 # calling the widget with the correct input images
---> 75 widget()
        widget =  Union[numpy.ndarray, pyclesperanto_prototype._tier0._pycl.OCLArray, pyopencl._cl.Image, pyclesperanto_prototype._tier0._pycl._OCLImage]>

File ~\miniconda3\envs\bio_39\lib\site-packages\magicgui\widgets\_function_gui.py:293, in FunctionGui.__call__(self=, update_widget=False, *args=(), **kwargs={})
    284     missing = match.groups()[0] if match else ""
    285     msg = (
    286         f"{e} in call to '{self._callable_name}{sig}'.\n"
    287         "To avoid this error, you can bind a value or callback to the "
   (...)
    291         f"    def {self._callable_name}{sig}: ..."
    292     )
--> 293     raise TypeError(msg) from None
        msg = "missing a required argument: 'source' in call to 'gaussian_blur(source: Union[numpy.ndarray, pyclesperanto_prototype._tier0._pycl.OCLArray, pyopencl._cl.Image, pyclesperanto_prototype._tier0._pycl._OCLImage], *, destination: Union[numpy.ndarray, pyclesperanto_prototype._tier0._pycl.OCLArray, pyopencl._cl.Image, pyclesperanto_prototype._tier0._pycl._OCLImage] = None, sigma_x: float = 3.0, sigma_y: float = 3.0, sigma_z: float = 0.0) -> Union[numpy.ndarray, pyclesperanto_prototype._tier0._pycl.OCLArray, pyopencl._cl.Image, pyclesperanto_prototype._tier0._pycl._OCLImage]'.\nTo avoid this error, you can bind a value or callback to the parameter:\n\n    gaussian_blur.source.bind(value)\n\nOr use the 'bind' option in the magicgui decorator:\n\n    @magicgui(source={'bind': value})\n    def gaussian_blur(source: Union[numpy.ndarray, pyclesperanto_prototype._tier0._pycl.OCLArray, pyopencl._cl.Image, pyclesperanto_prototype._tier0._pycl._OCLImage], *, destination: Union[numpy.ndarray, pyclesperanto_prototype._tier0._pycl.OCLArray, pyopencl._cl.Image, pyclesperanto_prototype._tier0._pycl._OCLImage] = None, sigma_x: float = 3.0, sigma_y: float = 3.0, sigma_z: float = 0.0) -> Union[numpy.ndarray, pyclesperanto_prototype._tier0._pycl.OCLArray, pyopencl._cl.Image, pyclesperanto_prototype._tier0._pycl._OCLImage]: ..."
    295 if update_widget:
    296     self._auto_call, before = False, self._auto_call

TypeError: missing a required argument: 'source' in call to 'gaussian_blur(source: Union[numpy.ndarray, pyclesperanto_prototype._tier0._pycl.OCLArray, pyopencl._cl.Image, pyclesperanto_prototype._tier0._pycl._OCLImage], *, destination: Union[numpy.ndarray, pyclesperanto_prototype._tier0._pycl.OCLArray, pyopencl._cl.Image, pyclesperanto_prototype._tier0._pycl._OCLImage] = None, sigma_x: float = 3.0, sigma_y: float = 3.0, sigma_z: float = 0.0) -> Union[numpy.ndarray, pyclesperanto_prototype._tier0._pycl.OCLArray, pyopencl._cl.Image, pyclesperanto_prototype._tier0._pycl._OCLImage]'.
To avoid this error, you can bind a value or callback to the parameter:

    gaussian_blur.source.bind(value)

Or use the 'bind' option in the magicgui decorator:

    @magicgui(source={'bind': value})
    def gaussian_blur(source: Union[numpy.ndarray, pyclesperanto_prototype._tier0._pycl.OCLArray, pyopencl._cl.Image, pyclesperanto_prototype._tier0._pycl._OCLImage], *, destination: Union[numpy.ndarray, pyclesperanto_prototype._tier0._pycl.OCLArray, pyopencl._cl.Image, pyclesperanto_prototype._tier0._pycl._OCLImage] = None, sigma_x: float = 3.0, sigma_y: float = 3.0, sigma_z: float = 0.0) -> Union[numpy.ndarray, pyclesperanto_prototype._tier0._pycl.OCLArray, pyopencl._cl.Image, pyclesperanto_prototype._tier0._pycl._OCLImage]: ...
Cryaaa commented 2 years ago

CLosed with #12