unienv_interface.remote.client¶
Connect to a :class:RemoteServer and call hosted objects.
Classes:
| Name | Description |
|---|---|
SubscriptionEvent |
The result of a |
Subscription |
Iterator over the latest results of a hosted env (latest wins, never queued). |
RemoteClient |
A connection to a :class: |
SubscriptionEvent
¶
Bases: NamedTuple
The result of a reset / reload / step of a subscribed env.
Attributes:
| Name | Type | Description |
|---|---|---|
kind |
str
|
Name of the method that produced |
sequence |
int
|
Per-env call counter; gaps mean intermediate results were skipped. |
value |
Any
|
The method's return value, converted to the client's backend and device. |
Subscription
¶
Subscription(client: RemoteClient, name: str)
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.
Methods:
| Name | Description |
|---|---|
connect |
Connect to |
call |
Call an allowed |
resource |
The proxy of hosted resource |
env |
Proxy of a hosted |
world |
Proxy of a hosted |
node |
Proxy of a hosted |
transformation |
Proxy of a hosted |
subscribe |
Follow the |
close |
Close the connection (hosted objects stay open on the server). |
Attributes:
| Name | Type | Description |
|---|---|---|
closed |
|
|
resources |
Dict[str, Dict[str, Any]]
|
Descriptor of every hosted resource, by name. |
resources
instance-attribute
¶
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 = 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 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.