httk.store.entry_providers¶
Serve standard entry types through in-memory EntryProvider implementations.
These providers map {id: record} mappings of the stdlib-only record models
defined in httk-core (Reference, File,
Calculation) onto the neutral httk-core entry-provider
contract, so a serving module (such as httk-serve) can expose them as
OPTIMADE references/files/calculations endpoints without either side
depending on the other. Each provider describes its entry type with the vendored
OPTIMADE standard definition loaded from httk-core via
standard_entry_type().
The record models live in httk-core (contracts and models); these providers
live in httk-store (the capability layer built on those models), together with
property-definition validation. The database storage layer in
httk.store.db complements them with a database-backed provider
(StoreEntryProvider) serving stored
dataclasses the same way.
Classes¶
Serve one standard entry type through the neutral provider contract. |
|
Serves OPTIMADE |
|
Serves OPTIMADE |
|
Serves OPTIMADE |
|
Serve core |
|
Serve core |
Functions¶
|
Build source-side relationships for a provider's |
Module Contents¶
- class httk.store.entry_providers.StandardEntryProvider(entries, *, record_type, entry_type, relationships)[source]¶
Bases:
httk.core.EntryProviderServe one standard entry type through the neutral provider contract.
- Parameters:
entries (collections.abc.Mapping[str, Any]) – The records keyed by their served identifiers.
record_type (type[Any]) – The core record class used to construct each entry.
entry_type (str) – The OPTIMADE entry type served by this provider.
relationships (collections.abc.Mapping[str, collections.abc.Iterable[httk.core.RelatedEntry]] | None) – Optional related entries keyed by served identifier.
- entry_types()[source]¶
Return the one standard entry-type definition served by this provider.
- Returns:
The served entry-type definition.
- Return type:
- property_keys(entry_type)[source]¶
Return served property names mapped to record attribute names.
- records(entry_type)[source]¶
Return JSON-compatible records for the requested entry type.
- relationships(entry_type)[source]¶
Return related entries keyed by served identifier.
- Parameters:
entry_type (str) – The entry type to inspect.
- Returns:
The normalized relationship mapping.
- Raises:
KeyError – If
entry_typeis not this provider’s entry type.- Return type:
collections.abc.Mapping[str, tuple[httk.core.RelatedEntry, Ellipsis]]
- class httk.store.entry_providers.ReferenceEntryProvider(entries, *, relationships=None)[source]¶
Bases:
StandardEntryProviderServes OPTIMADE
referencesfrom a mapping of id toReference.relationshipsoptionally maps a reference id to its related entries (RelatedEntryvalues, served flat per id).- Parameters:
entries (collections.abc.Mapping[str, httk.core.Reference | collections.abc.Mapping[str, Any]]) – The references keyed by their served identifiers.
relationships (collections.abc.Mapping[str, collections.abc.Iterable[httk.core.RelatedEntry]] | None) – Optional related entries keyed by reference identifier.
- class httk.store.entry_providers.FileEntryProvider(entries, *, relationships=None)[source]¶
Bases:
StandardEntryProviderServes OPTIMADE
filesfrom a mapping of id toFile.relationshipsoptionally maps a file id to its related entries (RelatedEntryvalues, served flat per id) — e.g. the calculations a file isinput/outputof.- Parameters:
entries (collections.abc.Mapping[str, httk.core.File | collections.abc.Mapping[str, Any]]) – The files keyed by their served identifiers.
relationships (collections.abc.Mapping[str, collections.abc.Iterable[httk.core.RelatedEntry]] | None) – Optional related entries keyed by file identifier.
- class httk.store.entry_providers.CalculationEntryProvider(entries, *, relationships=None)[source]¶
Bases:
StandardEntryProviderServes OPTIMADE
calculationsfrom a mapping of id toCalculation.relationshipsoptionally maps a calculation id to its related entries (RelatedEntryvalues, served flat per id) — e.g. itsinput/outputfiles, expressed via therolemetadata.- Parameters:
entries (collections.abc.Mapping[str, httk.core.Calculation | collections.abc.Mapping[str, Any]]) – The calculations keyed by their served identifiers.
relationships (collections.abc.Mapping[str, collections.abc.Iterable[httk.core.RelatedEntry]] | None) – Optional related entries keyed by calculation identifier.
- class httk.store.entry_providers.RunEntryProvider(entries)[source]¶
Bases:
httk.core.EntryProviderServe core
Runrecords and their provenance edges.- Parameters:
entries (collections.abc.Mapping[str, httk.core.Run | collections.abc.Mapping[str, Any]]) – The runs keyed by their served identifiers.
- entry_types()[source]¶
Return the vendored
_httk_runsentry definition.- Returns:
The served run entry-type definition.
- Return type:
- property_keys(entry_type)[source]¶
Return the served run-property to record-key mapping.
- relationships(entry_type)[source]¶
Return run provenance edges with role and edge-label metadata.
- Parameters:
entry_type (str) – The entry type to inspect.
- Returns:
Relationships grouped by run identifier.
- Raises:
KeyError – If
entry_typeis not_httk_runs.- Return type:
collections.abc.Mapping[str, tuple[httk.core.RelatedEntry, Ellipsis]]
- class httk.store.entry_providers.DataRecordEntryProvider(entries, *, definitions=None, relationships=None)[source]¶
Bases:
httk.core.EntryProviderServe core
DataRecordvalues as provider properties.Definitions are resolved eagerly at construction. Every served property name must start with
_; absent record properties are emitted as JSON null.- Parameters:
entries (collections.abc.Mapping[str, httk.core.DataRecord | collections.abc.Mapping[str, Any]]) – The data records keyed by their served identifiers.
definitions (collections.abc.Mapping[str, httk.core.PropertyDefinition] | None) – Optional property definitions keyed by served property name.
relationships (collections.abc.Mapping[str, collections.abc.Iterable[httk.core.RelatedEntry]] | None) – Optional related entries keyed by record identifier.
- Raises:
ValueError – If a property name, definition, or non-nullable property is inconsistent with the supplied records.
- entry_types()[source]¶
Return the resolved
_httk_recordsentry definition.- Returns:
The served data-record entry-type definition.
- Return type:
- property_keys(entry_type)[source]¶
Return served property names mapped to data-record keys.
- relationships(entry_type)[source]¶
Return normalized data-record relationships by identifier.
- Parameters:
entry_type (str) – The entry type to inspect.
- Returns:
The relationship mapping supplied at construction.
- Raises:
KeyError – If
entry_typeis not_httk_records.- Return type:
collections.abc.Mapping[str, tuple[httk.core.RelatedEntry, Ellipsis]]
- httk.store.entry_providers.product_relationships(links)[source]¶
Build source-side relationships for a provider’s
relationships=argument.Feed the inner mapping into the source-side provider’s
relationships=argument; per-edgeworkflow_declaration_uriis deliberately not served yet (relation-object serving is future work).- Parameters:
links (collections.abc.Iterable[httk.core.ProductLink]) – The product links to group by source type and identifier.
- Returns:
Source-type mappings of source identifiers to related product entries.
- Raises:
ValueError – If one source has duplicate product labels.
- Return type:
dict[str, dict[str, tuple[httk.core.RelatedEntry, Ellipsis]]]