httk.optimade.backend.translation¶
Translation of OPTIMADE filter syntax trees into backend search expressions.
The generic translation is implemented in httk.data.optimade_query;
translate_filter() delegates to
translate_filter_ast() and wraps its neutral
FilterTranslationError failure categories
into TranslatorError HTTP errors.
format_value() and translate_filter_node() are thin
OPTIMADE-side wrappers over the upstream functions.
Functions¶
|
Convert a filter value and translate neutral failures to HTTP errors. |
|
Build one searcher per entry source, with the filter applied to each. |
|
Translate one filter node against an OPTIMADE entry-info property mapping. |
Module Contents¶
- httk.optimade.backend.translation.format_value(fulltype: str, val: tuple[Any, Ellipsis], allow_null: bool = False) Any[source]¶
Convert a filter value and translate neutral failures to HTTP errors.
Delegates to
httk.data.optimade_query.format_value()and raisesTranslatorErrorfor its neutralFilterTranslationErrorfailures.
- httk.optimade.backend.translation.translate_filter(filter_ast: httk.core.FilterAst | None, entries: list[str], adapter: httk.optimade.backend.adapter.BackendAdapter, sort: collections.abc.Sequence[tuple[str, bool]] | None = None) list[tuple[httk.optimade.backend.adapter.EntrySource, httk.data.query.Searcher]][source]¶
Build one searcher per entry source, with the filter applied to each.
Relationship-property filters (dotted identifiers over served entry types) are resolved through the adapter’s related-property resolver (built by
_related_property_resolver), so filteringreferences.doibehaves exactly like filtering/referencesdirectly.
- httk.optimade.backend.translation.translate_filter_node(node: httk.core.FilterAst, search_variable: httk.data.query.SearchVariable, entry: str, entry_info: collections.abc.Mapping[str, Any], handlers: httk.data.optimade_query.HandlerTable, recognized_prefixes: tuple[str, Ellipsis], served_entries: tuple[str, Ellipsis] = ()) httk.data.query.SearchExpression[source]¶
Translate one filter node against an OPTIMADE entry-info property mapping.
An OPTIMADE-side adaptation of
translate_filter_ast():entry_infomaps property names to their property dictionaries (only their'fulltype'keys are read) rather than straight to fulltypes,served_entriesnames the relationship targets, and failures surface asTranslatorErrorinstead of the upstream neutralFilterTranslationError.No related-property resolver is threaded through, so relationship-property filters other than
<type>.id HAS ...raise a not-implemented (501) error. Usetranslate_filter()(which builds the resolver from its adapter) for full relationship-property filtering.