eomatch.ingest.ingest#
- eomatch.ingest.ingest(catalogue_path: str | None = None, config=None, db_host: str | None = None, db_port: int | None = None, db_name: str | None = None, db_user: str | None = None, db_password: str | None = None, assets_base_url: str | None = None) None[source]#
Push a local pystac catalogue into a pgSTAC database.
Reads every collection and item from the local catalogue and loads them into pgSTAC using upsert semantics, so re-running after a partial failure or incremental update is always safe.
Asset hrefs that are stored as relative paths in the local catalogue are resolved to absolute
file://paths before ingest. If assets_base_url is supplied, hrefs are further rewritten to HTTP URLs so the STAC Browser can load thumbnails. This requires the catalogue asset files to be served over HTTP at that URL (e.g. via the/catalogue/nginx location in the Docker Compose stack).derived_fromandrelateditem links are rewritten to root-relative API paths (/api/collections/{id}/items/{id}) before ingest. stac-fastapi resolves these to correct absolute URLs at serve time; the filter-proxy then rewrites them to/external/paths for external consumers. The local catalogue JSON files are never modified.Connection parameters are resolved in priority order: explicit keyword argument →
ingestsection of the eomatch config → environment variablePGPASSWORD(password only).Requires the
pypgstacpackage (pip install pypgstacorpip install eomatch[ingest]).Example usage:
from eomatch.ingest import ingest ingest( catalogue_path="/data/my_catalogue", assets_base_url="http://my-server:8000/catalogue", db_host="localhost", db_name="eomatch", db_user="postgres", db_password="secret", )
- Parameters:
catalogue_path – path to the root
catalog.json. Defaults tomatchup_catalogue.pathfrom the eomatch config.config – path to a eomatch YAML config file, or a dict of overrides. If
None, the package and user configs are used.db_host – pgSTAC database host.
db_port – pgSTAC database port.
db_name – pgSTAC database name.
db_user – pgSTAC database user.
db_password – pgSTAC database password. Falls back to the
PGPASSWORDenvironment variable if not supplied.assets_base_url – HTTP base URL at which the catalogue asset files are served. When set, asset hrefs are rewritten from local
file://paths to HTTP URLs so the STAC Browser can load thumbnails.