httk.serve.optimade.schema.served¶
The registry of entry types and properties served by an OPTIMADE deployment.
A ServedSchema narrows a set of first-class
EntryTypeDefinition objects (supplied from outside, e.g. by
an EntryProvider) down to the entry types and properties a
backend implements, and derives the endpoint and response-field tables used
during request validation and response generation.
The full OPTIMADE property definitions live in httk-core; this module keeps, for
each served property, a small simplified view (its fulltype and the
implementation flags) that the filter-translation and response layers consume,
alongside the full property definitions served on the entry listing info
endpoint.
Classes¶
Describe served entry types and their derived lookup tables. |
Functions¶
|
Reconstruct a property's simplified |
|
Build a simplified property view for the filter and wrapping layers. |
|
Build an |
|
Build a |
Module Contents¶
- httk.serve.optimade.schema.served.fulltype_of(definition)[source]¶
Reconstruct a property’s simplified
fulltypestring.Maps the OPTIMADE type back to the compact spelling used by the filter layer:
"string"/"integer"/"float"/"boolean"/"timestamp","dict"for dictionaries, and"list of ..."(nesting through the definition’sitems) for lists.- Parameters:
definition (httk.core.PropertyDefinition) – Property definition to inspect.
- Returns:
Compact fulltype spelling used by the filter and response layers.
- Return type:
- httk.serve.optimade.schema.served.simplified_property(definition, *, sortable=False, required_response=False, default_response=False, queryable=True)[source]¶
Build a simplified property view for the filter and wrapping layers.
Carries the
description, reconstructedfulltype, the implementation flags (sortable/required_response/default_response/queryable), and — when present — the property’sunitanddimensions(used by the trajectory frame-wrapping).- Parameters:
definition (httk.core.PropertyDefinition) – Property definition to simplify.
sortable (bool) – Mark the property as sortable by the backend.
required_response (bool) – Mark the property as required in responses.
default_response (bool) – Mark the property as returned by default.
queryable (bool) – Mark the property as usable in
filter=(false honors anx-optimade-requirements.query-supportof"none").
- Returns:
Simplified property metadata.
- Return type:
- httk.serve.optimade.schema.served.entry_type_definition_from_simple(name, info)[source]¶
Build an
EntryTypeDefinitionfrom simplified metadata.infois a{"description": <str>, "properties": {<name>: <simplified property dict>}}mapping (as produced by, e.g.,trajectories_entry_info()); each property is generated withfrom_simple().- Parameters:
name (str) – Entry endpoint and definition name.
info (collections.abc.Mapping[str, Any]) – Simplified entry description and property mapping.
- Returns:
Full entry-type definition.
- Return type:
- class httk.serve.optimade.schema.served.ServedSchema[source]¶
Describe served entry types and their derived lookup tables.
- Parameters:
entry_info – Simplified entry-info documents keyed by entry type.
entry_definition_ids – Definition IRIs keyed by entry type.
recognized_prefixes – Property-definition prefixes recognized in requests.
all_entries – Served entry endpoint names in declaration order.
valid_endpoints – Fixed and entry endpoint names accepted by validation.
properties_by_entry – Served property names keyed by entry type.
default_response_fields – Default response fields keyed by entry type.
required_response_fields – Required response fields keyed by entry type.
unknown_response_fields – Defined but unserved fields keyed by entry type.
sortable_response_fields – Sortable response fields keyed by entry type.
property_definitions – Full property definitions keyed by entry type.
- httk.serve.optimade.schema.served.build_served_schema(definitions, served=None, *, default_response_overrides=None, sortable=None, recognized_prefixes=None)[source]¶
Build a
ServedSchemafrom entry-type definitions.definitionsmaps each served entry type name to its fullEntryTypeDefinition.servedmaps each entry type to the subset of property names actually served (defaulting to every property the definition describes); every served name MUST be described by the definition (aValueErrornames any offender).idandtypeare always default- and required-response;default_response_overridesmarks additional served properties as default-response, andsortablemarks served properties as sortable.recognized_prefixesdefaults to the prefixes currently registered viaregister_definition_prefix()(resolved at call time so newly registered prefixes are honored).- Parameters:
definitions (collections.abc.Mapping[str, httk.core.EntryTypeDefinition]) – Full definitions keyed by served entry type.
served (collections.abc.Mapping[str, collections.abc.Sequence[str]] | None) – Optional served-property subset keyed by entry type.
default_response_overrides (collections.abc.Mapping[str, collections.abc.Sequence[str]] | None) – Additional default fields keyed by entry type.
sortable (collections.abc.Mapping[str, collections.abc.Sequence[str]] | None) – Sortable fields keyed by entry type.
recognized_prefixes (tuple[str, Ellipsis] | None) – Prefixes recognized in response-field requests.
- Returns:
Derived schema and lookup tables.
- Raises:
ValueError – If a requested served property is not defined.
- Return type: