academy.exchange.proxystore¶
ProxyStoreExchangeTransport
¶
ProxyStoreExchangeTransport(
transport: ExchangeTransportT,
store: Store[Any],
should_proxy: Callable[[Any], bool],
*,
resolve_async: bool = False
)
Bases: ExchangeTransportMixin, NoPickleMixin, Generic[ExchangeTransportT]
ProxyStore exchange client bound to a specific mailbox.
Source code in academy/exchange/proxystore.py
ProxyStoreExchangeFactory
¶
ProxyStoreExchangeFactory(
base: ExchangeFactory[ExchangeTransportT],
store: Store[Any] | None,
should_proxy: Callable[[Any], bool],
*,
resolve_async: bool = False
)
Bases: ExchangeFactory[ProxyStoreExchangeTransport[ExchangeTransportT]]
ProxStore exchange client factory.
A ProxyStore exchange is used to wrap an underlying exchange so large objects may be passed by reference.
Parameters:
-
base(ExchangeFactory[ExchangeTransportT]) –Base exchange factory.
-
store(Store[Any] | None) –Store to use for proxying data.
-
should_proxy(Callable[[Any], bool]) –A callable that returns
Trueif an object should be proxied. This is applied to every positional and keyword argument and result value. -
resolve_async(bool, default:False) –Resolve proxies asynchronously when received.
Source code in academy/exchange/proxystore.py
create_agent_client
async
¶
create_agent_client(
registration: AgentRegistration[AgentT],
request_handler: RequestHandler[RequestT_co],
) -> AgentExchangeClient[AgentT, ExchangeTransportT]
Create a new agent exchange client.
An agent must be registered with the exchange before an exchange client can be created. For example:
factory = ExchangeFactory(...)
user_client = factory.create_user_client()
registration = user_client.register_agent(...)
agent_client = factory.create_agent_client(registration, ...)
Parameters:
-
registration(AgentRegistration[AgentT]) –Registration information returned by the exchange.
-
request_handler(RequestHandler[RequestT_co]) –Agent request message handler.
Returns:
-
AgentExchangeClient[AgentT, ExchangeTransportT]–Agent exchange client.
Raises:
-
BadEntityIdError–If an agent with
registration.agent_idis not already registered with the exchange.
Source code in academy/exchange/factory.py
create_user_client
async
¶
create_user_client(
*, name: str | None = None, start_listener: bool = True
) -> UserExchangeClient[ExchangeTransportT]
Create a new user in the exchange and associated client.
Parameters:
-
name(str | None, default:None) –Display name of the client on the exchange.
-
start_listener(bool, default:True) –Start a message listener thread.
Returns:
-
UserExchangeClient[ExchangeTransportT]–User exchange client.