eomatch.enrich.enrich

Contents

eomatch.enrich.enrich#

eomatch.enrich.enrich(catalogue, enrichers: Iterable[Callable[[Matchup], Dict[str, Any]]], overwrite: bool = False, matchup_ids: Iterable[str] | None = None, raise_error: bool | None = False) → int[source]#

Apply enrichers to matchup items in catalogue.

For each matchup STAC Item the function:

  1. Reconstructs the Matchup domain object from the item’s derived_from links.

  2. Calls every enricher with the Matchup and merges the returned dicts.

  3. Writes the new key/value pairs back to item.properties (skipping keys that already exist unless overwrite is True).

  4. Saves the updated item JSON to disk (if the item has a self_href).

Enrichers that raise an exception are logged as warnings and skipped for that item, so a single failure does not abort the whole run.

A tqdm progress bar tracks matchup items processed so far against the total – known up front since every matching collection’s items are listed once before the main loop starts (a single pass, same total STAC-item I/O as before; a per-collection get_items() call is never repeated to recompute a total). The bar itself adds negligible overhead per item next to an enricher’s own work (e.g. a product download).

Parameters:
  • catalogue – MatchupCatalogue to enrich.

  • enrichers – iterable of enricher callables.

  • overwrite – when True, existing property values are replaced; when False (default), existing properties are kept unchanged.

  • matchup_ids – if given, only matchup items whose STAC id is in this collection are enriched – the catalogue is shared across many runs, so a caller working on a scoped subset (one site/platform/time window) can enrich just its own matchups instead of re-running every enricher (each of which does its full work, product reads included, on every call) over the whole catalogue. None (default) enriches every matchup item.

  • raise_error – Boolean to set whether errors should be raised or not

Returns:

number of matchup items enriched.