Skip to content

Commit 09105ff

Browse files
authored
chore: migrate to uv for reproducibility (#12)
1 parent a6bbdbe commit 09105ff

File tree

8 files changed

+1921
-24
lines changed

8 files changed

+1921
-24
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@ local-outputs/
66

77
# Archives
88
*.tar
9-
*.zip
9+
*.zip
10+
11+
# venv
12+
.venv

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.10

Dockerfile

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
11
FROM python:3.10.14-slim-bullseye
22

3+
COPY --from=ghcr.io/astral-sh/uv:0.9.9 /uv /uvx /bin/
4+
5+
ENV PYTHONUNBUFFERED=1 \
6+
PYTHONDONTWRITEBYTECODE=1 \
7+
UV_COMPILE_BYTECODE=1 \
8+
UV_LINK_MODE=copy \
9+
UV_PROJECT_ENVIRONMENT=/usr/local
10+
311
WORKDIR /app
4-
COPY build/requirements.txt /app/requirements.txt
5-
RUN pip install -r /app/requirements.txt
612

13+
RUN --mount=type=cache,target=/root/.cache/uv \
14+
--mount=type=bind,source=uv.lock,target=uv.lock \
15+
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
16+
uv sync --locked --no-install-project
17+
18+
COPY ./pyproject.toml ./uv.lock /app/
719
COPY ./models/ /models
8-
COPY scripts/run.py /app/run.py
20+
COPY ./scripts/run.py /app/run.py
21+
22+
RUN --mount=type=cache,target=/root/.cache/uv \
23+
uv sync --locked
924

1025
ENTRYPOINT ["python", "run.py"]

README.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Stardist Nuclei Segmentation
22

3-
4-
53
## How to run it manually ?
64

75
### Get the docker image
@@ -11,11 +9,11 @@
119
Either from an existing task bundle
1210

1311
```bash
14-
$> unzip com.cytomine.nuclei.segmentation.stardist-0.1.0.zip
15-
Archive: ./com.cytomine.nuclei-segmentation.stardist-0.1.0.zip
16-
inflating: com.cytomine.nuclei.segmentation.stardist-0.1.0.tar
12+
$> unzip com.cytomine.nuclei.segmentation.stardist-0.2.0.zip
13+
Archive: ./com.cytomine.nuclei-segmentation.stardist-0.2.0.zip
14+
inflating: com.cytomine.nuclei.segmentation.stardist-0.2.0.tar
1715
inflating: descriptor.yml
18-
$> docker image load --input com.cytomine.nuclei.segmentation.stardist-0.1.0.tar
16+
$> docker image load --input com.cytomine.nuclei.segmentation.stardist-0.2.0.tar
1917
0949773899cf: Loading layer [==================================================>] 84.2MB/84.2MB
2018
95c8f57bd29d: Loading layer [==================================================>] 3.405MB/3.405MB
2119
95ce64f868d0: Loading layer [==================================================>] 30.56MB/30.56MB
@@ -26,22 +24,22 @@ c70e485b159b: Loading layer [==================================================>
2624
84cc4f8d1ed4: Loading layer [==================================================>] 2.087GB/2.087GB
2725
e05ca7daf251: Loading layer [==================================================>] 5.78MB/5.78MB
2826
987f4b5a221e: Loading layer [==================================================>] 6.656kB/6.656kB
29-
Loaded image: com/cytomine/nuclei-segmentation/stardist:0.1.0
27+
Loaded image: com/cytomine/nuclei-segmentation/stardist:0.2.0
3028

3129
```
3230

3331
### Build the docker image yourself
3432

3533
```
36-
docker build -t com/cytomine/nuclei-segmentation/stardist:0.1.0 .
34+
docker build -t com/cytomine/nuclei-segmentation/stardist:0.2.0 .
3735
```
3836

3937
## Run on data
4038

4139
From this repository, run :
4240

4341
```bash
44-
docker run -v ./examples/inputs:/inputs -v ./local-outputs:/outputs --rm -it com/cytomine/nuclei-segmentation/stardist:0.1.0
42+
docker run -v ./examples/inputs:/inputs -v ./local-outputs:/outputs --rm -it com/cytomine/nuclei-segmentation/stardist:0.2.0
4543
```
4644

4745
You can then explore the results in the `./local-outputs` directory.
@@ -51,10 +49,10 @@ You can then explore the results in the `./local-outputs` directory.
5149
1. Build the docker image as described above
5250
2. save it as `tar` archive
5351
```bash
54-
docker save -o com.cytomine.nuclei.segmentation.stardist-0.1.0.tar com/cytomine/nuclei-segmentation/stardist:0.1.0
52+
docker save -o com.cytomine.nuclei.segmentation.stardist-0.2.0.tar com/cytomine/nuclei-segmentation/stardist:0.2.0
5553
```
5654
3. Build the bundle
5755
```bash
58-
zip com.cytomine.nuclei.segmentation.stardist-0.1.0.zip descriptor.yml com.cytomine.nuclei.segmentation.stardist-0.1.0.tar
56+
zip com.cytomine.nuclei.segmentation.stardist-0.2.0.zip descriptor.yml com.cytomine.nuclei.segmentation.stardist-0.2.0.tar
5957
```
6058
4. Upload the bundle on Cytomine

build/requirements.txt

Lines changed: 0 additions & 7 deletions
This file was deleted.

descriptor.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: StarDist Nuclei Segmentation
22
name_short: stardist
3-
version: 0.1.1
3+
version: 0.2.0
44
namespace: com.cytomine.nuclei.segmentation.stardist
55
$schema: https://raw.githubusercontent.com/cytomine/cytomine/refs/heads/main/app-engine/src/main/resources/schemas/tasks/task.v0.json
66

@@ -20,7 +20,7 @@ configuration:
2020
input_folder: /inputs
2121
output_folder: /outputs
2222
image:
23-
file: /com.cytomine.nuclei.segmentation.stardist-0.1.1.tar
23+
file: /com.cytomine.nuclei.segmentation.stardist-0.2.0.tar
2424

2525
inputs:
2626
image:

pyproject.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[project]
2+
name = "task-stardist"
3+
version = "0.2.0"
4+
description = "Integration of Stardist algorithm as a Cytomine task"
5+
readme = "README.md"
6+
requires-python = ">=3.10"
7+
dependencies = [
8+
"csbdeep==0.8.0",
9+
"geojson==3.1.0",
10+
"imageio==2.34.1",
11+
"numpy==1.26.4",
12+
"pyyaml==6.0.1",
13+
"stardist==0.9.1",
14+
"tensorflow-cpu==2.16.1",
15+
]

0 commit comments

Comments
 (0)