Adjusted all working routes, full docker pipeline verified, added extra validations for docker, reduced julia environment, tested run succesful

This commit is contained in:
Pixelguy14
2026-10-08 20:51:43 -06:00
parent 19fdd8af16
commit bab8f4d2a9
28 changed files with 290 additions and 499 deletions
+153 -12
View File
@@ -29,7 +29,7 @@ required. Raw MSI datasets are supplied by the user (see [Datasets](#datasets)).
├── run_full_pipeline.sh # single entry point: 7 stages (one or many datasets)
├── environment/ # pinned dependencies
│ ├── Project.toml # Julia package set
│ ├── Manifest.toml # locked Julia environment (julia 1.11.3)
│ ├── Manifest.toml # locked Julia environment (julia 1.11.7)
│ └── requirements.txt # Python deps (torch, sklearn, Pillow, …)
├── src/ # vendored JuliaMSI engine (MIT) — see below
│ └── MSI_src.jl + 14 modules # memory-mapped imzML, TrIQ, slicing, masks
@@ -67,33 +67,41 @@ required. Raw MSI datasets are supplied by the user (see [Datasets](#datasets)).
## Quick start (Docker, recommended)
```bash
# 1) build the GPU image (use `make build-cpu` for the CPU image)
# 1) build (GPU image; `make build-cpu` for the smaller CPU-only image)
make build
# 2) put each dataset in its own folder, e.g.
# datos_para_ai/Datura_leaf/<name>.imzML (+ <name>.ibd, optional ROI .png)
# 3) run
# 3) run — works on CPU out of the box (torch falls back when there is no GPU)
make run # every dataset under datos_para_ai/
make run-dataset D=Datura_leaf # a single dataset
# with an NVIDIA GPU (needs the Container Toolkit / a CDI spec — see Troubleshooting):
make run-gpu
make run-dataset-gpu D=Datura_leaf
```
Equivalent raw Docker, if you prefer not to use `make`:
Equivalent raw container, if you prefer not to use `make`:
```bash
docker build -t msi-pipeline-gpu .
docker run --gpus all --shm-size=2g -it \
# CPU (no GPU flags):
docker run --rm --shm-size=2g -it \
-v "$PWD/datos_para_ai:/app/datos_para_ai" \
-v "$PWD/outputs:/app/outputs" \
msi-pipeline-gpu bash
# add `--gpus all` (Docker) or `--device nvidia.com/gpu=all` (Podman + CDI) for a GPU.
# then, inside the container:
bash run_full_pipeline.sh # all datasets under datos_para_ai/
bash run_full_pipeline.sh Datura_leaf # a single dataset
```
For CPU-only machines, build `Dockerfile.cpu` (`make build-cpu`) and drop `--gpus all`.
In VS Code the bundled `.devcontainer/` builds the GPU image with the right flags.
The pipeline runs fine **without a GPU** (SimCLR trains on CPU, just slower). The pure
`Dockerfile.cpu` image (`make build-cpu`, `make run-cpu`) is smaller if you never need CUDA.
In VS Code the bundled `.devcontainer/` requests a GPU.
## Native run (venv + system Julia)
@@ -131,13 +139,29 @@ count `K`; Stage 3 prints and stores the best value (Silhouette optimum by defau
## Datasets
The pipeline reads **any valid imzML** (profile or centroid) — it is **not** restricted to
the manuscript datasets. For each dataset create `datos_para_ai/<name>/` containing:
the manuscript datasets.
**Each dataset must live in its own subfolder of `datos_para_ai/`.** The folder name *is*
the dataset name, and it becomes the `outputs/<name>/` directory. Files placed directly in
`datos_para_ai/` — **not inside a subfolder — are ignored** by `run_full_pipeline.sh`, so a
dataset dropped loose at the root will not be detected.
```
datos_para_ai/
├── Mouse_bladder/ # folder name = dataset name
│ ├── HR2MSImouseurinarybladderS096.imzML # exactly one .imzML
│ ├── HR2MSImouseurinarybladderS096.ibd # its sibling .ibd (matching basename)
│ └── region_of_interest.png # optional ROI mask
└── Datura_leaf/
├── Leaf.imzML
└── Leaf.ibd
```
Rules for each dataset folder:
- exactly one `.imzML` file, and
- its sibling `.ibd` binary (the imzML references the `.ibd` by basename, so both must sit
in the same folder).
The folder name becomes the dataset name used throughout `outputs/`.
- its sibling `.ibd` binary — the imzML references the `.ibd` by basename, so both must sit
in the same folder with matching basenames.
**ROI masks are optional.** If present in the same folder, the first match wins:
`region_of_interest.png`, otherwise any `*.png` whose filename contains `roi`, `mask`, or
@@ -207,6 +231,123 @@ outputs (`outputs/<ds>/msi_tsne_plot.png`,
`outputs/<ds>/figures/cluster_validation_detailed_plot.png`, `outputs/<ds>/galleries/`).
Re-run that script after any pipeline change to regenerate them.
## Troubleshooting
### `? Please select an image:` at `STEP 1/15` (Podman / Buildah)
When a `FROM` uses a short image name (e.g. `nvidia/cuda:12.4.1-runtime-ubuntu22.04`),
Docker resolves it against Docker Hub automatically, but **Podman/Buildah enforces
short-name resolution**: if more than one registry is configured it stops and asks which
one to pull from. A typical prompt (the list depends on your registry configuration):
```
? Please select an image:
▸ registry.fedoraproject.org/nvidia/cuda:12.4.1-runtime-ubuntu22.04
registry.access.redhat.com/nvidia/cuda:12.4.1-runtime-ubuntu22.04
docker.io/nvidia/cuda:12.4.1-runtime-ubuntu22.04
```
**Choose `docker.io/nvidia/cuda:12.4.1-runtime-ubuntu22.04`** — NVIDIA publishes these
images on Docker Hub.
To avoid the prompt entirely (recommended, works on every OS): use the **fully-qualified**
name. This repository's Dockerfiles already do this, so no prompt should appear:
```dockerfile
FROM docker.io/nvidia/cuda:12.4.1-runtime-ubuntu22.04 # Dockerfile (GPU)
FROM docker.io/library/ubuntu:22.04 # Dockerfile.cpu (CPU)
```
If you maintain a fork with short names and cannot change the Dockerfile, you can allow
short names globally instead. Edit the Containers registry config:
- Linux/macOS (rootless): `~/.config/containers/registries.conf`
- Linux (root): `/etc/containers/registries.conf`
- Windows: `%APPDATA%\containers\registries.conf`
```toml
unqualified-search-registries = ["docker.io"]
short-name-mode = "permissive"
```
- **Docker Desktop (Windows/macOS) and Docker Engine (Linux):** no prompt — `nvidia/cuda`
resolves to Docker Hub by default.
- **Podman (Linux/macOS/Windows):** prompted unless the name is fully qualified or the
config above is set.
### Clean rebuild / remove a failed build
A **failed build usually leaves no tagged project image** — only intermediary layers and
build cache. Clearing the cache is therefore the important step; there is often nothing to
`rmi`.
Docker (Linux/Windows/macOS):
```bash
docker compose down --rmi all --volumes --remove-orphans # project-scoped reset
docker rmi -f msi-pipeline-gpu msi-pipeline-cpu 2>/dev/null || true
docker builder prune -af # clear BuildKit cache
docker image prune -f # drop dangling <none> images
docker compose build --no-cache msi-pipeline-gpu # rebuild from scratch
```
Podman / `podman-compose`:
```bash
podman-compose down --rmi all -v
podman rmi -f $(podman images --format '{{.ID}} {{.Repository}}' \
| awk 'tolower($0) ~ /msi-pipeline/ {print $1}') 2>/dev/null || true
podman builder prune -af
podman-compose build --no-cache msi-pipeline-gpu
```
Global reset (**careful — removes all unused images/cache, not just this project**):
```bash
docker system prune -a --volumes -f # Docker (same as `make clean-all`)
podman system prune -a --volumes -f # Podman
```
Notes:
- `docker builder prune -af` / `podman builder prune -af` affect this project's cache
safely; the `system prune -a` commands are host-wide.
- A normal `make build` reuses cached `apt`/Julia/pip layers. For a genuine
reproducibility test, clear the cache (`builder prune -af`) or build with `--no-cache`.
### `make run` fails with `unresolvable CDI devices nvidia.com/gpu=all`
The base `docker-compose.yml` does **not** request a GPU, so `make run` / `make run-dataset`
work on CPU-only machines. Requesting a GPU is opt-in via `docker-compose.gpu.yml`:
```bash
make run-gpu
make run-dataset-gpu D=Datura_leaf
```
On **Podman**, a GPU reservation becomes the CDI device `nvidia.com/gpu=all`, which must
exist first:
```bash
# one-time, on the host (needs the NVIDIA driver + nvidia-container-toolkit):
sudo nvidia-ctk cdi generate --output=/etc/cdi/nvidia.yaml
nvidia-ctk cdi list # should show nvidia.com/gpu=all
```
Docker Desktop / Docker Engine handle the `deploy` GPU reservation without a manual CDI
spec. If you have no NVIDIA GPU, ignore `*-gpu` targets entirely — the CPU fallback works.
### If the Julia step of the build fails
- The images install Julia strictly from the committed `environment/Manifest.toml` and run
`Pkg.instantiate()` only (no `resolve()`). If you see
`… is a direct dependency, but does not appear in the manifest`, the lock is out of sync
with `Project.toml` — run `julia --project=environment -e 'using Pkg; Pkg.resolve()'`
locally and commit the regenerated `Manifest.toml`.
- `GLMakie` fails to precompile in a headless build
(`GLFWError … X11: The DISPLAY environment variable is missing`). This is expected and
**non-fatal**: GLMakie is a GUI-only dependency and the pipeline never loads it. The
images intentionally do not run an explicit `Pkg.precompile()`.
## License
MIT — see `LICENSE`. The vendored `src/` retains its own MIT license (`src/LICENSE`).