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:
Reconstructs the
Matchupdomain object from the item’sderived_fromlinks.Calls every enricher with the
Matchupand merges the returned dicts.Writes the new key/value pairs back to
item.properties(skipping keys that already exist unless overwrite isTrue).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
tqdmprogress 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-collectionget_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 –
MatchupCatalogueto enrich.enrichers – iterable of enricher callables.
overwrite – when
True, existing property values are replaced; whenFalse(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.