Source code for httk.optimade.model.results
from collections.abc import Iterator, Sequence
from dataclasses import dataclass, field
from typing import Any, Protocol
from httk.core import FilterAst
@dataclass(slots=True)
[docs]
class ResultRow:
"""One entry result: its attribute values plus per-entry envelope data."""
[docs]
relationships: dict[str, list[dict[str, Any]]] = field(default_factory=dict)
[docs]
class QueryResults(Protocol):
"""The results of a query against a backend, as consumed by the entry endpoints.
Iteration yields one :class:`~httk.optimade.model.results.ResultRow` per entry; its ``values`` map
OPTIMADE response-field names to values, and the ``id`` and ``type`` keys
are always present.
"""
[docs]
more_data_available: bool
[docs]
def count(self) -> int: ...
def __iter__(self) -> Iterator[ResultRow]: ...
[docs]
class QueryFunction(Protocol):
"""The callback seam through which the request engine runs queries on a backend."""
def __call__(
self,
entries: list[str],
response_fields: list[str],
unknown_response_fields: list[str],
page_limit: int,
page_offset: int,
filter_ast: FilterAst | None = None,
*,
sort: Sequence[tuple[str, bool]] | None = None,
debug: bool = False,
) -> QueryResults: ...