httk.core.optimade.entries¶
Typed, exact OPTIMADE resource backends for core standard entry types.
The resource and its schema snapshot remain the sole source of truth. A
typed backend recognizes values by property-definition IRI from the supplied
/info/<entry> document; a remote transport name is only an address after
that IRI match has been established. The record views deliberately defer all
document parsing and generated-record construction until .record (or a
delegated field) is requested.
Attributes¶
Exceptions¶
A resource lacks, nulls, or malforms a local record property. |
Classes¶
Store one typed handle around an authoritative OPTIMADE resource. |
|
Bind an OPTIMADE resource to the standard references schema. |
|
Bind an OPTIMADE resource to the standard files schema. |
|
Bind an OPTIMADE resource to the standard calculations schema. |
|
Present one typed resource backend as a lazy generated record. |
|
Present an |
|
Present an |
|
Present an |
Functions¶
|
Decode one value exactly from its local property definition. |
Module Contents¶
- type httk.core.optimade.entries.OptimadeValueDecoder = Callable[[object, PropertyDefinition], object][source]¶
- exception httk.core.optimade.entries.IncompleteOptimadeResourceError[source]¶
Bases:
ValueErrorA resource lacks, nulls, or malforms a local record property.
- httk.core.optimade.entries.decode_optimade_value(definition, value)[source]¶
Decode one value exactly from its local property definition.
Binding-specific decoder callables use the stable signature
decoder(value, definition)and replace this generic decoder for their exact property-definition IRI. JSON floats are retained asDecimal; nested lists and dictionaries become tuples and immutable mappings.- Parameters:
definition (httk.core.property_definitions.PropertyDefinition) – Local property definition that describes the value.
value (object) – Raw value to decode.
- Returns:
Decoded value with nested containers made immutable.
- Raises:
TypeError – If the value does not match the declared property shape.
ValueError – If the property definition is unsupported or malformed.
- Return type:
- class httk.core.optimade.entries.OptimadeEntryBackend[source]¶
Store one typed handle around an authoritative OPTIMADE resource.
- Parameters:
resource – Source resource and its schema provenance.
- property raw: collections.abc.Mapping[str, httk.core.optimade.resources.FrozenJson][source]¶
The immutable JSON API resource mapping, retaining source provenance.
- unwrap()[source]¶
Return the exact source resource, including document and schema provenance.
- Returns:
The source resource represented by this backend.
- Return type:
- property local_schema: httk.core.property_definitions.EntryTypeDefinition[source]¶
Return the standard local schema for this backend.
- value_by_definition_id(definition_id, *, default=_MISSING)[source]¶
Return a raw value by exact semantic IRI, retaining missing vs. null.
Values are intentionally undecoded here. This lets record views name missing/null semantic properties accurately and gives callers access to exact raw JSON before selecting a representation.
- Parameters:
- Returns:
The raw property value, or
defaultwhen it is absent.- Raises:
ValueError – If the resource attributes or schema mapping is malformed.
- Return type:
- decode_value(definition, value)[source]¶
Decode value, applying an exact-IRI binding override when present.
- Parameters:
definition (httk.core.property_definitions.PropertyDefinition) – Local property definition for the value.
value (object) – Raw value to decode.
- Returns:
Decoded value from the matching generic or binding-specific decoder.
- Raises:
TypeError – If the value does not match the selected property decoder.
ValueError – If the property definition or value is invalid.
- Return type:
- property last_modified: datetime.datetime | None[source]¶
Return the optional last-modified timestamp.
- class httk.core.optimade.entries.OptimadeReference[source]¶
Bases:
OptimadeEntryBackendBind an OPTIMADE resource to the standard references schema.
- Parameters:
resource – Source resource and its schema provenance.
- class httk.core.optimade.entries.OptimadeFile[source]¶
Bases:
OptimadeEntryBackendBind an OPTIMADE resource to the standard files schema.
- Parameters:
resource – Source resource and its schema provenance.
- class httk.core.optimade.entries.OptimadeCalculation[source]¶
Bases:
OptimadeEntryBackendBind an OPTIMADE resource to the standard calculations schema.
- Parameters:
resource – Source resource and its schema provenance.
- class httk.core.optimade.entries.OptimadeEntryView(backend)[source]¶
Present one typed resource backend as a lazy generated record.
- Parameters:
backend (OptimadeEntryBackend | OptimadeEntryView) – Typed backend to present, or an existing compatible view.
- backend_class: ClassVar[type[OptimadeEntryBackend]][source]¶
- record_class: ClassVar[type[httk.core.entry_types.Reference] | type[httk.core.entry_types.File] | type[httk.core.entry_types.Calculation]][source]¶
- property backend: OptimadeEntryBackend[source]¶
Return the typed backend behind this view.
- property record: httk.core.entry_types.Reference | httk.core.entry_types.File | httk.core.entry_types.Calculation[source]¶
Return the lazily materialized canonical record.
- class httk.core.optimade.entries.ReferenceView(backend)[source]¶
Bases:
OptimadeEntryViewPresent an
OptimadeReferenceas a lazy canonical view.- Parameters:
backend (OptimadeEntryBackend | OptimadeEntryView) – Reference backend to present, or an existing compatible view.
- class httk.core.optimade.entries.FileView(backend)[source]¶
Bases:
OptimadeEntryViewPresent an
OptimadeFileas a lazy canonical view.- Parameters:
backend (OptimadeEntryBackend | OptimadeEntryView) – File backend to present, or an existing compatible view.
- class httk.core.optimade.entries.CalculationView(backend)[source]¶
Bases:
OptimadeEntryViewPresent an
OptimadeCalculationas a lazy canonical view.- Parameters:
backend (OptimadeEntryBackend | OptimadeEntryView) – Calculation backend to present, or an existing compatible view.