httk.serve.optimade.remote_query¶
Neutral synchronous query/result protocols over a remote OPTIMADE service.
Exceptions¶
A successful HTTP response was not a usable OPTIMADE entry document. |
|
A remote continuation was unsafe, malformed, or non-terminating. |
|
The service omitted a valid filtered |
Classes¶
Build one portable single-root OPTIMADE query. |
|
Expose one named scalar projection from a lazy result set. |
|
Represent a frozen, lazy, and re-iterable remote result plan. |
Module Contents¶
- exception httk.serve.optimade.remote_query.OptimadeResponseError[source]¶
Bases:
httk.serve.optimade.client.OptimadeClientErrorA successful HTTP response was not a usable OPTIMADE entry document.
- exception httk.serve.optimade.remote_query.OptimadePaginationError[source]¶
Bases:
OptimadeResponseErrorA remote continuation was unsafe, malformed, or non-terminating.
Bases:
OptimadeResponseError,httk.store.CountUnavailableErrorThe service omitted a valid filtered
meta.data_returnedcount.
- class httk.serve.optimade.remote_query.RemoteSearcher(store, *, response_fields=None)[source]¶
Build one portable single-root OPTIMADE query.
- Parameters:
store (httk.serve.optimade.client.OptimadeStore) – Remote OPTIMADE store used for discovery and requests.
response_fields (object) – Optional field-selection policy for this search.
- variable(target)[source]¶
Bind the query to one discovered remote entry type.
- Parameters:
target (object) – Discovered entry descriptor or registered backend class.
- Returns:
Query variable exposing portable fields.
- Raises:
httk.store.query.protocols.UnsupportedQueryError – If the target is not recognized or a root variable is already bound.
- Return type:
_RemoteVariable
- add(expression)[source]¶
Add a filter expression to the query.
- Parameters:
expression (object) – Expression created by this searcher.
- Raises:
ValueError – If no query variable is bound.
httk.store.UnsupportedQueryError – If the expression belongs elsewhere.
- output(variable, name)[source]¶
Declare a whole-record or scalar output.
- Parameters:
- Raises:
ValueError – If the name is empty or duplicated.
httk.store.UnsupportedQueryError – If the output belongs elsewhere.
- add_sort(field, descending=False)[source]¶
Append a sortable field to the remote query.
- Parameters:
- Raises:
httk.store.UnsupportedQueryError – If the field is not portable or sortable.
- set_limit(limit)[source]¶
Set the query result limit.
- Parameters:
limit (int) – Nonnegative limit, or a negative value for no bound.
- add_offset(offset)[source]¶
Advance the query offset.
- Parameters:
offset (int) – Nonnegative number of matching rows to skip.
- count()[source]¶
Return the filtered remote count.
- Returns:
meta.data_returnedreported by the service.- Raises:
CountUnavailableError – If the service omits a valid count.
- Return type:
- results(**outputs)[source]¶
Freeze the query as a lazy, re-iterable result set.
- Parameters:
**outputs (object) – Optional output names mapped to this searcher’s projections.
- Returns:
Frozen remote result plan.
- Raises:
ValueError – If no outputs are declared.
- Return type:
- class httk.serve.optimade.remote_query.RemoteResultColumn(result, index)[source]¶
Expose one named scalar projection from a lazy result set.
- Parameters:
result (RemoteResultSet) – Result set owning the projection.
index (int) – Zero-based projection index.
- class httk.serve.optimade.remote_query.RemoteResultSet(searcher, outputs=None)[source]¶
Represent a frozen, lazy, and re-iterable remote result plan.
- Parameters:
searcher (RemoteSearcher) – Search plan to clone.
outputs (collections.abc.Mapping[str, object] | None) – Optional output names mapped to the searcher’s projections.
- first()[source]¶
Return the first result, if present.
- Returns:
First row or
None.- Return type:
httk.store.ResultRow | None
- one()[source]¶
Return the only result.
- Returns:
Sole result row.
- Raises:
httk.store.NoResultError – If no result exists.
httk.store.MultipleResultsError – If more than one result exists.
- Return type:
- scalars(name=None)[source]¶
Iterate one named scalar output from each result.
- Parameters:
name (str | None) – Output name, or
Nonewhen exactly one exists.- Returns:
Iterator over scalar values.
- Raises:
KeyError – If the named output is unknown.
ValueError – If no name is given and multiple outputs exist.
- Return type:
- column(name)[source]¶
Return a lazy column for a scalar output.
- Parameters:
name (str) – Scalar output name.
- Returns:
Lazy result column.
- Raises:
- Return type:
- abstractmethod cursor()[source]¶
Reject unsupported cursor access.
- Returns:
Never; remote OPTIMADE cursors are unsupported.
- Raises:
NotImplementedError – Remote OPTIMADE cursors are unavailable.
- Return type: