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.

Sentinel ingest pipeline Sentinel ingest pipeline

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_TOKEN if access requires it, and CUGEO_PIPELINE_CLAY_DIR to 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 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.

  1. 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.

  2. Prepare one input.json per 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_S2B or lib_S2C). packs/sentinel/scripts/prepare_l1b_ortho.py writes them for a corpus laid out as in Serve your L1B data as ortho images and embeddings.

  3. Write the host-private index: version, cugeo_checkout, the native libraries, the correction (terrain or flat) and ordering (ortho-first or source-first), and products keyed by granule name with its ten band inputs. l1b-index.example.json in packs/sentinel/examples/l1b-similarity/ is a starting point.

  4. 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.