Skip to content

Commit

Permalink
Modify pyproject.toml to make it publishable on PyPi
Browse files Browse the repository at this point in the history
  • Loading branch information
yuriyzubov committed Jan 17, 2025
1 parent 851c030 commit 82bf1a9
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 29 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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``
7 changes: 4 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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"]
Expand Down
File renamed without changes.
3 changes: 1 addition & 2 deletions src/tiff_stack.py → src/tiff_to_zarr/tiff_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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(
Expand Down
10 changes: 3 additions & 7 deletions src/tiff_to_zarr.py → src/tiff_to_zarr/tiff_to_zarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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(
Expand All @@ -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)

Expand Down
2 changes: 0 additions & 2 deletions src/tiff_volume.py → src/tiff_to_zarr/tiff_volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down
11 changes: 0 additions & 11 deletions src/zarr_attrs_template.json

This file was deleted.

0 comments on commit 82bf1a9

Please sign in to comment.