haesleinhuepf / napari-workflows

BSD 3-Clause "New" or "Revised" License
12 stars 10 forks source link

loading workflow involving two different datasets fails #36

Open thawn opened 1 year ago

thawn commented 1 year ago

loading the following workflow:

!!python/object:napari_workflows._workflow.Workflow
_tasks:
  Result of Binary fill holes (n-SimpleITK): !!python/tuple
  - !!python/name:napari_simpleitk_image_processing.binary_fill_holes ''
  - Result of dilate_labels (clesperanto)
  Result of Threshold (Huang and Wang 1995, n-SimpleITK): !!python/tuple
  - !!python/name:napari_simpleitk_image_processing.threshold_huang ''
  - Result of top_hat_box (clesperanto)
  Result of dilate_labels (clesperanto): !!python/tuple
  - !!python/name:pyclesperanto_prototype.dilate_labels ''
  - Result of Threshold (Huang and Wang 1995, n-SimpleITK)
  - null
  - 10.0
  Result of gaussian_blur (clesperanto): !!python/tuple
  - !!python/name:pyclesperanto_prototype.gaussian_blur ''
  - Result of maximum_z_projection (clesperanto) [1]
  - null
  - 5.0
  - 5.0
  - 0.0
  Result of maximum_z_projection (clesperanto): !!python/tuple
  - &id001 !!python/name:pyclesperanto_prototype.maximum_z_projection ''
  - '0 :: 20230608_103910_723__Point0001_Channel405_Seq0005.nd2 (series 1) :: 405'
  Result of maximum_z_projection (clesperanto) [1]: !!python/tuple
  - *id001
  - '0 :: 20230608_103910_723__Point0001_Channel488 Sanika_Seq0004.nd2 (series 1)
    :: 488 Sanika'
  Result of seeded_watershed_with_mask: !!python/tuple
  - !!python/name:napari_segment_blobs_and_things_with_membranes.seeded_watershed_with_mask ''
  - Result of subtract_image_from_scalar (clesperanto)
  - Result of voronoi_otsu_labeling (clesperanto)
  - Result of Binary fill holes (n-SimpleITK)
  Result of subtract_image_from_scalar (clesperanto): !!python/tuple
  - !!python/name:pyclesperanto_prototype.subtract_image_from_scalar ''
  - Result of maximum_z_projection (clesperanto) [1]
  - null
  - 65000.0
  Result of top_hat_box (clesperanto): !!python/tuple
  - !!python/name:pyclesperanto_prototype.top_hat_box ''
  - Result of gaussian_blur (clesperanto)
  - null
  - 100.0
  - 100.0
  - 0.0
  Result of voronoi_otsu_labeling (clesperanto): !!python/tuple
  - !!python/name:pyclesperanto_prototype.voronoi_otsu_labeling ''
  - Result of maximum_z_projection (clesperanto)
  - null
  - 20.0
  - 2.0

results in an AttributeError: 'function' object has no attribute '__wrapped__'

full error message
2023-06-22 19:07:03.728 | INFO     | napari_assistant._gui._category_widget:call_op:178 - maximum_z_projection (clesperanto)(..., )
2023-06-22 19:07:04.063 | INFO     | napari_assistant._gui._category_widget:call_op:178 - maximum_z_projection (clesperanto)(..., )
2023-06-22 19:07:04.232 | INFO     | napari_assistant._gui._category_widget:call_op:178 - voronoi_otsu_labeling (clesperanto)(..., 20.0, 2.0)
2023-06-22 19:07:07.314 | INFO     | napari_assistant._gui._category_widget:call_op:178 - gaussian_blur (clesperanto)(..., 5.0, 5.0, 0.0)
2023-06-22 19:07:07.454 | INFO     | napari_assistant._gui._category_widget:call_op:178 - subtract_image_from_scalar (clesperanto)(..., 1.0)
2023-06-22 19:07:07.829 | INFO     | napari_assistant._gui._category_widget:call_op:178 - subtract_image_from_scalar (clesperanto)(..., 65000.0)
2023-06-22 19:07:07.926 | INFO     | napari_assistant._gui._category_widget:call_op:178 - top_hat_box (clesperanto)(..., 100.0, 100.0, 0.0)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
File /opt/homebrew/Caskroom/mambaforge/base/envs/dbn2/lib/python3.9/site-packages/napari_assistant/_gui/_Assistant.py:379, in Assistant.load_workflow(self=, filename='/Users/korten/Documents/Doktorarbeit/Daten-temp/...repro_hackathon_BPAE_cells/cell_segmentation.yaml')
    373 self.workflow = _io_yaml_v1.load_workflow(filename)
    375 w_dw = initialise_root_functions(
    376     self.workflow, 
    377     self._viewer,
    378 )
--> 379 w_dw += load_remaining_workflow(
        w_dw = [(, op_name: str = 'maximum_z_projection (clesperanto)', x: float = 1.0, y: float = 1.0, z: float = 1.0, u: float = 0.0, v: float = 0.0, w: float = 0.0, w1: float = 0.0, w2: float = 0.0, w3: float = 0.0, w4: float = 0.0, a: bool = False, b: bool = False, c: bool = False, d: bool = False, e: bool = False, f: bool = False, g: bool = False, h: bool = False, i: bool = False, j: bool = False, k: str = '', l: str = '', m: str = '', o: Union[pathlib.Path, str, bytes] = PosixPath('.'), p: Union[pathlib.Path, str, bytes] = PosixPath('.'), q: Union[pathlib.Path, str, bytes] = PosixPath('.'), viewer: napari.viewer.Viewer = Viewer(axes=Axes(visible=False, labels=True, colored=True, dashed=False, arrows=True), camera=Camera(center=(0.0, 124.74583333333297, 124.74583333333297), zoom=2.8279246794871877, angles=(0.0, 0.0, 90.0), perspective=0.0, interactive=True), cursor=Cursor(position=(0.0, 5.0, 0.0, 0.0), scaled=True, size=1, style=), dims=Dims(ndim=4, ndisplay=2, last_used=0, range=((0.0, 1.0, 1.0), (0.0, 11.0, 1.0), (0.0, 250.04583333333258, 0.108333333333333), (0.0, 250.04583333333258, 0.108333333333333)), current_step=(0, 5, 1152, 1152), order=(0, 1, 2, 3), axis_labels=('0', '1', '2', '3')), grid=GridCanvas(stride=-1, shape=(-1, -1), enabled=False), layers=[, , , , , , , ], scale_bar=ScaleBar(visible=False, colored=False, color= (4,) float32, ticks=True, position=, font_size=10.0, box=False, box_color= (4,) float32, unit=None), text_overlay=TextOverlay(visible=False, color= (4,) float32, font_size=10.0, 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='Hold  key to open plugin selection. Hold  to open files as stack.', tooltip=Tooltip(visible=False, text=''), theme='dark', title='napari', mouse_over_canvas=False, mouse_move_callbacks=[.mouse_move at 0x154147670>], mouse_drag_callbacks=[.mouse_drag at 0x154135790>], mouse_double_click_callbacks=[], mouse_wheel_callbacks=[], _persisted_mouse_event={}, _mouse_drag_gen={}, _mouse_wheel_gen={}, keymap={'Shift': .hold_to_lock_aspect_ratio at 0x154135af0>, 'Control-Shift-R': , 'Control-Shift-A': }))>, ), (, op_name: str = 'maximum_z_projection (clesperanto)', x: float = 1.0, y: float = 1.0, z: float = 1.0, u: float = 0.0, v: float = 0.0, w: float = 0.0, w1: float = 0.0, w2: float = 0.0, w3: float = 0.0, w4: float = 0.0, a: bool = False, b: bool = False, c: bool = False, d: bool = False, e: bool = False, f: bool = False, g: bool = False, h: bool = False, i: bool = False, j: bool = False, k: str = '', l: str = '', m: str = '', o: Union[pathlib.Path, str, bytes] = PosixPath('.'), p: Union[pathlib.Path, str, bytes] = PosixPath('.'), q: Union[pathlib.Path, str, bytes] = PosixPath('.'), viewer: napari.viewer.Viewer = Viewer(axes=Axes(visible=False, labels=True, colored=True, dashed=False, arrows=True), camera=Camera(center=(0.0, 124.74583333333297, 124.74583333333297), zoom=2.8279246794871877, angles=(0.0, 0.0, 90.0), perspective=0.0, interactive=True), cursor=Cursor(position=(0.0, 5.0, 0.0, 0.0), scaled=True, size=1, style=), dims=Dims(ndim=4, ndisplay=2, last_used=0, range=((0.0, 1.0, 1.0), (0.0, 11.0, 1.0), (0.0, 250.04583333333258, 0.108333333333333), (0.0, 250.04583333333258, 0.108333333333333)), current_step=(0, 5, 1152, 1152), order=(0, 1, 2, 3), axis_labels=('0', '1', '2', '3')), grid=GridCanvas(stride=-1, shape=(-1, -1), enabled=False), layers=[, , , , , , , ], scale_bar=ScaleBar(visible=False, colored=False, color= (4,) float32, ticks=True, position=, font_size=10.0, box=False, box_color= (4,) float32, unit=None), text_overlay=TextOverlay(visible=False, color= (4,) float32, font_size=10.0, 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='Hold  key to open plugin selection. Hold  to open files as stack.', tooltip=Tooltip(visible=False, text=''), theme='dark', title='napari', mouse_over_canvas=False, mouse_move_callbacks=[.mouse_move at 0x154147670>], mouse_drag_callbacks=[.mouse_drag at 0x154135790>], mouse_double_click_callbacks=[], mouse_wheel_callbacks=[], _persisted_mouse_event={}, _mouse_drag_gen={}, _mouse_wheel_gen={}, keymap={'Shift': .hold_to_lock_aspect_ratio at 0x154135af0>, 'Control-Shift-R': , 'Control-Shift-A': }))>, )]
        self.workflow = 
        self = 
        self._viewer = Viewer(axes=Axes(visible=False, labels=True, colored=True, dashed=False, arrows=True), camera=Camera(center=(0.0, 124.74583333333297, 124.74583333333297), zoom=2.8279246794871877, angles=(0.0, 0.0, 90.0), perspective=0.0, interactive=True), cursor=Cursor(position=(0.0, 5.0, 0.0, 0.0), scaled=True, size=1, style=), dims=Dims(ndim=4, ndisplay=2, last_used=0, range=((0.0, 1.0, 1.0), (0.0, 11.0, 1.0), (0.0, 250.04583333333258, 0.108333333333333), (0.0, 250.04583333333258, 0.108333333333333)), current_step=(0, 5, 1152, 1152), order=(0, 1, 2, 3), axis_labels=('0', '1', '2', '3')), grid=GridCanvas(stride=-1, shape=(-1, -1), enabled=False), layers=[, , , , , , , ], scale_bar=ScaleBar(visible=False, colored=False, color= (4,) float32, ticks=True, position=, font_size=10.0, box=False, box_color= (4,) float32, unit=None), text_overlay=TextOverlay(visible=False, color= (4,) float32, font_size=10.0, 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='Hold  key to open plugin selection. Hold  to open files as stack.', tooltip=Tooltip(visible=False, text=''), theme='dark', title='napari', mouse_over_canvas=False, mouse_move_callbacks=[.mouse_move at 0x154147670>], mouse_drag_callbacks=[.mouse_drag at 0x154135790>], mouse_double_click_callbacks=[], mouse_wheel_callbacks=[], _persisted_mouse_event={}, _mouse_drag_gen={}, _mouse_wheel_gen={}, keymap={'Shift': .hold_to_lock_aspect_ratio at 0x154135af0>, 'Control-Shift-R': , 'Control-Shift-A': })
    380     self.workflow, 
    381     self._viewer,
    382 )
    384 for gui, dw in w_dw:
    385     # call the function widget &
    386     # track the association between the layer and the gui that generated it
    387     category = get_category_of_function(
    388         find_function(gui.op_name.current_choice)
    389     )

File /opt/homebrew/Caskroom/mambaforge/base/envs/dbn2/lib/python3.9/site-packages/napari_assistant/_workflow_io_utility.py:164, in load_remaining_workflow(workflow=, viewer=Viewer(axes=Axes(visible=False, labels=True, col...indings._transform_active_layer at 0x1540e0670>}), button_size=40)
    158     widget = make_flexible_gui(func, 
    159                                 viewer,
    160                                 autocall= False,
    161                                 button_size = button_size
    162     )
    163 else:
--> 164     widget = make_flexible_gui(func, 
        func = 
        widget = , op_name: str = 'top_hat_box (clesperanto)', x: float = 100.0, y: float = 100.0, z: float = 0.0, u: float = 0.0, v: float = 0.0, w: float = 0.0, w1: float = 0.0, w2: float = 0.0, w3: float = 0.0, w4: float = 0.0, a: bool = False, b: bool = False, c: bool = False, d: bool = False, e: bool = False, f: bool = False, g: bool = False, h: bool = False, i: bool = False, j: bool = False, k: str = '', l: str = '', m: str = '', o: Union[pathlib.Path, str, bytes] = PosixPath('.'), p: Union[pathlib.Path, str, bytes] = PosixPath('.'), q: Union[pathlib.Path, str, bytes] = PosixPath('.'), viewer: napari.viewer.Viewer = Viewer(axes=Axes(visible=False, labels=True, colored=True, dashed=False, arrows=True), camera=Camera(center=(0.0, 124.74583333333297, 124.74583333333297), zoom=2.8279246794871877, angles=(0.0, 0.0, 90.0), perspective=0.0, interactive=True), cursor=Cursor(position=(0.0, 5.0, 0.0, 0.0), scaled=True, size=1, style=), dims=Dims(ndim=4, ndisplay=2, last_used=0, range=((0.0, 1.0, 1.0), (0.0, 11.0, 1.0), (0.0, 250.04583333333258, 0.108333333333333), (0.0, 250.04583333333258, 0.108333333333333)), current_step=(0, 5, 1152, 1152), order=(0, 1, 2, 3), axis_labels=('0', '1', '2', '3')), grid=GridCanvas(stride=-1, shape=(-1, -1), enabled=False), layers=[, , , , , , , ], scale_bar=ScaleBar(visible=False, colored=False, color= (4,) float32, ticks=True, position=, font_size=10.0, box=False, box_color= (4,) float32, unit=None), text_overlay=TextOverlay(visible=False, color= (4,) float32, font_size=10.0, 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='Hold  key to open plugin selection. Hold  to open files as stack.', tooltip=Tooltip(visible=False, text=''), theme='dark', title='napari', mouse_over_canvas=False, mouse_move_callbacks=[.mouse_move at 0x154147670>], mouse_drag_callbacks=[.mouse_drag at 0x154135790>], mouse_double_click_callbacks=[], mouse_wheel_callbacks=[], _persisted_mouse_event={}, _mouse_drag_gen={}, _mouse_wheel_gen={}, keymap={'Shift': .hold_to_lock_aspect_ratio at 0x154135af0>, 'Control-Shift-R': , 'Control-Shift-A': }))>
        viewer = Viewer(axes=Axes(visible=False, labels=True, colored=True, dashed=False, arrows=True), camera=Camera(center=(0.0, 124.74583333333297, 124.74583333333297), zoom=2.8279246794871877, angles=(0.0, 0.0, 90.0), perspective=0.0, interactive=True), cursor=Cursor(position=(0.0, 5.0, 0.0, 0.0), scaled=True, size=1, style=), dims=Dims(ndim=4, ndisplay=2, last_used=0, range=((0.0, 1.0, 1.0), (0.0, 11.0, 1.0), (0.0, 250.04583333333258, 0.108333333333333), (0.0, 250.04583333333258, 0.108333333333333)), current_step=(0, 5, 1152, 1152), order=(0, 1, 2, 3), axis_labels=('0', '1', '2', '3')), grid=GridCanvas(stride=-1, shape=(-1, -1), enabled=False), layers=[, , , , , , , ], scale_bar=ScaleBar(visible=False, colored=False, color= (4,) float32, ticks=True, position=, font_size=10.0, box=False, box_color= (4,) float32, unit=None), text_overlay=TextOverlay(visible=False, color= (4,) float32, font_size=10.0, 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='Hold  key to open plugin selection. Hold  to open files as stack.', tooltip=Tooltip(visible=False, text=''), theme='dark', title='napari', mouse_over_canvas=False, mouse_move_callbacks=[.mouse_move at 0x154147670>], mouse_drag_callbacks=[.mouse_drag at 0x154135790>], mouse_double_click_callbacks=[], mouse_wheel_callbacks=[], _persisted_mouse_event={}, _mouse_drag_gen={}, _mouse_wheel_gen={}, keymap={'Shift': .hold_to_lock_aspect_ratio at 0x154135af0>, 'Control-Shift-R': , 'Control-Shift-A': })
        button_size = 40
    165                                 viewer, 
    166                                 button_size = button_size
    167     )
    168     widget._auto_call = False
    169 # add the final widget to the napari viewer and set the input images in
    170 # the dropdown to the specified input images

File /opt/homebrew/Caskroom/mambaforge/base/envs/dbn2/lib/python3.9/site-packages/napari_assistant/_workflow_io_utility.py:224, in make_flexible_gui(func=, viewer=Viewer(axes=Axes(visible=False, labels=True, col...indings._transform_active_layer at 0x1540e0670>}), autocall=True, button_size=40)
    206 """
    207 Function returns a widget with a GUI for the function provided in the parameters,
    208 that can be added to the napari viewer.
   (...)
    221     button size parameter that is passed to make_category_gui
    222 """
    223 gui = None
--> 224 category = get_category_of_function(func)
        func = 
    226 if category is None:
    227     raise ModuleNotFoundError("Cannot build user interface for not installed function " + str(func))

File /opt/homebrew/Caskroom/mambaforge/base/envs/dbn2/lib/python3.9/site-packages/napari_assistant/_categories.py:595, in get_category_of_function(func=, func_name=None)
    589 """
    590 Searches categories for a given function and returns the first (!)
    591 category that contains the function
    592 """
    594 if func_name is None:
--> 595     func_name = get_name_of_function(func)
        func_name = None
        func = 
    597 for k, c in CATEGORIES.items():
    598     if not callable(c):

File /opt/homebrew/Caskroom/mambaforge/base/envs/dbn2/lib/python3.9/site-packages/napari_assistant/_categories.py:367, in get_name_of_function(func=)
    362 """
    363 Searches all functions for a given function
    364 and returns its human-readable name
    365 """
    366 for k, v in all_operations().items():
--> 367     if v is func or v.__wrapped__ is func:
        v = 
        v is func = False
        func = 
    368         if ">" in k:
    369             return k.split(">")[1]

AttributeError: 'function' object has no attribute '__wrapped__'