httk.serve.optimade.backend.protocols¶
Typed protocols for the store/searcher contract the OPTIMADE backend uses.
The store/searcher protocols are defined in httk.store.query (httk-store
is where httk’s data stores live, and this backend programs against their
shared query contract); this module re-exports them for the backend’s use,
together with the OPTIMADE-specific query-callable types from the result
model.
Classes¶
Build one query; consume it through |
|
Require composable backend search expressions. |
|
Expose a queryable field of a search variable. |
|
Bind a query variable to a target type whose attributes yield fields. |
|
Require a store that can create a query searcher. |
|
The callback seam through which the request engine runs queries on a backend. |
|
The results of a query against a backend, as consumed by the entry endpoints. |
Module Contents¶
- class httk.serve.optimade.backend.protocols.Searcher[source]¶
Bases:
ProtocolBuild one query; consume it through
Searcher.results().The expressions received by
addare always ones produced by this same backend’s search variables, so implementations may type them as their own expression class; a backend that needs a second (post-filter) evaluation position decides that from the expression itself, not from the caller.
- class httk.serve.optimade.backend.protocols.SearchExpression[source]¶
Bases:
ProtocolRequire composable backend search expressions.
- class httk.serve.optimade.backend.protocols.SearchField[source]¶
Bases:
ProtocolExpose a queryable field of a search variable.
In addition to the methods below, fields support the rich comparison operators (
==,!=,<,<=,>,>=), returningSearchExpression. The handlers invoke those viagetattr(field, '__eq__')(value)since the comparison dunders cannot be typed as expression-returning.The three string-matching methods take literal text: no wildcard or pattern syntax whatsoever crosses this contract, so
%and_(and any other metacharacter) match themselves. A backend is therefore free to implement them with SQLLIKEover an escaped pattern, with a regular expression, or with a full-text index — the choice is invisible here.- is_in(*values)[source]¶
Match a root scalar field whose value is one of
values.Noneis an explicit member: it matches a null field value, and its negation excludes nulls rather than inheriting SQL’s three-valuedNOT IN (..., NULL)behavior.Backends define the corresponding semantics for child or set fields; for example, a backend may use the existing
has_only-style all-values reading for a child field.
- class httk.serve.optimade.backend.protocols.SearchVariable[source]¶
Bases:
ProtocolBind a query variable to a target type whose attributes yield fields.
always_true/always_falseare reserved names: they are real methods of the variable, never stored fields resolved through__getattr__. They exist so a translation layer can express a constant truth value without inventing a probe field. Afield == fieldprobe is NULL-unsound, since it yields NULL (not true) for a NULL field.links.<name>is a reserved relationship namespace: usable as a predicate root (v.links.p == other, field chaining, set operations) and, on its own, as a set-valued output declared throughSearcher.results().
- class httk.serve.optimade.backend.protocols.Store[source]¶
Bases:
ProtocolRequire a store that can create a query searcher.
Implementations predating the
as_ofkeyword may omit it and remain usable for current-state queries, but cannot honor historic queries.
- class httk.serve.optimade.backend.protocols.QueryFunction[source]¶
Bases:
ProtocolThe callback seam through which the request engine runs queries on a backend.
- class httk.serve.optimade.backend.protocols.QueryResults[source]¶
Bases:
ProtocolThe results of a query against a backend, as consumed by the entry endpoints.
Iteration yields one
ResultRowper entry; itsvaluesmap OPTIMADE response-field names to values, and theidandtypekeys are always present.