From 8b332c700fb818e6545269097065d0c51ff68a52 Mon Sep 17 00:00:00 2001 From: Grzegorz Bokota Date: Mon, 9 Dec 2024 01:23:23 +0100 Subject: [PATCH] move io plugins from PartSeg to PartSegCore --- launcher.spec | 2 +- package/PartSeg/launcher_main.py | 2 +- package/PartSeg/napari.yaml | 14 ++++++------- .../plugins/napari_io}/__init__.py | 2 +- .../plugins/napari_io}/load_image.py | 2 +- .../plugins/napari_io}/load_mask_project.py | 2 +- .../plugins/napari_io}/load_masked_image.py | 2 +- .../plugins/napari_io}/load_roi_project.py | 2 +- .../plugins/napari_io}/loader.py | 0 .../plugins/napari_io}/save_mask_roi.py | 0 .../plugins/napari_io}/save_tiff_layer.py | 0 .../test_napari_io.py} | 20 +++++++++---------- 12 files changed, 24 insertions(+), 24 deletions(-) rename package/{PartSegCore/napari_plugins => PartSeg/plugins/napari_io}/__init__.py (87%) rename package/{PartSegCore/napari_plugins => PartSeg/plugins/napari_io}/load_image.py (85%) rename package/{PartSegCore/napari_plugins => PartSeg/plugins/napari_io}/load_mask_project.py (83%) rename package/{PartSegCore/napari_plugins => PartSeg/plugins/napari_io}/load_masked_image.py (87%) rename package/{PartSegCore/napari_plugins => PartSeg/plugins/napari_io}/load_roi_project.py (86%) rename package/{PartSegCore/napari_plugins => PartSeg/plugins/napari_io}/loader.py (100%) rename package/{PartSegCore/napari_plugins => PartSeg/plugins/napari_io}/save_mask_roi.py (100%) rename package/{PartSegCore/napari_plugins => PartSeg/plugins/napari_io}/save_tiff_layer.py (100%) rename package/tests/{test_PartSegCore/test_napari_plugins.py => test_PartSeg/test_napari_io.py} (90%) diff --git a/launcher.spec b/launcher.spec index b3d7637bd..7d7aadec2 100644 --- a/launcher.spec +++ b/launcher.spec @@ -90,7 +90,7 @@ hiddenimports = ( "psygnal._weak_callback", "imagecodecs._imagecodecs", "PartSeg.plugins.napari_widgets", - "PartSegCore.napari_plugins", + "PartSegCore.napari_io", ] + [x.module_name for x in imageio_known_plugins.values()] + [x for x in collect_submodules("skimage") if "tests" not in x] diff --git a/package/PartSeg/launcher_main.py b/package/PartSeg/launcher_main.py index 4721a994b..cf4713f5a 100644 --- a/package/PartSeg/launcher_main.py +++ b/package/PartSeg/launcher_main.py @@ -33,7 +33,7 @@ def _test_imports(): # pragma: no cover raise ImportError("napari_widgets not loaded") if "load_image" not in dir(napari_plugins): - raise ImportError("napari_plugins not loaded") + raise ImportError("napari_io not loaded") with suppress(ImportError): from napari.qt import get_app diff --git a/package/PartSeg/napari.yaml b/package/PartSeg/napari.yaml index 08eaafc48..a5ba3fa00 100644 --- a/package/PartSeg/napari.yaml +++ b/package/PartSeg/napari.yaml @@ -4,25 +4,25 @@ contributions: commands: - id: PartSeg.load_roi_project title: Get PartSeg ROI project Reader - python_name: PartSegCore.napari_plugins.load_roi_project:napari_get_reader + python_name: PartSeg.plugins.napari_io.load_roi_project:napari_get_reader - id: PartSeg.load_image title: Get Image Reader - python_name: PartSegCore.napari_plugins.load_image:napari_get_reader + python_name: PartSeg.plugins.napari_io.load_image:napari_get_reader - id: PartSeg.write_tiff_image title: Write tiff Image - python_name: PartSegCore.napari_plugins.save_tiff_layer:napari_write_images + python_name: PartSeg.plugins.napari_io.save_tiff_layer:napari_write_images - id: PartSeg.write_tiff_labels title: Write tiff Labels - python_name: PartSegCore.napari_plugins.save_tiff_layer:napari_write_labels + python_name: PartSeg.plugins.napari_io.save_tiff_layer:napari_write_labels - id: PartSeg.load_mask_project title: Get PartSeg mask project Reader - python_name: PartSegCore.napari_plugins.load_mask_project:napari_get_reader + python_name: PartSeg.plugins.napari_io.load_mask_project:napari_get_reader - id: PartSeg.save_mask_roi title: Write Labels as mask project - python_name: PartSegCore.napari_plugins.save_mask_roi:napari_write_labels + python_name: PartSeg.plugins.napari_io.save_mask_roi:napari_write_labels - id: PartSeg.load_masked_image title: Get Reader for image with mask - python_name: PartSegCore.napari_plugins.load_masked_image:napari_get_reader + python_name: PartSeg.plugins.napari_io.load_masked_image:napari_get_reader - id: PartSeg.SimpleMeasurement title: Create Simple Measurement python_name: PartSeg.plugins.napari_widgets.simple_measurement_widget:SimpleMeasurement diff --git a/package/PartSegCore/napari_plugins/__init__.py b/package/PartSeg/plugins/napari_io/__init__.py similarity index 87% rename from package/PartSegCore/napari_plugins/__init__.py rename to package/PartSeg/plugins/napari_io/__init__.py index 8a61c506e..756d95a00 100644 --- a/package/PartSegCore/napari_plugins/__init__.py +++ b/package/PartSeg/plugins/napari_io/__init__.py @@ -1,4 +1,4 @@ -from PartSegCore.napari_plugins import ( +from PartSeg.plugins.napari_io import ( load_image, load_mask_project, load_masked_image, diff --git a/package/PartSegCore/napari_plugins/load_image.py b/package/PartSeg/plugins/napari_io/load_image.py similarity index 85% rename from package/PartSegCore/napari_plugins/load_image.py rename to package/PartSeg/plugins/napari_io/load_image.py index 19f9a6d61..eda13202f 100644 --- a/package/PartSegCore/napari_plugins/load_image.py +++ b/package/PartSeg/plugins/napari_io/load_image.py @@ -1,7 +1,7 @@ import functools +from PartSeg.plugins.napari_io.loader import partseg_loader from PartSegCore.analysis.load_functions import LoadStackImage -from PartSegCore.napari_plugins.loader import partseg_loader def napari_get_reader(path: str): diff --git a/package/PartSegCore/napari_plugins/load_mask_project.py b/package/PartSeg/plugins/napari_io/load_mask_project.py similarity index 83% rename from package/PartSegCore/napari_plugins/load_mask_project.py rename to package/PartSeg/plugins/napari_io/load_mask_project.py index 9d7b54ecf..49bf709b6 100644 --- a/package/PartSegCore/napari_plugins/load_mask_project.py +++ b/package/PartSeg/plugins/napari_io/load_mask_project.py @@ -1,7 +1,7 @@ import functools +from PartSeg.plugins.napari_io.loader import partseg_loader from PartSegCore.mask.io_functions import LoadROI -from PartSegCore.napari_plugins.loader import partseg_loader def napari_get_reader(path: str): diff --git a/package/PartSegCore/napari_plugins/load_masked_image.py b/package/PartSeg/plugins/napari_io/load_masked_image.py similarity index 87% rename from package/PartSegCore/napari_plugins/load_masked_image.py rename to package/PartSeg/plugins/napari_io/load_masked_image.py index c1d1deaf0..f3acb8dce 100644 --- a/package/PartSegCore/napari_plugins/load_masked_image.py +++ b/package/PartSeg/plugins/napari_io/load_masked_image.py @@ -1,8 +1,8 @@ import functools import os.path +from PartSeg.plugins.napari_io.loader import partseg_loader from PartSegCore.mask.io_functions import LoadStackImageWithMask -from PartSegCore.napari_plugins.loader import partseg_loader def napari_get_reader(path: str): diff --git a/package/PartSegCore/napari_plugins/load_roi_project.py b/package/PartSeg/plugins/napari_io/load_roi_project.py similarity index 86% rename from package/PartSegCore/napari_plugins/load_roi_project.py rename to package/PartSeg/plugins/napari_io/load_roi_project.py index 9fc6fd421..658b9cf09 100644 --- a/package/PartSegCore/napari_plugins/load_roi_project.py +++ b/package/PartSeg/plugins/napari_io/load_roi_project.py @@ -1,8 +1,8 @@ import functools import os.path +from PartSeg.plugins.napari_io.loader import partseg_loader from PartSegCore.analysis.load_functions import LoadProject -from PartSegCore.napari_plugins.loader import partseg_loader def napari_get_reader(path: str): diff --git a/package/PartSegCore/napari_plugins/loader.py b/package/PartSeg/plugins/napari_io/loader.py similarity index 100% rename from package/PartSegCore/napari_plugins/loader.py rename to package/PartSeg/plugins/napari_io/loader.py diff --git a/package/PartSegCore/napari_plugins/save_mask_roi.py b/package/PartSeg/plugins/napari_io/save_mask_roi.py similarity index 100% rename from package/PartSegCore/napari_plugins/save_mask_roi.py rename to package/PartSeg/plugins/napari_io/save_mask_roi.py diff --git a/package/PartSegCore/napari_plugins/save_tiff_layer.py b/package/PartSeg/plugins/napari_io/save_tiff_layer.py similarity index 100% rename from package/PartSegCore/napari_plugins/save_tiff_layer.py rename to package/PartSeg/plugins/napari_io/save_tiff_layer.py diff --git a/package/tests/test_PartSegCore/test_napari_plugins.py b/package/tests/test_PartSeg/test_napari_io.py similarity index 90% rename from package/tests/test_PartSegCore/test_napari_plugins.py rename to package/tests/test_PartSeg/test_napari_io.py index a6e99403f..2ba1f8ff1 100644 --- a/package/tests/test_PartSegCore/test_napari_plugins.py +++ b/package/tests/test_PartSeg/test_napari_io.py @@ -8,20 +8,20 @@ from napari.layers import Image, Labels, Layer from packaging.version import parse as parse_version -from PartSegCore.analysis import ProjectTuple -from PartSegCore.mask.io_functions import LoadROIFromTIFF -from PartSegCore.napari_plugins.load_image import napari_get_reader as napari_get_reader_image -from PartSegCore.napari_plugins.load_mask_project import napari_get_reader as napari_get_reader_mask -from PartSegCore.napari_plugins.load_masked_image import napari_get_reader as napari_get_reader_mask_image -from PartSegCore.napari_plugins.load_roi_project import napari_get_reader as napari_get_reader_roi -from PartSegCore.napari_plugins.loader import project_to_layers -from PartSegCore.napari_plugins.save_mask_roi import napari_write_labels -from PartSegCore.napari_plugins.save_tiff_layer import ( +from PartSeg.plugins.napari_io.load_image import napari_get_reader as napari_get_reader_image +from PartSeg.plugins.napari_io.load_mask_project import napari_get_reader as napari_get_reader_mask +from PartSeg.plugins.napari_io.load_masked_image import napari_get_reader as napari_get_reader_mask_image +from PartSeg.plugins.napari_io.load_roi_project import napari_get_reader as napari_get_reader_roi +from PartSeg.plugins.napari_io.loader import project_to_layers +from PartSeg.plugins.napari_io.save_mask_roi import napari_write_labels +from PartSeg.plugins.napari_io.save_tiff_layer import ( napari_write_images, ) -from PartSegCore.napari_plugins.save_tiff_layer import ( +from PartSeg.plugins.napari_io.save_tiff_layer import ( napari_write_labels as napari_write_labels_tiff, ) +from PartSegCore.analysis import ProjectTuple +from PartSegCore.mask.io_functions import LoadROIFromTIFF from PartSegImage import GenericImageReader from PartSegImage import Image as PImage