Sentinel-2 ingestion pipeline#
Build a searchable embedding index from Sentinel-2 L2A products, or from explicitly configured L1B products, with a host-local batch worker.
For a first run on one L2A product, with the image build and the serving steps scripted, follow Tutorial: find ships off a port.
The pipeline lives in packs/sentinel/pipelines/ingest/ with its own environment and lock
file. It keeps the cugeo.pipeline namespace and the cugeo-pipeline command, and uses
cuGeo for GPU JPEG 2000 reads and coordinate transformation. It is not part of the server
environment, and its vector stores are separate from the server’s retrieval registry. To
make vectors available to API and agent clients, publish verified source metadata and
import the vectors through the server. The CLI does not do this for you.
Embedding and retrieval shows the server side; the pipeline’s place in the flow
is the Sentinel ingest sheet.
Prerequisites#
Linux with a CUDA 13 driver and an NVIDIA GPU, or the pipeline container image.
Python 3.12 and uv, plus the native prerequisites of cuGeo’s raster and projection libraries (Rust 1.85.1 and CUDA 13). The build fetches the latest cuGeo
main. Git credentials provide access when the repository requires it.Clay v1.5 weights. They are downloaded on first use; set
HF_TOKENif access requires it, andCUGEO_PIPELINE_CLAY_DIRto change the default~/.cache/cugeo/clay.
Install#
Run sh packs/sentinel/scripts/fetch-cugeo.sh from the repository root. Then
run the following from packs/sentinel/pipelines/ingest/.
uv venv --python 3.12
sdk=$(python3 -c 'import tomllib; print(tomllib.load(open("../cugeo/cugeo-raster/pyproject.toml", "rb"))["project"]["optional-dependencies"]["nvjpeg2k"][0])')
uv pip install "$sdk" 'setuptools>=77' wheel cupy-cuda13x
CUGEO_PROJ_BUILD_CUDA=1 CUGEO_PROJ_CUDA_MAJOR=13 \
uv pip install --reinstall ../cugeo/cugeo-proj
uv lock --upgrade-package cugeo-proj --upgrade-package cugeo-raster
NVJPEG2K_ROOT="$PWD/.venv/lib/python3.12/site-packages/nvidia/nvjpeg2k" \
CUGEO_RASTER_BUILD_NVJPEG2K=1 \
uv sync --locked --extra dev --extra raster-gpu --extra cuvs --extra clay \
--no-build-isolation-package cugeo-raster --reinstall-package cugeo-raster
Keep NVJPEG2K_ROOT set when rebuilding. The L1B similarity image builder
builds a local GPU worker image. The image runs cugeo-pipeline as UID 10001
and takes imagery, work and cache directories as mounts.
Ingest L2A and search#
Pass an unpacked single-granule L2A SAFE product:
uv run cugeo-pipeline info /data/product.SAFE
uv run cugeo-pipeline pipeline /data/product.SAFE --limit 50 --num-gpus 1
uv run cugeo-pipeline search --chip-id <stored-chip-id> --top-k 5
Setting |
Behavior |
|---|---|
Bands |
B02, B03, B04, B05, B06, B07, B08, B8A, B11, B12, with SAFE offsets and quantification applied, normalized with Clay’s L2A statistics |
Chip size |
128 pixels by default; |
Area |
The whole product by default; |
Precision |
|
Encoder |
PyTorch by default; |
Store |
cuVS by default; |
Run mode |
|
Search uses a stored chip’s vector, so it needs no endpoint or credentials. Each payload records the source, location, sensing time and embedding recipe, and cuVS rejects an append whose dimension, metric, model, precision, chip size or normalization differs. Start a new table when the recipe changes. Re-ingesting appends rows, and duplicate chip IDs make a stored-chip query ambiguous.
Ingest L1B#
pipeline --l1b-manifest <index.json> accepts L1B granules, their metadata XML, completed
_L1B_GR_*.tar archives and directories of those. Source archives are never changed.
L1B chips are 128 by 128 pixels on a common 10 m ground grid with the ten Clay bands. Each band is calibrated, orthorectified and atmospherically corrected with Sen2Cor tables and a fixed visibility before Clay sees it. Reflectance is multiplied by 10,000. Fully contained chips pass the all-band nodata filter, and partial edge chips are dropped. The result is not ESA’s operational L2A and has no cloud mask.
Build the source-only cuGeo runtime and its native libraries from the same checkout. Keep the same checkout path available to every worker, and use a dedicated Python 3.12 environment.
Prepare one
input.jsonper band for each granule. All ten must describe the same granule and destination extent at 10 m, with a halo for terrain correction. Inputs need matching datastrip metadata, spacecraft calibration, DEM cells, a geoid, matching L1C metadata and the Sen2Cor tables for that spacecraft (lib_S2A,lib_S2Borlib_S2C).packs/sentinel/scripts/prepare_l1b_ortho.pywrites them for a corpus laid out as in Serve your L1B data as ortho images and embeddings.Write the host-private index:
version,cugeo_checkout, the nativelibraries, thecorrection(terrainor flat) andordering(ortho-firstorsource-first), andproductskeyed by granule name with its ten band inputs.l1b-index.example.jsoninpacks/sentinel/examples/l1b-similarity/is a starting point.Run it:
cugeo-pipeline pipeline /data/raw \ --l1b-manifest /work/l1b.json --size 128 --run-mode inprocess \ --db-uri /work/l1b-vectors --table sentinel2_l1b --limit 16
Use a table separate from L2A embeddings. Product writes commit together: a failure publishes none of that product’s batches.
The adapter takes a fixed visibility and chosen atmosphere preset. It does not retrieve atmosphere from reanalysis data, retrieve visibility or classify clouds.
Hosted embeddings#
nim-pipeline and the document commands (chip, ingest) use NVIDIA’s hosted image
embedding endpoint instead of Clay. Set NVIDIA_API_KEY; CUGEO_PIPELINE_EMBED_ENDPOINT
and CUGEO_PIPELINE_EMBED_MODEL select another endpoint. Keep these vectors in their own
table. These paths do not accept raw L1B geometry. The CLI writes a session log under
outputs/logs/; CUGEO_PIPELINE_SESSION_LOG=off disables it.
Test#
uv run --extra dev pytest tests -q
uv run --extra dev ruff check .
The default suite uses generated SAFE fixtures. Native projection and GPU tests skip when their prerequisites are missing, and a passing host suite does not qualify GPU ingestion or model accuracy.