Skip to content

Feature/add unit tests - #24

Merged
evaminot merged 77 commits into
developfrom
feature/add-unit-tests
Nov 6, 2026
Merged

evaminot merged 77 commits into
developfrom
feature/add-unit-tests

Conversation

@evaminot

@evaminot evaminot commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator

Add a set of unit tests for the incoming GRSProcessor v3.0.0

harmelt and others added 30 commits January 14, 2026 17:37
Add a "How the CI/CD Pipeline Works" section explaining the GitHub
Actions (tests, PyPI, Docker Hub, docs) and GitLab CI (HPC functional
tests, security/quality gates) pipelines, and replace the minimal
Contributing pointer with a fuller "How to Contribute" quick start.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
guillaumeeb/grs:2.1.9 on Docker Hub is broken (ModuleNotFoundError:
grs.data.aux, missing subpackage). The fix is already on this branch,
but the publish step only runs on tag pushes and the original v2.1.9
tag predates .github/workflows/main.yml entirely, so it can't trigger
a rebuild. This lets podman-build force-tag the image as 2.1.9 and
publish it when run from feature/dev-ci, without touching the v2.1.9
git tag. Also fixes the publish step to use VERSION_GRS consistently
instead of GITHUB_REF_NAME (the two only coincided on tag pushes).

Revert once the corrected 2.1.9 image has been republished.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The republished guillaumeeb/grs:2.1.9 image (aux/auxiliary fix) now
fails on import with AttributeError: module 'dask.dataframe.core' has
no attribute 'DataFrame', raised deep in
grs -> GRSdriver -> holoviews -> datashader.data_libraries.dask.

datashader==0.16.3 (pinned in requirements.txt) predates a dask
dataframe API change; pip resolves an unpinned, newer dask
transitively and the two become incompatible. The python-tests CI job
already works around this with `pip install -U datashader` — apply
the same upgrade in Dockerfile-github so the published image doesn't
hit it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
grs's own docopt Usage pattern only declared the short -o <odir>
option, so any caller using --odir (the form used everywhere else:
README examples, the PBS launcher scripts, conda_grs.sh, and
grsprocessor.cwl, which always injects "--odir <runtime.outdir>")
hit a docopt parse failure and got the usage banner printed instead
of actually running — this is what the Antflow job was hitting after
the aux/auxiliary and datashader/dask fixes.

Declare -o/--odir as synonyms in the Options section so both spellings
work, and read args['--odir'] (docopt's canonical key once a long name
exists) instead of args['-o'].

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The cloud-cover pre-check crashed with "RuntimeError: not a string"
before even reaching Process() — osgeo.gdal.Open() doesn't accept
pathlib.Path objects, only str/bytes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
# Conflicts:
#	grs/__init__.py
#	grs/grs_process.py
#	grs/run.py
#	pyproject.toml
Tristanovsk and others added 24 commits October 14, 2026 22:23
Rerun the Sentinel-2 (processing, xarray, grstbx) and Landsat tutorials
with the fixes of the NaN bands and edges.
… Zenodo

- grs.config: settings merged from the packaged defaults (grs/config.yml),
  the user file ~/.config/grs/config.yml (or GRS_CONFIG) and GRS_DATA_ROOT,
  read at run time instead of editing grs/config.yml before installing;
  when grsdata is not set, the LUTs are read from the user data folder
  (platformdirs), e.g. ~/.local/share/grs/lut on Linux
- grs_config: prints the configuration in use and checks the LUTs (exit
  code 1 if one is missing); --init [DATA_ROOT] writes the user file;
  --download downloads the LUTs from the Zenodo record of the zenodo
  section (MD5 checked, written to .part then renamed); --force
- Process.execute checks the LUT files before reading the image
- grs/config.yml: grsdata null by default, description of each setting,
  zenodo section (record to set once the LUT dataset is published)
- fix: Process.cams_dir was read from trans_lut instead of path: cams
- platformdirs replaces importlib_resources in the dependencies
- docs: Configuration page; installation, README, README_CNES, API page
  and CHANGELOG updated
…23394202)

- grs/config.yml: zenodo record 23394202, used by grs_config --download
- grs.config: link of the record taken from links.self_html
- README, installation and configuration pages: link to the Zenodo DOI
final_process_chunk returns at once for a block without any valid pixel
(only aot550 is interpolated) and, when less than half of the block is
valid, computes the pixel-by-pixel steps on the valid pixels only.
Same results, cost proportional to the number of water pixels.
The sunglint slope correction is disabled (the result was multiplied by 0
then 1 added): return 1 with the NaN of the inputs directly, without
computing the Cox-Munk distribution. Same output, about a quarter less time
per block in final_process_chunk.

Future use of p_slope should be developed once the azimuth issue corrected
in the computation.
- execute and write_output run dask with processor.ncpu workers (the
  setting was read but not used: one worker per core, each holding its
  blocks in memory)
- CamsProduct keeps only the coordinates of the image, and prod.cirrus /
  prod.wv are copies: the L1C bands are no longer held during the run
- the water masking sets the non-water pixels to NaN in place for bands in
  memory, and the band selections are released after use

Sentinel-2 tile at 20 m: peak memory 15.9 -> 10.1 GB, 238 -> 185 s,
identical output.
The transmittance (CAMS grid) has its own spatial_ref: the division dropped
this conflicting coordinate from the blocks and xr.map_blocks rejected them.
The scalar coordinates of the transmittance are dropped before the division.
Found with GRSdriver v1.0.10 and EOREADER_USE_DASK=1.
- missing LUTs downloaded from Zenodo before the first processing
  (grs.config.ensure_luts); off with zenodo: auto_download: false or
  GRS_NO_DOWNLOAD=1
- pyproject: distribution GRSprocessor, version from grs.__version__,
  Python >= 3.11, tests excluded; requirements matching the imports
- CLI: Sentinel-2 cloud cover read from MTD_MSIL1C.xml (no GDAL needed)
- PyPI README, release recipe in CONTRIBUTING.md, GitHub workflow
  pypi.yml (trusted publishing on v* tags), CHANGELOG
…hers

The memory freed by the threads that read and process the image was kept
in one glibc arena per thread. MALLOC_ARENA_MAX=2 is set in the Docker
images; the grs command and exe/launcher.py set it at start-up with
mallopt (unless MALLOC_ARENA_MAX is set). Sentinel-2 tile at 20 m with
the parallel band reading of GRSdriver: about 2-3 GB less peak memory,
same output.
…orrection failed)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…om the ADS

- installation from PyPI (GRSprocessor) or from the source, CPU build of
  PyTorch, check with grs -v / grs_config
- LUTs downloaded from Zenodo on the first run, GRS_NO_DOWNLOAD
- CAMS: --cams_file or download from the Atmosphere Data Store (~/.cdsapirc)
- usage: main options, Python API, memory and computing time
- tests with pytest (test data in Git LFS); duplicated title removed
Notebook from notebook/launcher/launcher_grs.ipynb, rendered with the
outputs of a batch of 21 images (tile 31TEJ, August 2025): list of the
Level-1 images of a date range, CAMS file and DEM of each image, batch
with grs.Process (skipped / failed images, summary table), quick look,
and one grs command per image for the command line. Links from the
tutorials menu and the usage page.
Global daily files <cams_dir>/YYYY/MM/DD/YYYY-MM-DD-cams-global-atmospheric-
composition-forecasts.nc (ecmwf/download_cams_cds_day.py), monthly files
kept for the older archive: download of any day, cams_file_of(date) to
find the file of an image (daily, else monthly). Checked on 2026-03-09:
same CAMS values from the daily and the monthly file, 8 times faster to
load.
Without CAMS file, the forecasts are read from
<path: cams>/YYYY/MM/DD/YYYY-MM-DD-cams-global-atmospheric-composition-
forecasts.nc (global file of the day), else from the file of the tile next
to it (..._<tile>.nc), downloaded from the ADS if needed (never into the
global file). Files of the former layout <path: cams>/<tile>/<date>-
forecast_<tile>.nc are still read. grs.cams.cams_daily_file gives the
path of a date.
Sentinel-2 image of 2026-03-09 over Lake Geneva (tile 31TGM) with the
CAMS daily file of its date (YYYY/MM/DD tree); download into the archive
with grs.cams.cams_daily_file, monthly files for the older archive only.
Notebook re-run.
h5netcdf >= 1.8 no longer installs h5py, its default backend: a new
installation failed to read the NetCDF files ("No module named 'h5py',
backend not available").
- visualization tutorial: pip install "grstbx[notebook]" (grstbx >= 2.4.0
  on PyPI), RGB bands / contrast / brightness of ViewSpectral, web
  dashboard grstbx-viewer, links to the grstbx documentation
- home page: link to the grstbx documentation, viewers and dashboard
aot_resolution, min_pixel_prop, aot_chunk, outlier_factor,
aot_smoothing_blocks, fine_step, fine_window and aot_step are read from
the aerosol section of config.yml; the arguments of the same name of
Process.execute (new for the five that were fixed in the code) override
them, and --aot_resolution of the grs command. Default aot_resolution
240 m (was 480 m: one AOT value per Sentinel-2 tile), as in the study
notebook notebook/settings_aerosols; checked on the Loire image: same
AOT as the notebook with the defaults and with aot_chunk=64.
The box filter of the second smoothing can turn a null block AOT into a
tiny negative value (rounding, ~-4e-17); the LUTs of the final processing
then started below 0 and Rrs was NaN everywhere. Seen on 4 of 13 images
with aot_smoothing_blocks=1 (study notebook/settings_aerosols); checked on
the Venice image: 553/553 finite Rrs after the fix, 0/686 before.
Validated against AERONET-OC (Venise, Section-7 Platform; 73 AOT and 67
Rrs matchups, notebook/settings_aerosols/AERONET-OC): with blocks of
15 km instead of 61 km (aot_chunk 256), AOT RMSE 0.066 instead of 0.094,
bias -0.013 instead of -0.054, Rrs RMSE 23 to 33 % lower in all bands.
Test data (grs/tests/data, 0.95 MB, made with make_test_data.py): 128 x
128 pixels at 60 m of S2A 2021-02-11 (tile 31TFJ) and its CAMS forecasts.
Tests (28, about 20 s): configuration and aerosol settings, CAMS
YYYY/MM/DD archive, smoothing filters, gaseous correction with dask,
command line helpers, and end-to-end processing to L2A (skipped without
the look-up tables). Run in the CI with the integration tests.
@review-notebook-app

Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@evaminot
evaminot merged commit 3babe2a into develop Nov 6, 2026
13 of 17 checks passed
@evaminot
evaminot deleted the feature/add-unit-tests branch November 6, 2026 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants