httk.serve.optimade.backend.stores

Build an OPTIMADE adapter over lazy SQL-backed entry federation.

The durable layout, SQL translation, collision policy, and bounded global pagination live in httk.store.db. This module owns only the serving boundary: the advertised OPTIMADE schema, request-error translation, public response-field projection, and ResultRow objects consumed by the endpoint envelope code.

Imports from httk.store.db deliberately remain inside call sites. Importing httk.serve.optimade therefore does not initialize a database backend or load optional SQL dialects.

Classes

StoredBackendAdapter

Serve one data federation per OPTIMADE entry type.

Functions

adapter_from_stores(sources, **options)

Build a lazy store-backed adapter from durable entry sources.

adapter_from_store(store, **options)

Build a lazy OPTIMADE adapter from every described family in one store.

Module Contents

class httk.serve.optimade.backend.stores.StoredBackendAdapter[source]

Serve one data federation per OPTIMADE entry type.

Parameters:
  • federations – Durable federations keyed by entry endpoint.

  • schema – Schema describing the federations’ served entries.

federations: collections.abc.Mapping[str, Any][source]
schema: httk.serve.optimade.schema.served.ServedSchema[source]
snapshot_cutoff_ns(entry_type, now_ns)[source]

Return the resolution-aware snapshot cutoff for one entry type.

query_function()[source]

Return the callback that queries the configured federations.

Returns:

Query callback consumed by the OPTIMADE request engine.

Return type:

httk.serve.optimade.model.results.QueryFunction

httk.serve.optimade.backend.stores.adapter_from_stores(sources, **options)[source]

Build a lazy store-backed adapter from durable entry sources.

Sources with the same exact logical family are federated under one entry endpoint. The data layer owns all source/backing traversal and global pagination; this adapter advertises the family’s definition and turns only the returned page into OPTIMADE result rows.

Parameters:
Returns:

Lazy adapter over the supplied durable sources.

Raises:
  • ValueError – If sources conflict or expose incomplete sort mappings.

  • TypeError – If a source is not a stored entry source.

Return type:

StoredBackendAdapter

httk.serve.optimade.backend.stores.adapter_from_store(store, **options)[source]

Build a lazy OPTIMADE adapter from every described family in one store.

Families declared without an entry-type definition are deliberately ignored. This lets application-specific records, such as DSP publication declarations, coexist with OPTIMADE records in one durable layout.

Parameters:
  • store (httk.store.EntryStore) – Entry store whose configured layout is discovered.

  • **options (Any) – Schema options forwarded to adapter_from_stores().

Returns:

Lazy adapter over all configured OPTIMADE families.

Raises:
  • TypeError – If store does not implement EntryStore.

  • ValueError – If the store contains no OPTIMADE-described family.

Return type:

StoredBackendAdapter