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
¶
prediction_output(properties)
¶
The mlm:output entry describing post-processed prediction features through MLM variables.
Source code in fair/stac/validators.py
is_trainable(assets)
¶
A base model without a training runtime serves predictions only and cannot be finetuned.
batch_runtime(assets)
¶
The full toolchain image that runs batch predictions; the distroless mlm:inference image cannot.
validate_inference_params(params, model_item)
¶
Raise ValueError unless every key is a declared, spec'd inference parameter with a valid value.
Source code in fair/stac/validators.py
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 the backend's item_href form.
pystac's local-catalog write produces these relative hrefs. Use raw link.target so we
don't trigger pystac's root resolution (which makes HTTP calls).
Source code in fair/stac/versioning.py
relativize_catalog_links(item, catalog_url)
¶
Store links into this catalog relative to its root; the STAC API resolves them against each request's host.
Source code in fair/stac/versioning.py
prepare_api_links(item, catalog_url)
¶
Shape links for a STAC API: catalog links relative to its root, no self, no latest-version on a current item.
The API infers self per request, and pystac turns a relative self href into a local file path.
Source code in fair/stac/versioning.py
delete_item_with_archives(backend, collection_id, item_id)
¶
Delete the item and its deprecated {id}-v{n} archives; return the deleted ids.
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.
Source code in fair/stac/versioning.py
Constants¶
fair.stac.constants
¶
options: show_if_no_docstring: true members_order: alphabetical