Skip to content

type_bridge.typed.remote_session

remote_session

Transport-neutral remote typed-query session over released composition.

RemoteQuerySession

RemoteQuerySession(authority, advertisement, exchange, limits)

Compose with the released grammar and execute through caller transport.

Source code in type_bridge/typed/remote_session.py
def __init__(
    self,
    authority: QueryV2Authority,
    advertisement: bytes,
    exchange: RemoteQueryExchange,
    limits: RemoteQueryLimits,
) -> None:
    if not isinstance(authority, QueryV2Authority):
        raise TypeError("RemoteQuerySession requires a QueryV2Authority")
    if type(advertisement) is not bytes:
        raise TypeError("RemoteQuerySession advertisement must be exact bytes")
    if not callable(exchange):
        raise TypeError("RemoteQuerySession exchange must be callable")
    if not isinstance(limits, RemoteQueryLimits):
        raise TypeError("RemoteQuerySession limits must be RemoteQueryLimits")

    context = query_v2_remote_model_context(
        authority,
        bytes(advertisement),
        limits.max_items,
        limits.max_bytes,
        limits.max_collection_members,
        limits.max_graph_nodes,
        limits.max_attribute_values,
        limits.max_role_players,
        limits.deadline_ms,
    )
    self.__direct = QuerySession._diagnostic()
    self.__runtime = _RemoteRuntime(context, exchange)

var

var(model: type[ModelT], *, subtypes: Literal[False] = False) -> BoundVar[ModelT]
var(model: type[ModelT], *, subtypes: Literal[True]) -> BoundVar[ModelT]
var(model, *, subtypes=False)

Delegate model registration and binding to the released session.

Source code in type_bridge/typed/remote_session.py
def var(self, model: type[ModelT], *, subtypes: bool = False) -> BoundVar[ModelT]:
    """Delegate model registration and binding to the released session."""
    return self.__direct.var(model, subtypes=subtypes)

exact

exact(model)

Create one exact binding through the released session.

Source code in type_bridge/typed/remote_session.py
def exact(self, model: type[ModelT]) -> BoundVar[ModelT]:
    """Create one exact binding through the released session."""
    return self.__direct.exact(model)

subtypes

subtypes(model)

Create one subtype-inclusive binding through the released session.

Source code in type_bridge/typed/remote_session.py
def subtypes(self, model: type[ModelT]) -> BoundVar[ModelT]:
    """Create one subtype-inclusive binding through the released session."""
    return self.__direct.subtypes(model)

reachable

reachable(source, target, relation, role_from, role_to, *, min_depth, max_depth)

Delegate bounded reachability to the released session.

Source code in type_bridge/typed/remote_session.py
def reachable[
    SourcePlayerT: TypeDBType,
    TargetPlayerT: TypeDBType,
    RelationT: Relation,
](
    self,
    source: _PlayerBinding[SourcePlayerT],
    target: _PlayerBinding[TargetPlayerT],
    relation: type[RelationT],
    role_from: RoleRef[SourcePlayerT, RelationT],
    role_to: RoleRef[TargetPlayerT, RelationT],
    *,
    min_depth: int,
    max_depth: int,
) -> Predicate:
    """Delegate bounded reachability to the released session."""
    return self.__direct.reachable(
        source,
        target,
        relation,
        role_from,
        role_to,
        min_depth=min_depth,
        max_depth=max_depth,
    )

query

query(selection1: Selection[T1]) -> RemoteQuery[T1]
query(selection1: Selection[T1], selection2: Selection[T2]) -> RemoteQuery[T1, T2]
query(selection1: Selection[T1], selection2: Selection[T2], selection3: Selection[T3]) -> RemoteQuery[T1, T2, T3]
query(selection1: Selection[T1], selection2: Selection[T2], selection3: Selection[T3], selection4: Selection[T4]) -> RemoteQuery[T1, T2, T3, T4]
query(selection1: Selection[T1], selection2: Selection[T2], selection3: Selection[T3], selection4: Selection[T4], selection5: Selection[T5]) -> RemoteQuery[T1, T2, T3, T4, T5]
query(selection1: Selection[T1], selection2: Selection[T2], selection3: Selection[T3], selection4: Selection[T4], selection5: Selection[T5], selection6: Selection[T6]) -> RemoteQuery[T1, T2, T3, T4, T5, T6]
query(selection1: Selection[T1], selection2: Selection[T2], selection3: Selection[T3], selection4: Selection[T4], selection5: Selection[T5], selection6: Selection[T6], selection7: Selection[T7]) -> RemoteQuery[T1, T2, T3, T4, T5, T6, T7]
query(selection1: Selection[T1], selection2: Selection[T2], selection3: Selection[T3], selection4: Selection[T4], selection5: Selection[T5], selection6: Selection[T6], selection7: Selection[T7], selection8: Selection[T8]) -> RemoteQuery[T1, T2, T3, T4, T5, T6, T7, T8]
query(selection1: Selection[T1], selection2: Selection[T2], selection3: Selection[T3], selection4: Selection[T4], selection5: Selection[T5], selection6: Selection[T6], selection7: Selection[T7], selection8: Selection[T8], selection9: Selection[T9]) -> RemoteQuery[T1, T2, T3, T4, T5, T6, T7, T8, T9]
query(selection1: Selection[T1], selection2: Selection[T2], selection3: Selection[T3], selection4: Selection[T4], selection5: Selection[T5], selection6: Selection[T6], selection7: Selection[T7], selection8: Selection[T8], selection9: Selection[T9], selection10: Selection[T10]) -> RemoteQuery[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]
query(selection1: Selection[T1], selection2: Selection[T2], selection3: Selection[T3], selection4: Selection[T4], selection5: Selection[T5], selection6: Selection[T6], selection7: Selection[T7], selection8: Selection[T8], selection9: Selection[T9], selection10: Selection[T10], selection11: Selection[T11]) -> RemoteQuery[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11]
query(selection1: Selection[T1], selection2: Selection[T2], selection3: Selection[T3], selection4: Selection[T4], selection5: Selection[T5], selection6: Selection[T6], selection7: Selection[T7], selection8: Selection[T8], selection9: Selection[T9], selection10: Selection[T10], selection11: Selection[T11], selection12: Selection[T12]) -> RemoteQuery[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12]
query(selection1: Selection[T1], selection2: Selection[T2], selection3: Selection[T3], selection4: Selection[T4], selection5: Selection[T5], selection6: Selection[T6], selection7: Selection[T7], selection8: Selection[T8], selection9: Selection[T9], selection10: Selection[T10], selection11: Selection[T11], selection12: Selection[T12], selection13: Selection[T13]) -> RemoteQuery[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13]
query(selection1: Selection[T1], selection2: Selection[T2], selection3: Selection[T3], selection4: Selection[T4], selection5: Selection[T5], selection6: Selection[T6], selection7: Selection[T7], selection8: Selection[T8], selection9: Selection[T9], selection10: Selection[T10], selection11: Selection[T11], selection12: Selection[T12], selection13: Selection[T13], selection14: Selection[T14]) -> RemoteQuery[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14]
query(selection1: Selection[T1], selection2: Selection[T2], selection3: Selection[T3], selection4: Selection[T4], selection5: Selection[T5], selection6: Selection[T6], selection7: Selection[T7], selection8: Selection[T8], selection9: Selection[T9], selection10: Selection[T10], selection11: Selection[T11], selection12: Selection[T12], selection13: Selection[T13], selection14: Selection[T14], selection15: Selection[T15]) -> RemoteQuery[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15]
query(selection1: Selection[T1], selection2: Selection[T2], selection3: Selection[T3], selection4: Selection[T4], selection5: Selection[T5], selection6: Selection[T6], selection7: Selection[T7], selection8: Selection[T8], selection9: Selection[T9], selection10: Selection[T10], selection11: Selection[T11], selection12: Selection[T12], selection13: Selection[T13], selection14: Selection[T14], selection15: Selection[T15], selection16: Selection[T16]) -> RemoteQuery[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16]
query(*selections)

Wrap one ordinary immutable positional query for remote terminals.

Source code in type_bridge/typed/remote_session.py
def query(self, *selections: Selection[object]) -> object:
    """Wrap one ordinary immutable positional query for remote terminals."""
    direct = self.__direct.query(*selections)
    return RemoteQuery._from_direct(direct, self.__runtime)

query_as

query_as(declaration, /, **selections)

Wrap one released named query for remote terminals.

Source code in type_bridge/typed/remote_session.py
def query_as[DeclaredRowT](
    self,
    declaration: type[DeclaredRowT],
    /,
    **selections: Selection[object],
) -> RemoteQuery[DeclaredRowT]:
    """Wrap one released named query for remote terminals."""
    direct = self.__direct.query_as(declaration, **selections)
    return RemoteQuery._from_direct(direct, self.__runtime)