From 82bf1a950121801579401e45dcb4f8276620f85a Mon Sep 17 00:00:00 2001 From: Yurii Zubov Date: Thu, 16 Jan 2025 22:39:44 -0500 Subject: [PATCH] Modify pyproject.toml to make it publishable on PyPi --- README.md | 8 ++++---- pyproject.toml | 7 ++++--- src/{ => tiff_to_zarr}/__init__.py | 0 src/{ => tiff_to_zarr}/tiff_stack.py | 3 +-- src/{ => tiff_to_zarr}/tiff_to_zarr.py | 10 +++------- src/{ => tiff_to_zarr}/tiff_volume.py | 2 -- src/zarr_attrs_template.json | 11 ----------- 7 files changed, 12 insertions(+), 29 deletions(-) rename src/{ => tiff_to_zarr}/__init__.py (100%) rename src/{ => tiff_to_zarr}/tiff_stack.py (97%) rename src/{ => tiff_to_zarr}/tiff_to_zarr.py (94%) rename src/{ => tiff_to_zarr}/tiff_volume.py (98%) delete mode 100644 src/zarr_attrs_template.json diff --git a/README.md b/README.md index f6f1778..7f94ea5 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,10 @@ This script could be used for conversion of a .tiff file to .zarr format with OM #### How to run 1. open command line terminal 2. install tif_to_zarr - ``pip install tif_to_zarr`` + ``pip install tiff-to-zarr`` 5. run script using cli: - ``tif_to_zarr --src=PATH_TO_SOURCE_DIRECTORY/input_file.tif --dest=PATH_TO_DEST_DIRECTORY/output_file.zarr`` + ``tiff-to-zarr --src=PATH_TO_SOURCE_DIRECTORY/input_file.tif --dest=PATH_TO_DEST_DIRECTORY/output_file.zarr --num_workers=20, --cluster=local`` 6. to convert a tiff file to zarr with custom metadata values, you can run smthg similar to this: -``tif_to_zarr --src=path_to_source_tif(3d or stack) --dest=path_to_output_zarr --num_workers=20 --cluster=local(or lsf) --zarr_chunks 13 128 128 --axes x z y --scale 4.0 5.0 6.0 --translation 1.0 2.0 3.0 --units nanometer nanometer nanometer`` +``tiff-to-zarr --src=path_to_source_tif(3d or stack) --dest=path_to_output_zarr --num_workers=20 --cluster=local(or lsf) --zarr_chunks 13 128 128 --axes x z y --scale 4.0 5.0 6.0 --translation 1.0 2.0 3.0 --units nanometer nanometer nanometer`` 7. To get the list of options, you may run this: -``tif_to_zarr --help`` +``tiff-to-zarr --help`` diff --git a/pyproject.toml b/pyproject.toml index 931c405..509f429 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,7 @@ [tool.poetry] -name = "tif_to_zarr" -version = "0.6.0" +packages = [{include = "tiff_to_zarr", from = "src"}] +name = "tiff-to-zarr" +version = "0.6.13" description = "" authors = ["yurii_zubov"] license = "BSD 3-Clause License" @@ -24,7 +25,7 @@ logging = "^0.4.9.6" xarray-multiscale = "^2.1.0" [tool.poetry.scripts] -tif_to_zarr = 'tif_to_zarr.tif_to_zarr:tif_to_zarr' +tiff-to-zarr = 'tiff_to_zarr.tiff_to_zarr:cli' [build-system] requires = ["poetry-core"] diff --git a/src/__init__.py b/src/tiff_to_zarr/__init__.py similarity index 100% rename from src/__init__.py rename to src/tiff_to_zarr/__init__.py diff --git a/src/tiff_stack.py b/src/tiff_to_zarr/tiff_stack.py similarity index 97% rename from src/tiff_stack.py rename to src/tiff_to_zarr/tiff_stack.py index 0a27551..71364df 100644 --- a/src/tiff_stack.py +++ b/src/tiff_to_zarr/tiff_stack.py @@ -7,7 +7,7 @@ import dask.array as da from natsort import natsorted from glob import glob -from tiff_volume import TiffVolume +from tiff_to_zarr.tiff_volume import TiffVolume class TiffStack(TiffVolume): @@ -72,7 +72,6 @@ def write_tile_slab_to_zarr( # parallel writing of tiff stack into zarr array def write_to_zarr(self, zarray: zarr.Array, client: Client): chunks_list = np.arange(0, zarray.shape[0], zarray.chunks[0]) - print(chunks_list) start = time.time() fut = client.map( diff --git a/src/tiff_to_zarr.py b/src/tiff_to_zarr/tiff_to_zarr.py similarity index 94% rename from src/tiff_to_zarr.py rename to src/tiff_to_zarr/tiff_to_zarr.py index 0f30574..6731765 100644 --- a/src/tiff_to_zarr.py +++ b/src/tiff_to_zarr/tiff_to_zarr.py @@ -6,11 +6,11 @@ from dask_jobqueue import LSFCluster from dask.distributed import Client, LocalCluster import time -from tiff_stack import TiffStack -from tiff_volume import TiffVolume +from tiff_to_zarr.tiff_stack import TiffStack +from tiff_to_zarr.tiff_volume import TiffVolume -@click.command() +@click.command("tiff-to-zarr") @click.option( "--src", "-s", @@ -101,8 +101,6 @@ def cli(src, dest, num_workers, cluster, zarr_chunks, axes, translation, scale, elif src.endswith(".tif") or src.endswith(".tiff"): tiff_volume = TiffVolume(src, axes, scale, translation, units) - print(tiff_volume.shape) - z_store = zarr.NestedDirectoryStore(dest) z_root = zarr.open(store=z_store, mode="a") z_arr = z_root.require_dataset( @@ -114,11 +112,9 @@ def cli(src, dest, num_workers, cluster, zarr_chunks, axes, translation, scale, ) # write in parallel to zarr using dask - start_time = time.time() client.cluster.scale(num_workers) tiff_volume.write_to_zarr(z_arr, client) client.cluster.scale(0) - print(time.time() - start_time) # populate zarr metadata tiff_volume.populate_zarr_attrs(z_root) diff --git a/src/tiff_volume.py b/src/tiff_to_zarr/tiff_volume.py similarity index 98% rename from src/tiff_volume.py rename to src/tiff_to_zarr/tiff_volume.py index 33f7b26..bd9ae23 100644 --- a/src/tiff_volume.py +++ b/src/tiff_to_zarr/tiff_volume.py @@ -27,7 +27,6 @@ def __init__( self.zarr_store = imread(os.path.join(src_path), aszarr=True) self.zarr_arr = zarr.open(self.zarr_store) - print(type(self.zarr_arr)) self.shape = self.zarr_arr.shape self.dtype = self.zarr_arr.dtype @@ -43,7 +42,6 @@ def __init__( # multiprocess writing tiff stack into zarr array def write_to_zarr(self, zarray: zarr.Group, client: Client): chunks_list = np.arange(0, zarray.shape[0], zarray.chunks[0]) - print(chunks_list) src_path = copy.copy(self.src_path) diff --git a/src/zarr_attrs_template.json b/src/zarr_attrs_template.json deleted file mode 100644 index 8e7ac29..0000000 --- a/src/zarr_attrs_template.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "multiscales": [ - { - "version": "", - "name": "", - "axes": [], - "datasets": [], - "coordinateTransformations": [] - } - ] -}