unienv_interface.remote.client¶
Connect to a :class:RemoteServer and call hosted objects.
SubscriptionEvent
¶
Bases: NamedTuple
The result of a reset / reload / step of a subscribed env.
Subscription
¶
Subscription(client: RemoteClient, name: str)
Iterator over the latest results of a hosted env (latest wins, never queued).
Use it as a context manager or call :meth:close; next(timeout=...)
raises TimeoutError if no new result arrives in time.
RemoteClient
¶
RemoteClient(transport: Transport, *, backend: ComputeBackend = NumpyComputeBackend, device: Optional[Any] = None, timeout: Optional[float] = None, compress: Optional[Dict[str, str]] = None)
A connection to a :class:RemoteServer. Thread-safe: calls may be concurrent.
Results are converted to backend arrays on device. A remote exception
is re-raised as :class:RemoteError; a lost connection raises
ConnectionError, in which case a call that was in flight may or may not
have run on the server. timeout (seconds, None = wait forever) bounds
each call; a timed-out call keeps running on the server.
resources
instance-attribute
¶
resources: Dict[str, Dict[str, Any]] = hello['resources']
Descriptor of every hosted resource, by name.
connect
classmethod
¶
connect(address: str, *, timeout: Optional[float] = None, connect_timeout: float = 10.0, backend: ComputeBackend = NumpyComputeBackend, device: Optional[Any] = None, compress: Optional[Dict[str, str]] = None, max_frame_size: int = wire.DEFAULT_MAX_FRAME_SIZE) -> RemoteClient
Connect to tcp://host:port, unix:///path or ws://host:port.
compress opts into lossy compression of server-to-client data, e.g.
{"image": "jpeg:90"} JPEG-encodes uint8 image leaves (spaces whose
metadata["kind"] == "image") at quality 90.
call
¶
call(name: str, method: str, *args: Any, **kwargs: Any) -> Any
Call an allowed method of the hosted resource name.
resource
¶
resource(name: str) -> Union[RemoteEnv, RemoteWorld, RemoteWorldNode, RemoteDataTransformation]
The proxy of hosted resource name (one shared proxy per name).
world
¶
world(name: str) -> RemoteWorld
Proxy of a hosted World (e.g. "sim/world" for a WorldEnv registered recursively as "sim").
node
¶
node(name: str) -> RemoteWorldNode
Proxy of a hosted WorldNode (e.g. "sim/node", "sim/node/camera").
transformation
¶
transformation(name: str) -> RemoteDataTransformation
Proxy of a hosted DataTransformation.
subscribe
¶
subscribe(name: str) -> Subscription
Follow the reset / reload / step results of hosted env name.
Results of calls by any client are delivered, latest wins: a slow subscriber skips results rather than slowing the server down.