From e7581a38ae36a14e2f154c062000c1b0c0a547bb Mon Sep 17 00:00:00 2001 From: James Lamb Date: Mon, 26 Feb 2024 17:18:57 -0600 Subject: [PATCH 1/5] Add support for Python 3.11. --- benchmarks/skimage/_image_bench.py | 1 - benchmarks/skimage/bench_convolve.py | 3 +-- benchmarks/skimage/cucim_color_bench.py | 5 ++--- benchmarks/skimage/cucim_exposure_bench.py | 5 ++--- benchmarks/skimage/cucim_feature_bench.py | 7 +++---- benchmarks/skimage/cucim_filters_bench.py | 5 ++--- benchmarks/skimage/cucim_measure_bench.py | 5 ++--- benchmarks/skimage/cucim_metrics_bench.py | 5 ++--- benchmarks/skimage/cucim_morphology_bench.py | 5 ++--- benchmarks/skimage/cucim_registration_bench.py | 5 ++--- benchmarks/skimage/cucim_restoration_bench.py | 7 +++---- benchmarks/skimage/cucim_segmentation_bench.py | 3 +-- benchmarks/skimage/cucim_transform_bench.py | 5 ++--- ci/wheel_smoke_test.py | 4 +--- dependencies.yaml | 4 ++++ examples/python/distance_transform_edt_demo.py | 3 +-- examples/python/gds_whole_slide/benchmark_round_trip.py | 5 ++--- examples/python/gds_whole_slide/benchmark_zarr_write.py | 3 +-- examples/python/gds_whole_slide/demo_implementation.py | 3 +-- examples/python/tiff_image/main.py | 3 +-- experiments/Supporting_Aperio_SVS_Format/benchmark.py | 3 +-- experiments/Using_Cache/benchmark.py | 3 +-- 22 files changed, 37 insertions(+), 55 deletions(-) diff --git a/benchmarks/skimage/_image_bench.py b/benchmarks/skimage/_image_bench.py index 9d55c6be0..abb2ffbbb 100644 --- a/benchmarks/skimage/_image_bench.py +++ b/benchmarks/skimage/_image_bench.py @@ -12,7 +12,6 @@ import pandas as pd import scipy.ndimage import skimage.data - from cucim.time import repeat diff --git a/benchmarks/skimage/bench_convolve.py b/benchmarks/skimage/bench_convolve.py index f44714306..a43636931 100644 --- a/benchmarks/skimage/bench_convolve.py +++ b/benchmarks/skimage/bench_convolve.py @@ -3,8 +3,6 @@ """ import cupy as cp import cupyx.scipy.ndimage as ndi -from cupyx.profiler import benchmark - from cucim.skimage._vendored.ndimage import ( # noqa: F401 convolve1d, correlate1d, @@ -18,6 +16,7 @@ uniform_filter, uniform_filter1d, ) +from cupyx.profiler import benchmark d = cp.cuda.Device() diff --git a/benchmarks/skimage/cucim_color_bench.py b/benchmarks/skimage/cucim_color_bench.py index b9886d2b8..8f394daef 100644 --- a/benchmarks/skimage/cucim_color_bench.py +++ b/benchmarks/skimage/cucim_color_bench.py @@ -2,6 +2,8 @@ import os import pickle +import cucim.skimage +import cucim.skimage.color import cupy import cupy as cp import cupyx.scipy.ndimage @@ -12,9 +14,6 @@ import skimage.color from _image_bench import ImageBench -import cucim.skimage -import cucim.skimage.color - func_name_choices = [ "convert_colorspace", "rgb2hed", diff --git a/benchmarks/skimage/cucim_exposure_bench.py b/benchmarks/skimage/cucim_exposure_bench.py index 317c4efe6..558a2282f 100644 --- a/benchmarks/skimage/cucim_exposure_bench.py +++ b/benchmarks/skimage/cucim_exposure_bench.py @@ -2,6 +2,8 @@ import os import pickle +import cucim.skimage +import cucim.skimage.exposure import cupy import cupy as cp import numpy as np @@ -10,9 +12,6 @@ import skimage.exposure from _image_bench import ImageBench -import cucim.skimage -import cucim.skimage.exposure - class ExposureBench(ImageBench): def set_args(self, dtype): diff --git a/benchmarks/skimage/cucim_feature_bench.py b/benchmarks/skimage/cucim_feature_bench.py index b390f02e6..4142d7965 100644 --- a/benchmarks/skimage/cucim_feature_bench.py +++ b/benchmarks/skimage/cucim_feature_bench.py @@ -3,17 +3,16 @@ import os import pickle +import cucim.skimage +import cucim.skimage.feature import cupy as cp import numpy as np import pandas as pd import skimage import skimage.feature from _image_bench import ImageBench -from skimage import data, draw - -import cucim.skimage -import cucim.skimage.feature from cucim.skimage import exposure +from skimage import data, draw class BlobDetectionBench(ImageBench): diff --git a/benchmarks/skimage/cucim_filters_bench.py b/benchmarks/skimage/cucim_filters_bench.py index 9dcbf2867..09a47e346 100644 --- a/benchmarks/skimage/cucim_filters_bench.py +++ b/benchmarks/skimage/cucim_filters_bench.py @@ -2,15 +2,14 @@ import os import pickle +import cucim.skimage +import cucim.skimage.filters import numpy as np import pandas as pd import skimage import skimage.filters from _image_bench import ImageBench -import cucim.skimage -import cucim.skimage.filters - def main(args): pfile = "cucim_filters_results.pickle" diff --git a/benchmarks/skimage/cucim_measure_bench.py b/benchmarks/skimage/cucim_measure_bench.py index 15ec470ce..e7e7b40df 100644 --- a/benchmarks/skimage/cucim_measure_bench.py +++ b/benchmarks/skimage/cucim_measure_bench.py @@ -3,6 +3,8 @@ import os import pickle +import cucim.skimage +import cucim.skimage.measure import cupy as cp import numpy as np import pandas as pd @@ -11,9 +13,6 @@ from _image_bench import ImageBench from cucim_metrics_bench import MetricsBench -import cucim.skimage -import cucim.skimage.measure - class LabelBench(ImageBench): def __init__( diff --git a/benchmarks/skimage/cucim_metrics_bench.py b/benchmarks/skimage/cucim_metrics_bench.py index 8ac43a086..585dd7be8 100644 --- a/benchmarks/skimage/cucim_metrics_bench.py +++ b/benchmarks/skimage/cucim_metrics_bench.py @@ -2,15 +2,14 @@ import os import pickle +import cucim.skimage +import cucim.skimage.metrics import cupy as cp import numpy as np import pandas as pd import skimage import skimage.metrics from _image_bench import ImageBench - -import cucim.skimage -import cucim.skimage.metrics from cucim.skimage import data, measure diff --git a/benchmarks/skimage/cucim_morphology_bench.py b/benchmarks/skimage/cucim_morphology_bench.py index 47658e502..aeab0e142 100644 --- a/benchmarks/skimage/cucim_morphology_bench.py +++ b/benchmarks/skimage/cucim_morphology_bench.py @@ -6,6 +6,8 @@ import os import pickle +import cucim.skimage +import cucim.skimage.morphology import cupy as cp import numpy as np import pandas as pd @@ -15,9 +17,6 @@ import skimage.morphology from _image_bench import ImageBench -import cucim.skimage -import cucim.skimage.morphology - class BinaryMorphologyBench(ImageBench): def __init__( diff --git a/benchmarks/skimage/cucim_registration_bench.py b/benchmarks/skimage/cucim_registration_bench.py index 86070ecb5..be5b94594 100644 --- a/benchmarks/skimage/cucim_registration_bench.py +++ b/benchmarks/skimage/cucim_registration_bench.py @@ -3,6 +3,8 @@ import os import pickle +import cucim.skimage +import cucim.skimage.registration import cupy as cp import numpy as np import pandas as pd @@ -10,9 +12,6 @@ import skimage.registration from _image_bench import ImageBench -import cucim.skimage -import cucim.skimage.registration - class RegistrationBench(ImageBench): def set_args(self, dtype): diff --git a/benchmarks/skimage/cucim_restoration_bench.py b/benchmarks/skimage/cucim_restoration_bench.py index 064b9a068..c876cae12 100644 --- a/benchmarks/skimage/cucim_restoration_bench.py +++ b/benchmarks/skimage/cucim_restoration_bench.py @@ -3,6 +3,8 @@ import os import pickle +import cucim.skimage +import cucim.skimage.restoration import cupy as cp import cupyx.scipy.ndimage as ndi import numpy as np @@ -10,11 +12,8 @@ import skimage import skimage.restoration from _image_bench import ImageBench -from skimage.restoration import denoise_tv_chambolle as tv_cpu - -import cucim.skimage -import cucim.skimage.restoration from cucim.skimage.restoration import denoise_tv_chambolle as tv_gpu +from skimage.restoration import denoise_tv_chambolle as tv_cpu class DenoiseBench(ImageBench): diff --git a/benchmarks/skimage/cucim_segmentation_bench.py b/benchmarks/skimage/cucim_segmentation_bench.py index fcba7073c..77bbae630 100644 --- a/benchmarks/skimage/cucim_segmentation_bench.py +++ b/benchmarks/skimage/cucim_segmentation_bench.py @@ -3,14 +3,13 @@ import os import pickle +import cucim.skimage import cupy as cp import numpy as np import pandas as pd import skimage import skimage.segmentation from _image_bench import ImageBench - -import cucim.skimage from cucim.skimage import data, measure diff --git a/benchmarks/skimage/cucim_transform_bench.py b/benchmarks/skimage/cucim_transform_bench.py index 3d64d60d3..6cc007af9 100644 --- a/benchmarks/skimage/cucim_transform_bench.py +++ b/benchmarks/skimage/cucim_transform_bench.py @@ -2,15 +2,14 @@ import os import pickle +import cucim.skimage +import cucim.skimage.transform import numpy as np import pandas as pd import skimage import skimage.transform from _image_bench import ImageBench -import cucim.skimage -import cucim.skimage.transform - def main(args): pfile = "cucim_transform_results.pickle" diff --git a/ci/wheel_smoke_test.py b/ci/wheel_smoke_test.py index e86a8888e..5311c6a96 100644 --- a/ci/wheel_smoke_test.py +++ b/ci/wheel_smoke_test.py @@ -1,8 +1,6 @@ -import cupy as cp - import cucim import cucim.skimage - +import cupy as cp if __name__ == "__main__": # verify that all top-level modules are available diff --git a/dependencies.yaml b/dependencies.yaml index 2c9159c50..fa72cb440 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -233,6 +233,10 @@ dependencies: py: "3.10" packages: - python=3.10 + - matrix: + py: "3.11" + packages: + - python=3.11 - matrix: packages: - python>=3.8,<3.11 diff --git a/examples/python/distance_transform_edt_demo.py b/examples/python/distance_transform_edt_demo.py index 405cd0f23..d9813b2f4 100644 --- a/examples/python/distance_transform_edt_demo.py +++ b/examples/python/distance_transform_edt_demo.py @@ -10,11 +10,10 @@ print("This demo requires the matplotlib and colorcet packages.") raise (e) -from skimage import data - from cucim.core.operations.morphology import distance_transform_edt from cucim.skimage.color import label2rgb from cucim.skimage.segmentation import relabel_sequential +from skimage import data def coords_to_labels(coords): diff --git a/examples/python/gds_whole_slide/benchmark_round_trip.py b/examples/python/gds_whole_slide/benchmark_round_trip.py index 21f4ec278..2335e73a0 100644 --- a/examples/python/gds_whole_slide/benchmark_round_trip.py +++ b/examples/python/gds_whole_slide/benchmark_round_trip.py @@ -1,16 +1,15 @@ import os from time import time +import cucim.skimage.filters import cupy as cp import kvikio import kvikio.defaults import numpy as np +from cucim.core.operations.color import image_to_absorbance from cupyx.profiler import benchmark from demo_implementation import cupy_to_zarr, read_tiled -import cucim.skimage.filters -from cucim.core.operations.color import image_to_absorbance - data_dir = os.environ.get("WHOLE_SLIDE_DATA_DIR", os.path.dirname("__file__")) fname = os.path.join(data_dir, "resize.tiff") if not os.path.exists(fname): diff --git a/examples/python/gds_whole_slide/benchmark_zarr_write.py b/examples/python/gds_whole_slide/benchmark_zarr_write.py index 13376f410..f1f4a021b 100644 --- a/examples/python/gds_whole_slide/benchmark_zarr_write.py +++ b/examples/python/gds_whole_slide/benchmark_zarr_write.py @@ -4,12 +4,11 @@ import cupy as cp import kvikio.defaults import numpy as np +from cucim.core.operations.color import image_to_absorbance from cupyx.profiler import benchmark from demo_implementation import cupy_to_zarr, get_n_tiles, read_tiled from tifffile import TiffFile -from cucim.core.operations.color import image_to_absorbance - data_dir = os.environ.get("WHOLE_SLIDE_DATA_DIR", os.path.dirname("__file__")) fname = os.path.join(data_dir, "resize.tiff") if not os.path.exists(fname): diff --git a/examples/python/gds_whole_slide/demo_implementation.py b/examples/python/gds_whole_slide/demo_implementation.py index 7d02c8407..89cb69342 100644 --- a/examples/python/gds_whole_slide/demo_implementation.py +++ b/examples/python/gds_whole_slide/demo_implementation.py @@ -8,14 +8,13 @@ import numpy as np import openslide import tifffile +from cucim.clara import filesystem from kvikio.cufile import IOFuture from kvikio.zarr import GDSStore from tifffile import TiffFile from zarr import DirectoryStore from zarr.creation import init_array -from cucim.clara import filesystem - """ Developed with Dask 2022.05.2 zarr >= 2.13.2 diff --git a/examples/python/tiff_image/main.py b/examples/python/tiff_image/main.py index c36149a9e..42adf36e0 100644 --- a/examples/python/tiff_image/main.py +++ b/examples/python/tiff_image/main.py @@ -16,9 +16,8 @@ import json import numpy as np -from PIL import Image - from cucim import CuImage +from PIL import Image img = CuImage("image.tif") diff --git a/experiments/Supporting_Aperio_SVS_Format/benchmark.py b/experiments/Supporting_Aperio_SVS_Format/benchmark.py index 17085a8e9..db5deac70 100644 --- a/experiments/Supporting_Aperio_SVS_Format/benchmark.py +++ b/experiments/Supporting_Aperio_SVS_Format/benchmark.py @@ -19,10 +19,9 @@ from itertools import repeat from time import perf_counter -from openslide import OpenSlide - from cucim import CuImage from cucim.clara.filesystem import discard_page_cache # noqa: F401 +from openslide import OpenSlide class Timer(ContextDecorator): diff --git a/experiments/Using_Cache/benchmark.py b/experiments/Using_Cache/benchmark.py index d9667a44b..b1f69c5dc 100644 --- a/experiments/Using_Cache/benchmark.py +++ b/experiments/Using_Cache/benchmark.py @@ -21,11 +21,10 @@ import numpy as np import rasterio +from cucim import CuImage from openslide import OpenSlide from rasterio.windows import Window -from cucim import CuImage - class Timer(ContextDecorator): def __init__(self, message): From 03f4bc69988e9d76359118d3d0eff80108659ec3 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Tue, 27 Feb 2024 14:36:51 -0500 Subject: [PATCH 2/5] Update dependencies.yaml --- dependencies.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dependencies.yaml b/dependencies.yaml index fa72cb440..21ce5f503 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -239,7 +239,7 @@ dependencies: - python=3.11 - matrix: packages: - - python>=3.8,<3.11 + - python>=3.8,<3.12 run: common: - output_types: [conda, requirements, pyproject] From 42289f72aa4f8cf7902d5830366895e3236d5156 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Tue, 27 Feb 2024 14:41:35 -0500 Subject: [PATCH 3/5] Update conda environments --- conda/environments/all_cuda-118_arch-x86_64.yaml | 2 +- conda/environments/all_cuda-122_arch-x86_64.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index 31c5e6077..de6a215c8 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -40,7 +40,7 @@ dependencies: - pytest-lazy-fixture>=0.6.3 - pytest-xdist - pytest>=6.2.4,<8.0.0a0 -- python>=3.8,<3.11 +- python>=3.8,<3.12 - pywavelets>=1.0 - recommonmark - scikit-image>=0.19.0,<0.23.0a0 diff --git a/conda/environments/all_cuda-122_arch-x86_64.yaml b/conda/environments/all_cuda-122_arch-x86_64.yaml index fb6453a6c..bfdec601c 100644 --- a/conda/environments/all_cuda-122_arch-x86_64.yaml +++ b/conda/environments/all_cuda-122_arch-x86_64.yaml @@ -39,7 +39,7 @@ dependencies: - pytest-lazy-fixture>=0.6.3 - pytest-xdist - pytest>=6.2.4,<8.0.0a0 -- python>=3.8,<3.11 +- python>=3.8,<3.12 - pywavelets>=1.0 - recommonmark - scikit-image>=0.19.0,<0.23.0a0 From 5f87ea4741df2eb5720f3753f83fabefa57273c0 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Tue, 27 Feb 2024 16:21:51 -0500 Subject: [PATCH 4/5] Bump numpy to 1.23 --- conda/recipes/cucim/meta.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conda/recipes/cucim/meta.yaml b/conda/recipes/cucim/meta.yaml index 04a94830a..61d85d080 100644 --- a/conda/recipes/cucim/meta.yaml +++ b/conda/recipes/cucim/meta.yaml @@ -63,7 +63,7 @@ requirements: {% endif %} - cupy >=12.0.0 - libcucim ={{ version }} - - numpy 1.21 + - numpy 1.23 - python - scikit-image >=0.19.0,<0.23.0a0 - scipy From 5d2a6c1125a4238132c6d468ab3acf295867adc7 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Tue, 27 Feb 2024 16:38:42 -0500 Subject: [PATCH 5/5] Require numpy 1.23.4 --- conda/environments/all_cuda-118_arch-x86_64.yaml | 2 +- conda/environments/all_cuda-122_arch-x86_64.yaml | 2 +- dependencies.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index de6a215c8..da6d2d6ae 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -27,7 +27,7 @@ dependencies: - matplotlib-base - nbsphinx - ninja -- numpy>=1.21.3 +- numpy>=1.23.4 - numpydoc>=1.5 - nvcc_linux-64=11.8 - openslide-python>=1.3.0 diff --git a/conda/environments/all_cuda-122_arch-x86_64.yaml b/conda/environments/all_cuda-122_arch-x86_64.yaml index bfdec601c..22532cbc3 100644 --- a/conda/environments/all_cuda-122_arch-x86_64.yaml +++ b/conda/environments/all_cuda-122_arch-x86_64.yaml @@ -27,7 +27,7 @@ dependencies: - matplotlib-base - nbsphinx - ninja -- numpy>=1.21.3 +- numpy>=1.23.4 - numpydoc>=1.5 - openslide-python>=1.3.0 - pip diff --git a/dependencies.yaml b/dependencies.yaml index 21ce5f503..1f8283432 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -250,7 +250,7 @@ dependencies: - output_types: conda packages: - cupy>=12.0.0 - - numpy>=1.21.3 + - numpy>=1.23.4 # All dependencies below this point are specific to `cucim.clara` and # are not needed for either `cucim.core` or `cucim.skimage`. I did # not include these under a "pyproject" output so that it is still