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

ServedSchema

Describe served entry types and their derived lookup tables.

Functions

fulltype_of(definition)

Reconstruct a property's simplified fulltype string.

simplified_property(definition, *[, sortable, ...])

Build a simplified property view for the filter and wrapping layers.

entry_type_definition_from_simple(name, info)

Build an EntryTypeDefinition from simplified metadata.

build_served_schema(definitions[, served, ...])

Build a ServedSchema from entry-type definitions.

Module Contents

httk.serve.optimade.schema.served.fulltype_of(definition)[source]

Reconstruct a property’s simplified fulltype string.

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’s items) for lists.

Parameters:

definition (httk.core.PropertyDefinition) – Property definition to inspect.

Returns:

Compact fulltype spelling used by the filter and response layers.

Return type:

str

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, reconstructed fulltype, the implementation flags (sortable/required_response/default_response/queryable), and — when present — the property’s unit and dimensions (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 an x-optimade-requirements.query-support of "none").

Returns:

Simplified property metadata.

Return type:

dict[str, Any]

httk.serve.optimade.schema.served.entry_type_definition_from_simple(name, info)[source]

Build an EntryTypeDefinition from simplified metadata.

info is a {"description": <str>, "properties": {<name>: <simplified property dict>}} mapping (as produced by, e.g., trajectories_entry_info()); each property is generated with from_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:

httk.core.EntryTypeDefinition

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.

entry_info: dict[str, dict[str, Any]][source]
entry_definition_ids: dict[str, str][source]
recognized_prefixes: tuple[str, Ellipsis][source]
all_entries: tuple[str, Ellipsis][source]
valid_endpoints: tuple[str, Ellipsis][source]
properties_by_entry: dict[str, tuple[str, Ellipsis]][source]
default_response_fields: dict[str, tuple[str, Ellipsis]][source]
required_response_fields: dict[str, tuple[str, Ellipsis]][source]
unknown_response_fields: dict[str, tuple[str, Ellipsis]][source]
sortable_response_fields: dict[str, tuple[str, Ellipsis]][source]
property_definitions: dict[str, dict[str, dict[str, Any]]][source]
httk.serve.optimade.schema.served.build_served_schema(definitions, served=None, *, default_response_overrides=None, sortable=None, recognized_prefixes=None)[source]

Build a ServedSchema from entry-type definitions.

definitions maps each served entry type name to its full EntryTypeDefinition. served maps 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 (a ValueError names any offender). id and type are always default- and required-response; default_response_overrides marks additional served properties as default-response, and sortable marks served properties as sortable. recognized_prefixes defaults to the prefixes currently registered via register_definition_prefix() (resolved at call time so newly registered prefixes are honored).

Parameters:
Returns:

Derived schema and lookup tables.

Raises:

ValueError – If a requested served property is not defined.

Return type:

ServedSchema