patchworks 0.11.14__tar.gz → 0.11.16__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. {patchworks-0.11.14 → patchworks-0.11.16}/PKG-INFO +15 -8
  2. {patchworks-0.11.14 → patchworks-0.11.16}/README.md +10 -7
  3. {patchworks-0.11.14 → patchworks-0.11.16}/pyproject.toml +2 -0
  4. {patchworks-0.11.14 → patchworks-0.11.16}/workflow/README.md +11 -4
  5. {patchworks-0.11.14 → patchworks-0.11.16}/workflow/config/config.yaml +4 -0
  6. {patchworks-0.11.14 → patchworks-0.11.16}/workflow/pixi.toml +14 -0
  7. {patchworks-0.11.14 → patchworks-0.11.16}/workflow/profile/slurm/config.yaml +15 -3
  8. {patchworks-0.11.14 → patchworks-0.11.16}/workflow/scripts/merge.py +12 -0
  9. {patchworks-0.11.14 → patchworks-0.11.16}/.github/workflows/docs.yml +0 -0
  10. {patchworks-0.11.14 → patchworks-0.11.16}/.github/workflows/lint.yml +0 -0
  11. {patchworks-0.11.14 → patchworks-0.11.16}/.github/workflows/release.yml +0 -0
  12. {patchworks-0.11.14 → patchworks-0.11.16}/.gitignore +0 -0
  13. {patchworks-0.11.14 → patchworks-0.11.16}/.markdownlint-cli2.yaml +0 -0
  14. {patchworks-0.11.14 → patchworks-0.11.16}/LICENSE +0 -0
  15. {patchworks-0.11.14 → patchworks-0.11.16}/cliff.toml +0 -0
  16. {patchworks-0.11.14 → patchworks-0.11.16}/docs/api/chunks.md +0 -0
  17. {patchworks-0.11.14 → patchworks-0.11.16}/docs/api/cluster.md +0 -0
  18. {patchworks-0.11.14 → patchworks-0.11.16}/docs/api/io.md +0 -0
  19. {patchworks-0.11.14 → patchworks-0.11.16}/docs/api/merge_tile_labels.md +0 -0
  20. {patchworks-0.11.14 → patchworks-0.11.16}/docs/api/plugins/cellpose.md +0 -0
  21. {patchworks-0.11.14 → patchworks-0.11.16}/docs/api/plugins/napari.md +0 -0
  22. {patchworks-0.11.14 → patchworks-0.11.16}/docs/api/plugins/ome_zarr.md +0 -0
  23. {patchworks-0.11.14 → patchworks-0.11.16}/docs/api/relabel.md +0 -0
  24. {patchworks-0.11.14 → patchworks-0.11.16}/docs/api/tile_process.md +0 -0
  25. {patchworks-0.11.14 → patchworks-0.11.16}/docs/assets/logo.png +0 -0
  26. {patchworks-0.11.14 → patchworks-0.11.16}/docs/examples/cellpose_2d.md +0 -0
  27. {patchworks-0.11.14 → patchworks-0.11.16}/docs/examples/cellpose_2d.py +0 -0
  28. {patchworks-0.11.14 → patchworks-0.11.16}/docs/examples/cellpose_3d.md +0 -0
  29. {patchworks-0.11.14 → patchworks-0.11.16}/docs/examples/cellpose_3d.py +0 -0
  30. {patchworks-0.11.14 → patchworks-0.11.16}/docs/examples/custom.md +0 -0
  31. {patchworks-0.11.14 → patchworks-0.11.16}/docs/examples/custom_method.py +0 -0
  32. {patchworks-0.11.14 → patchworks-0.11.16}/docs/examples/standalone_merge.md +0 -0
  33. {patchworks-0.11.14 → patchworks-0.11.16}/docs/examples/stardist.md +0 -0
  34. {patchworks-0.11.14 → patchworks-0.11.16}/docs/examples/stardist_2d.py +0 -0
  35. {patchworks-0.11.14 → patchworks-0.11.16}/docs/getting_started.md +0 -0
  36. {patchworks-0.11.14 → patchworks-0.11.16}/docs/guide/gpu_distributed.md +0 -0
  37. {patchworks-0.11.14 → patchworks-0.11.16}/docs/guide/merging.md +0 -0
  38. {patchworks-0.11.14 → patchworks-0.11.16}/docs/guide/ome_zarr_napari.md +0 -0
  39. {patchworks-0.11.14 → patchworks-0.11.16}/docs/guide/performance.md +0 -0
  40. {patchworks-0.11.14 → patchworks-0.11.16}/docs/guide/pitfalls.md +0 -0
  41. {patchworks-0.11.14 → patchworks-0.11.16}/docs/guide/skip_empty.md +0 -0
  42. {patchworks-0.11.14 → patchworks-0.11.16}/docs/guide/snakemake.md +0 -0
  43. {patchworks-0.11.14 → patchworks-0.11.16}/docs/guide/tiling.md +0 -0
  44. {patchworks-0.11.14 → patchworks-0.11.16}/docs/index.md +0 -0
  45. {patchworks-0.11.14 → patchworks-0.11.16}/mkdocs.yml +0 -0
  46. {patchworks-0.11.14 → patchworks-0.11.16}/src/patchworks/__init__.py +0 -0
  47. {patchworks-0.11.14 → patchworks-0.11.16}/src/patchworks/_chunks.py +0 -0
  48. {patchworks-0.11.14 → patchworks-0.11.16}/src/patchworks/_cluster.py +0 -0
  49. {patchworks-0.11.14 → patchworks-0.11.16}/src/patchworks/_core.py +0 -0
  50. {patchworks-0.11.14 → patchworks-0.11.16}/src/patchworks/_distributed.py +0 -0
  51. {patchworks-0.11.14 → patchworks-0.11.16}/src/patchworks/_io.py +0 -0
  52. {patchworks-0.11.14 → patchworks-0.11.16}/src/patchworks/_merge.py +0 -0
  53. {patchworks-0.11.14 → patchworks-0.11.16}/src/patchworks/_relabel.py +0 -0
  54. {patchworks-0.11.14 → patchworks-0.11.16}/src/patchworks/plugins/__init__.py +0 -0
  55. {patchworks-0.11.14 → patchworks-0.11.16}/src/patchworks/plugins/cellpose.py +0 -0
  56. {patchworks-0.11.14 → patchworks-0.11.16}/src/patchworks/plugins/napari.py +0 -0
  57. {patchworks-0.11.14 → patchworks-0.11.16}/src/patchworks/plugins/ome_zarr.py +0 -0
  58. {patchworks-0.11.14 → patchworks-0.11.16}/tests/test_core.py +0 -0
  59. {patchworks-0.11.14 → patchworks-0.11.16}/tests/test_distributed.py +0 -0
  60. {patchworks-0.11.14 → patchworks-0.11.16}/tests/test_napari.py +0 -0
  61. {patchworks-0.11.14 → patchworks-0.11.16}/tests/test_ome_zarr.py +0 -0
  62. {patchworks-0.11.14 → patchworks-0.11.16}/workflow/Snakefile +0 -0
  63. {patchworks-0.11.14 → patchworks-0.11.16}/workflow/rules/common.smk +0 -0
  64. {patchworks-0.11.14 → patchworks-0.11.16}/workflow/rules/convert.smk +0 -0
  65. {patchworks-0.11.14 → patchworks-0.11.16}/workflow/rules/merge.smk +0 -0
  66. {patchworks-0.11.14 → patchworks-0.11.16}/workflow/rules/segment.smk +0 -0
  67. {patchworks-0.11.14 → patchworks-0.11.16}/workflow/scripts/_pw.py +0 -0
  68. {patchworks-0.11.14 → patchworks-0.11.16}/workflow/scripts/convert.py +0 -0
  69. {patchworks-0.11.14 → patchworks-0.11.16}/workflow/scripts/fetch_model.py +0 -0
  70. {patchworks-0.11.14 → patchworks-0.11.16}/workflow/scripts/prepare_tiles.py +0 -0
  71. {patchworks-0.11.14 → patchworks-0.11.16}/workflow/scripts/segment_tile.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: patchworks
3
- Version: 0.11.14
3
+ Version: 0.11.16
4
4
  Summary: Tiled processing of arbitrarily large images with globally consistent labels
5
5
  Project-URL: Homepage, https://github.com/imcf/patchworks
6
6
  Project-URL: Issues, https://github.com/imcf/patchworks/issues
@@ -50,6 +50,10 @@ Requires-Dist: bioio-ome-tiff; extra == 'bioio'
50
50
  Requires-Dist: bioio-tifffile; extra == 'bioio'
51
51
  Provides-Extra: cellpose
52
52
  Requires-Dist: cellpose>=3.0; extra == 'cellpose'
53
+ Provides-Extra: cellpose3
54
+ Requires-Dist: cellpose<4,>=3.0; extra == 'cellpose3'
55
+ Provides-Extra: cellpose4
56
+ Requires-Dist: cellpose>=4; extra == 'cellpose4'
53
57
  Provides-Extra: dev
54
58
  Requires-Dist: psutil; extra == 'dev'
55
59
  Requires-Dist: pytest; extra == 'dev'
@@ -115,12 +119,14 @@ pip install patchworks
115
119
  Optional extras:
116
120
 
117
121
  ```bash
118
- pip install "patchworks[gpu]" # GPU VRAM querying (nvidia-ml-py)
119
- pip install "patchworks[cellpose]" # Cellpose plugin
120
- pip install "patchworks[bioio]" # convert any image format to OME-ZARR
121
- pip install "patchworks[imaris]" # convert Imaris .ims files to OME-ZARR
122
- pip install "patchworks[napari]" # interactive napari viewer plugin
123
- pip install "patchworks[all]" # Everything, incl. the napari viewer
122
+ pip install "patchworks[gpu]" # GPU VRAM querying (nvidia-ml-py)
123
+ pip install "patchworks[cellpose]" # Cellpose plugin (>=3.0, v3 or v4)
124
+ pip install "patchworks[cellpose3]" # Cellpose plugin, pinned to v3.x
125
+ pip install "patchworks[cellpose4]" # Cellpose plugin, pinned to v4+
126
+ pip install "patchworks[bioio]" # convert any image format to OME-ZARR
127
+ pip install "patchworks[imaris]" # convert Imaris .ims files to OME-ZARR
128
+ pip install "patchworks[napari]" # interactive napari viewer plugin
129
+ pip install "patchworks[all]" # Everything, incl. the napari viewer
124
130
  ```
125
131
 
126
132
  > `bioio` reads CZI/LIF/ND2/OME-TIFF/… The `[bioio]` extra bundles the common
@@ -382,7 +388,8 @@ Optional:
382
388
  - `psutil` — accurate RAM sizing for `tile_shape="auto"`
383
389
  - `nvidia-ml-py` — accurate GPU VRAM sizing
384
390
  - `tqdm` — progress bars
385
- - `cellpose` — Cellpose plugin (`patchworks[cellpose]`)
391
+ - `cellpose` — Cellpose plugin, v3 or v4 (`patchworks[cellpose]`);
392
+ pin with `[cellpose3]` or `[cellpose4]`
386
393
  - `bioio` + readers — convert CZI/LIF/ND2/OME-TIFF/… to OME-ZARR
387
394
  (`patchworks[bioio]`)
388
395
  - `imaris-ims-file-reader` — convert Imaris `.ims` (`patchworks[imaris]`)
@@ -36,12 +36,14 @@ pip install patchworks
36
36
  Optional extras:
37
37
 
38
38
  ```bash
39
- pip install "patchworks[gpu]" # GPU VRAM querying (nvidia-ml-py)
40
- pip install "patchworks[cellpose]" # Cellpose plugin
41
- pip install "patchworks[bioio]" # convert any image format to OME-ZARR
42
- pip install "patchworks[imaris]" # convert Imaris .ims files to OME-ZARR
43
- pip install "patchworks[napari]" # interactive napari viewer plugin
44
- pip install "patchworks[all]" # Everything, incl. the napari viewer
39
+ pip install "patchworks[gpu]" # GPU VRAM querying (nvidia-ml-py)
40
+ pip install "patchworks[cellpose]" # Cellpose plugin (>=3.0, v3 or v4)
41
+ pip install "patchworks[cellpose3]" # Cellpose plugin, pinned to v3.x
42
+ pip install "patchworks[cellpose4]" # Cellpose plugin, pinned to v4+
43
+ pip install "patchworks[bioio]" # convert any image format to OME-ZARR
44
+ pip install "patchworks[imaris]" # convert Imaris .ims files to OME-ZARR
45
+ pip install "patchworks[napari]" # interactive napari viewer plugin
46
+ pip install "patchworks[all]" # Everything, incl. the napari viewer
45
47
  ```
46
48
 
47
49
  > `bioio` reads CZI/LIF/ND2/OME-TIFF/… The `[bioio]` extra bundles the common
@@ -303,7 +305,8 @@ Optional:
303
305
  - `psutil` — accurate RAM sizing for `tile_shape="auto"`
304
306
  - `nvidia-ml-py` — accurate GPU VRAM sizing
305
307
  - `tqdm` — progress bars
306
- - `cellpose` — Cellpose plugin (`patchworks[cellpose]`)
308
+ - `cellpose` — Cellpose plugin, v3 or v4 (`patchworks[cellpose]`);
309
+ pin with `[cellpose3]` or `[cellpose4]`
307
310
  - `bioio` + readers — convert CZI/LIF/ND2/OME-TIFF/… to OME-ZARR
308
311
  (`patchworks[bioio]`)
309
312
  - `imaris-ims-file-reader` — convert Imaris `.ims` (`patchworks[imaris]`)
@@ -41,6 +41,8 @@ dependencies = [
41
41
  [project.optional-dependencies]
42
42
  io = ["psutil", "tqdm"]
43
43
  cellpose = ["cellpose>=3.0"]
44
+ cellpose3 = ["cellpose>=3.0,<4"]
45
+ cellpose4 = ["cellpose>=4"]
44
46
  gpu = ["nvidia-ml-py"]
45
47
  # bioio enables converting any image format (CZI, LIF, ND2, OME-TIFF, …) to
46
48
  # OME-ZARR. Ships the common native readers (faster than going through Java)
@@ -41,10 +41,17 @@ pip install "patchworks[workflow,cellpose,imaris,bioio]"
41
41
  Prefer pixi? No conda needed — a `pixi.toml` is included:
42
42
 
43
43
  ```bash
44
- pixi install
45
- pixi run dry # dry-run
46
- pixi run go # run locally
47
- pixi run slurm # submit to SLURM
44
+ pixi install # default env (latest compatible Cellpose)
45
+ pixi install -e cellpose3 # pin to Cellpose 3.x
46
+ pixi install -e cellpose4 # pin to Cellpose 4+
47
+
48
+ pixi run dry # dry-run (default env)
49
+ pixi run go # run locally (default env)
50
+ pixi run slurm # submit to SLURM (default env)
51
+
52
+ # To run with a specific Cellpose version:
53
+ pixi run -e cellpose3 go
54
+ pixi run -e cellpose4 go
48
55
  ```
49
56
 
50
57
  ## Configure
@@ -51,3 +51,7 @@ cellpose:
51
51
  pyramid_levels: 5
52
52
  pyramid_downscale: 2
53
53
  sequential_labels: true # renumber merged labels to a contiguous 1..N range
54
+
55
+ # ---- merge performance --------------------------------------------------
56
+ # null -> use the "merge" rule's actual cpus_per_task (profile/slurm/config.yaml).
57
+ merge_workers: null
@@ -15,9 +15,23 @@ platforms = ["linux-64"]
15
15
  [dependencies]
16
16
  python = "3.12.*"
17
17
 
18
+ # Default env uses patchworks[cellpose] (>=3.0, resolves to latest compatible).
18
19
  [pypi-dependencies]
19
20
  patchworks = { version = "*", extras = ["workflow", "cellpose", "imaris", "bioio"] }
20
21
 
22
+ # Cellpose-version-pinned features for explicit environments below.
23
+ [feature.cp3.pypi-dependencies]
24
+ cellpose = ">=3.0,<4"
25
+
26
+ [feature.cp4.pypi-dependencies]
27
+ cellpose = ">=4"
28
+
29
+ # Named environments: pixi install -e cellpose3 / -e cellpose4
30
+ # The base patchworks[cellpose] (>=3.0) is further constrained by each feature.
31
+ [environments]
32
+ cellpose3 = { features = ["cp3"], solve-group = "cp3" }
33
+ cellpose4 = { features = ["cp4"], solve-group = "cp4" }
34
+
21
35
  [tasks]
22
36
  # --rerun-triggers mtime: don't redo finished steps (e.g. the conversion) just
23
37
  # because the patchworks version/code changed — only when an output is missing.
@@ -5,7 +5,13 @@
5
5
  # Edit the partitions / account / GPU request for your cluster.
6
6
 
7
7
  executor: slurm
8
- jobs: 64 # max concurrent SLURM jobs (≈ how many GPUs you can grab at once)
8
+ # Max concurrent SLURM jobs Snakemake will have in flight at once. This is a
9
+ # submission-side cap, not a cluster limit — raising it just lets more
10
+ # "segment" tiles queue/run together; scicore's scheduler still enforces your
11
+ # real GPU quota (MaxTRESPU) and backfills the rest, so it's safe to raise.
12
+ # Check your actual per-user GPU cap with:
13
+ # sacctmgr show assoc user=$USER format=account,partition,maxjobs,GrpTRES
14
+ jobs: 128
9
15
  latency-wait: 60
10
16
  rerun-incomplete: true
11
17
  # Only re-run when an output is missing/stale — NOT when the patchworks code,
@@ -26,8 +32,12 @@ default-resources:
26
32
  # Per-rule overrides.
27
33
  set-resources:
28
34
  convert:
35
+ # bioio/dask's default threaded scheduler uses every visible core, so
36
+ # this scales conversion for free. Verify actual scaling with `seff
37
+ # <jobid>` after a run and dial back if efficiency is low (scicore
38
+ # fair-share asks you not to sit on idle cores).
29
39
  mem_mb: 64000
30
- cpus_per_task: 8
40
+ cpus_per_task: 32
31
41
  runtime: 360
32
42
  prepare:
33
43
  mem_mb: 32000
@@ -44,6 +54,8 @@ set-resources:
44
54
  cpus_per_task: 4
45
55
  runtime: 360 # 6 hours — must match the QOS, NOT 120 (=2h → killed early)
46
56
  merge:
57
+ # merge_tile_labels now uses n_workers = this allocation (see merge.py /
58
+ # config.yaml's merge_workers) instead of silently capping at 4 threads.
47
59
  mem_mb: 128000
48
- cpus_per_task: 8
60
+ cpus_per_task: 32
49
61
  runtime: 240
@@ -5,6 +5,7 @@ boundaries, optionally renumbers them) and writes the result back into the
5
5
  image store under ``labels/<name>/`` as a calibrated, multi-scale pyramid.
6
6
  """
7
7
 
8
+ import os
8
9
  import shutil
9
10
  from pathlib import Path
10
11
 
@@ -19,11 +20,17 @@ work_dir = cfg["work_dir"]
19
20
  image_store = str(Path(work_dir) / "image.zarr")
20
21
  merged_store = str(Path(work_dir) / "_merged.zarr")
21
22
 
23
+ # merge_tile_labels defaults to min(4, cpu_count) workers, so it ignores
24
+ # whatever cpus_per_task the "merge" rule was actually allocated in the SLURM
25
+ # profile. Read the real allocation (SLURM_CPUS_PER_TASK) so the job uses all
26
+ # the cores it's paying for; merge_workers: in config.yaml can still override.
27
+ default_workers = int(os.environ.get("SLURM_CPUS_PER_TASK", os.cpu_count() or 4))
22
28
  merged = merge_tile_labels(
23
29
  stage_path(work_dir),
24
30
  write_to=merged_store,
25
31
  input_component="staged",
26
32
  sequential_labels=cfg.get("sequential_labels", True),
33
+ n_workers=cfg.get("merge_workers", default_workers),
27
34
  progress=False,
28
35
  )
29
36
  group = write_labels(
@@ -37,5 +44,10 @@ group = write_labels(
37
44
 
38
45
  shutil.rmtree(merged_store, ignore_errors=True)
39
46
  shutil.rmtree(stage_path(work_dir), ignore_errors=True)
47
+ # Also drop the checkpoint's completion sentinel (stage.zarr.done): the
48
+ # "prepare" rule's stage=touch(STAGE_OK) output must not outlive the store it
49
+ # claims exists, or a future rerun (e.g. re-segmenting for new labels) skips
50
+ # "prepare" and "segment" tries to open a stage.zarr that's already gone.
51
+ Path(f"{stage_path(work_dir)}.done").unlink(missing_ok=True)
40
52
  print(f"[patchworks] labels written to {group}")
41
53
  open(snakemake.output[0], "w").close() # noqa: F821
File without changes
File without changes
File without changes
File without changes
File without changes