STAC¶
STAC catalog management, item builders, validators, and backends.
Backend Protocol¶
fair.stac.backend
¶
StacBackend
¶
Bases: Protocol
Structural interface for STAC catalog operations.
StacCatalogManager (local JSON) and PgStacBackend (pgstac) both conform without explicit inheritance.
Catalog Manager¶
fair.stac.catalog_manager
¶
PgSTAC Backend¶
fair.stac.pgstac_backend
¶
PgStacBackend(dsn, stac_api_url)
¶
STAC backend using pypgstac Loader and pystac-client.
Writes use pypgstac's Loader (bulk upsert via COPY + pgstac SQL). Reads use pystac-client against the STAC API. Delete uses pgstac's delete_item() SQL function directly since Loader has no delete API.
Source code in fair/stac/pgstac_backend.py
Builders¶
fair.stac.builders
¶
Collections¶
fair.stac.collections
¶
create_base_models_collection()
¶
base-models: model blueprints contributed via PR.
Source code in fair/stac/collections.py
create_local_models_collection()
¶
local-models: finetuned models, only promoted versions.
Source code in fair/stac/collections.py
create_datasets_collection()
¶
datasets: training data registered via fAIr UI/backend.
Source code in fair/stac/collections.py
initialize_catalog(catalog_path)
¶
Create catalog.json + 3 empty collections. Saves to disk.
returns existing catalog if already present.
Source code in fair/stac/collections.py
Validators¶
fair.stac.validators
¶
Versioning¶
fair.stac.versioning
¶
normalize_version_link_hrefs(item, item_href_factory, default_collection_id)
¶
Rewrite version-link relative hrefs (../../coll/id/id.json) to absolute API URLs.
pystac's local-catalog write produces relative hrefs; remote backends need the same
links pointing at the API URL the catalog will live at. Use raw link.target so we
don't trigger pystac's root resolution (which makes HTTP calls).
Source code in fair/stac/versioning.py
archive_previous_version(backend, collection_id, old_item, new_item_href)
¶
Copy the old item to a version-suffixed ID and deprecate it.
Preserves the old version as a discoverable, deprecated STAC item per the STAC Version Extension v1.2.0 spec.