Skip to content

Commit 769e222

Browse files
committed
Add ome-zarr+zarr support & drop py < 3.10
1 parent 054bdff commit 769e222

6 files changed

Lines changed: 84 additions & 26 deletions

File tree

.github/workflows/python-package.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ on:
1111
jobs:
1212
build:
1313

14-
runs-on: ubuntu-latest
14+
runs-on: ${{ matrix.os }}
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
18+
os: [ubuntu-latest, windows-latest]
19+
python-version: ["3.10", "3.12"]
1920

2021
steps:
2122
- uses: actions/checkout@v4
@@ -26,19 +27,18 @@ jobs:
2627
- name: Install dependencies
2728
run: |
2829
python -m pip install --upgrade pip
29-
python -m pip install flake8
3030
python -m pip install --editable .[test]
3131
- name: Lint with flake8
3232
run: |
3333
# stop the build if there are Python syntax errors or undefined names
34-
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
34+
flake8 biomero tests --count --select=E9,F63,F7,F82 --show-source --statistics
3535
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
36-
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
36+
flake8 biomero tests --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
3737
- name: Test with pytest
3838
run: |
39-
python -m pytest --cov=biomero --cov-report=xml
39+
python -m pytest tests/unit/ --cov=biomero --cov-report=xml
4040
- name: Coveralls GitHub Action
41-
if: matrix.python-version == '3.11'
41+
if: matrix.python-version == '3.12' && matrix.os == 'ubuntu-latest'
4242
uses: coverallsapp/github-action@v2.3.0
4343

4444

README.md

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,37 @@ For a quick overview of what this library can do for you, we can install an exam
9090

9191
# Prerequisites & Getting Started with BIOMERO
9292

93+
## Installation
94+
95+
### Using pip (Cross-platform)
96+
97+
BIOMERO can be installed via pip with different dependency sets:
98+
99+
```bash
100+
# Basic library only (core BIOMERO functionality)
101+
python3 -m pip install biomero
102+
103+
# With BIOMERO.scripts requirements (includes BIOMERO.scripts dependencies)
104+
python3 -m pip install biomero[full]
105+
106+
# Latest development version with BIOMERO.scripts requirements
107+
python3 -m pip install 'git+https://github.com/NL-BioImaging/biomero[full]'
108+
109+
# With test dependencies (for local testing/development)
110+
python3 -m pip install biomero[test]
111+
112+
# With both test and BIOMERO.scripts requirements
113+
python3 -m pip install biomero[test,full]
114+
```
115+
116+
**Dependency sets explained:**
117+
- **Default (no extras)**: Core BIOMERO library for basic functionality
118+
- **`[test]`**: Adds pytest, coverage tools for local testing and development
119+
- **`[full]`**: Adds BIOMERO.scripts requirements (`ezomero`, `tifffile`, `omero-metadata`, `omero-cli-zarr`) which require complex dependencies like `zeroc-ice` and `omero-py`
120+
121+
**Note**: The `[full]` dependencies require complex packages like `zeroc-ice` and `omero-py` that need system libraries. For OMERO integration, you may need to install these separately or use conda.
122+
123+
93124
## Slurm Requirements
94125
Note: This library has only been tested on Slurm versions 21.08.6 and 22.05.09 !
95126

@@ -106,12 +137,11 @@ Your Slurm cluster/login node needs to have:
106137
Your OMERO _processing_ node needs to have:
107138
1. SSH client and access to the Slurm cluster (w/ private key / headless)
108139
2. SCP access to the Slurm cluster
109-
3. Python3.8+
140+
3. Python3.10+
110141
4. This library installed
111-
- Latest release on PyPI `python3 -m pip install biomero`
112-
- or latest Github version `python3 -m pip install 'git+https://github.com/NL-BioImaging/biomero'`
113-
5. Configuration setup at `/etc/slurm-.ini`
114-
6. Requirements for some scripts: `python3 -m pip install ezomero==1.1.1 tifffile==2020.9.3` and the [OMERO CLI Zarr plugin](https://github.com/ome/omero-cli-zarr).
142+
- **With BIOMERO.scripts dependencies**: `python3 -m pip install biomero[full]`
143+
- **Latest development**: `python3 -m pip install 'git+https://github.com/NL-BioImaging/biomero[full]'`
144+
5. Configuration setup at `/etc/slurm-config.ini`
115145

116146
Your OMERO _server_ node needs to have:
117147
1. Some OMERO example scripts installed to interact with this library:
@@ -151,11 +181,12 @@ To connect an OMERO processor to a Slurm cluster using the `biomero` library, us
151181

152182
!!*NOTE*: Do not install [Example Minimal Slurm Script](https://github.com/NL-BioImaging/biomero-scripts/blob/master/Example_Minimal_Slurm_Script.py) if you do not trust your users with your Slurm cluster. It has literal Command Injection for the SSH user as a **FEATURE**.
153183

154-
5. Install [BIOMERO.scripts](https://github.com/NL-BioImaging/biomero-scripts/) requirements, e.g.
155-
- `python3 -m pip install ezomero==1.1.1 tifffile==2020.9.3`
156-
- the [OMERO CLI Zarr plugin](https://github.com/ome/omero-cli-zarr), e.g.
157-
`python3 -m pip install omero-cli-zarr==0.5.3` && `yum install -y blosc-devel`
158-
- the [bioformats2raw-0.7.0](https://github.com/glencoesoftware/bioformats2raw/releases/download/v0.7.0/bioformats2raw-0.7.0.zip), e.g. `unzip -d /opt bioformats2raw-0.7.0.zip && export PATH="$PATH:/opt/bioformats2raw-0.7.0/bin"`
184+
5. 4. Install [BIOMERO.scripts](https://github.com/NL-BioImaging/biomero-scripts/) requirements:
185+
- **If you installed `biomero[full]`**: All required dependencies (`ezomero`, `tifffile`, `omero-metadata`, `omero-cli-zarr`) are already included
186+
- **Manual installation** (if using basic `biomero` without `[full]` extras):
187+
- `python3 -m pip install ezomero>=1.1.1 tifffile>=2020.9.3 omero-metadata>=0.12.0 omero-cli-zarr>=0.5.5`
188+
- Additional system dependencies may be required: `yum install -y blosc-devel`
189+
- Install [bioformats2raw-0.7.0](https://github.com/glencoesoftware/bioformats2raw/releases/download/v0.7.0/bioformats2raw-0.7.0.zip): `unzip -d /opt bioformats2raw-0.7.0.zip && export PATH="$PATH:/opt/bioformats2raw-0.7.0/bin"`
159190

160191
6. To finish setting up your `SlurmClient` and Slurm server, run it once with `init_slurm=True`. This is provided in an OMERO script form at [init/Slurm Init environment](https://github.com/NL-BioImaging/biomero-scripts/blob/master/admin/SLURM_Init_environment.py) , which you just installed in previous step.
161192
- You could provide the configfile location explicitly if it is not a default one defined earlier, but very likely you can omit that field.

biomero/slurm_client.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1606,8 +1606,19 @@ def run_conversion_workflow_job(self,
16061606
data_path = f"{self.slurm_data_path}/{folder_name}"
16071607
conversion_cmd, sbatch_env, chosen_converter, version = self.get_conversion_command(
16081608
data_path, config_file, source_format, target_format)
1609+
1610+
# Handle both .zarr and .ome.zarr extensions for backward compatibility
1611+
if source_format == 'zarr':
1612+
find_cmd = (f"find \"{data_path}/data/in\" -name \"*.zarr\" "
1613+
f"-o -name \"*.ome.zarr\" | "
1614+
f"awk '{{print NR, $0}}' > \"{config_file}\"")
1615+
else:
1616+
find_cmd = (f"find \"{data_path}/data/in\" "
1617+
f"-name \"*.{source_format}\" | "
1618+
f"awk '{{print NR, $0}}' > \"{config_file}\"")
1619+
16091620
commands = [
1610-
f"find \"{data_path}/data/in\" -name \"*.{source_format}\" | awk '{{print NR, $0}}' > \"{config_file}\"",
1621+
find_cmd,
16111622
f"N=$(wc -l < \"{config_file}\")",
16121623
f"echo \"Number of .{source_format} files: $N\"",
16131624
conversion_cmd
@@ -2284,7 +2295,7 @@ def get_logfile_from_slurm(self,
22842295
return local_tmp_storage, export_file, result
22852296

22862297
def get_unzip_command(self, zipfile: str,
2287-
filter_filetypes: str = "*.zarr *.tiff *.tif"
2298+
filter_filetypes: str = "*.zarr *.ome.zarr *.tiff *.tif"
22882299
) -> str:
22892300
"""
22902301
Generate a command string for unzipping a data archive and creating
@@ -2295,7 +2306,7 @@ def get_unzip_command(self, zipfile: str,
22952306
Without extension.
22962307
filter_filetypes (str, optional): A space-separated string
22972308
containing the file extensions to extract from the zip file.
2298-
E.g. defaults to "*.zarr *.tiff *.tif".
2309+
E.g. defaults to "*.zarr *.ome.zarr *.tiff *.tif".
22992310
Setting this argument to `None` will omit the file
23002311
filter and extract all files.
23012312

pyproject.toml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@ authors = [
1212
]
1313
description = "A python library for easy connecting between OMERO (jobs) and a Slurm cluster"
1414
readme = "README.md"
15-
requires-python = ">=3.8"
15+
requires-python = ">=3.10"
1616
keywords = ["omero", "slurm", "high-performance-computing", "fair", "image-analysis", "bioimaging", "high-throughput-screening", "high-content-screening", "cytomine", "biomero", "biaflows"]
1717
license = { file = "LICENSE" }
1818
classifiers = [
1919
"Programming Language :: Python :: 3",
20-
"Programming Language :: Python :: 3.8",
21-
"Programming Language :: Python :: 3.9",
2220
"Programming Language :: Python :: 3.10",
2321
"Programming Language :: Python :: 3.11",
2422
"Programming Language :: Python :: 3.12",
@@ -50,8 +48,15 @@ test = [
5048
"pytest",
5149
"pytest-cov",
5250
"mock",
51+
"flake8",
5352
"psycopg2-binary"
5453
]
54+
full = [
55+
"ezomero>=1.1.1",
56+
"tifffile>=2020.9.3",
57+
"omero-metadata>=0.12.0",
58+
"omero-cli-zarr>=0.6.1"
59+
]
5560

5661
[project.urls]
5762
"Homepage" = "https://github.com/NL-BioImaging/biomero"

resources/slurm-config.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ slurm_script_repo=
9090
# Please pin it to a specific version to reduce unforeseen errors.
9191
#
9292
# Key should be the types "X_to_Y" and value should be the docker image
93-
#zarr_to_tiff=cellularimagingcf/convert_zarr_to_tiff:1.14.0
93+
#zarr_to_tiff=cellularimagingcf/convert_zarr_to_tiff:2.0.0
9494

9595

9696
[MODELS]

tests/unit/test_slurm_client.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def test_get_unzip_command(slurm_client):
148148
slurm_data_path = "/path/to/slurm/data"
149149
slurm_client.slurm_data_path = slurm_data_path
150150
zipfile = "example"
151-
filter_filetypes = "*.zarr *.tiff *.tif"
151+
filter_filetypes = "*.zarr *.ome.zarr *.tiff *.tif"
152152
expected_command = (
153153
f"mkdir \"{slurm_data_path}/{zipfile}\" \
154154
\"{slurm_data_path}/{zipfile}/data\" \
@@ -422,8 +422,19 @@ def test_run_conversion_workflow_job(
422422
expected_sbatch_env["CONVERSION_PARTITION"] = f'"{conversion_partition}"'
423423

424424
expected_conversion_cmd = 'sbatch --job-name=conversion --export=ALL,CONFIG_PATH="$PWD/$CONFIG_FILE" --array=1-$N "$SCRIPT_PATH/convert_job_array.sh"'
425+
426+
# Handle special case for zarr format (.zarr and .ome.zarr)
427+
if source_format == 'zarr':
428+
find_cmd = (f'find "{expected_data_path}/data/in" -name "*.zarr" '
429+
f'-o -name "*.ome.zarr" | awk \'{{print NR, $0}}\' '
430+
f'> "{expected_config_file}"')
431+
else:
432+
find_cmd = (f'find "{expected_data_path}/data/in" '
433+
f'-name "*.{source_format}" | awk \'{{print NR, $0}}\' '
434+
f'> "{expected_config_file}"')
435+
425436
expected_commands = [
426-
f'find "{expected_data_path}/data/in" -name "*.{source_format}" | awk \'{{print NR, $0}}\' > "{expected_config_file}"',
437+
find_cmd,
427438
f'N=$(wc -l < "{expected_config_file}")',
428439
f'echo "Number of .{source_format} files: $N"',
429440
expected_conversion_cmd,

0 commit comments

Comments
 (0)