proxystore.connectors.endpoint¶
Endpoint connector implementation.
EndpointConnectorError
¶
Bases: Exception
Exception raised when the endpoint connector fails.
This is raised when the connector cannot connect to any of its endpoints
or when a request fails. The error that caused the failure (e.g., an
endpoint was not running or a peer endpoint was not allowed) is the
__cause__ of the exception. The types of the causes are internal to
proxystore.endpoint so only the message should
be relied on.
EndpointKey
¶
EndpointConnector
¶
EndpointConnector(
endpoints: Sequence[str] | None = None,
proxystore_dir: str | PathLike[str] | None = None,
reconnect_timeout: float = 5,
request_timeout: float | None = REQUEST_TIMEOUT,
)
Connector to ProxyStore Endpoints.
Warning
Specifying a custom proxystore_dir can cause problems if the
proxystore_dir is not the same on all systems that a proxy
created by this store could end up on. It is recommended to leave
the proxystore_dir unspecified so the correct default directory
will be used.
Parameters:
-
endpoints(Sequence[str] | None, default:None) –IDs of the endpoints which the connector may use as its home endpoint, the local endpoint which all requests are sent to. The connector uses the first of these endpoints found in
proxystore_dirwhich it can connect to. This is not an allowlist: requests for objects stored on other endpoints are forwarded by the home endpoint, and which peers an endpoint communicates with is controlled by the allowlist of peers of each endpoint. The list is part of the connector's configuration so a proxy resolved on another system will use whichever of these endpoints is on that system. IfNone, the connector uses the only endpoint running inproxystore_dir. -
proxystore_dir(str | PathLike[str] | None, default:None) –Optionally specify the proxystore home directory. Defaults to
home_dir(). -
reconnect_timeout(float, default:5) –Seconds to keep trying to reconnect to the endpoint if it is unavailable (e.g., because it is restarting) before a request fails.
-
request_timeout(float | None, default:REQUEST_TIMEOUT) –Seconds a request to the local endpoint can go without sending or receiving any data, including while the endpoint handles the request, before it fails. Requests for objects on peer endpoints have no timeout in the client because the endpoint only responds once the peer does. If
None, requests have no timeout.
Raises:
-
ValueError–If endpoints is an empty list or contains an invalid endpoint ID, or if
request_timeoutis not positive. -
EndpointConnectorError–If unable to connect to any of the endpoints provided, or if
endpointsisNoneand there is not exactly one endpoint running inproxystore_dir.
Source code in proxystore/connectors/endpoint.py
close
¶
config
¶
Get the connector configuration.
The configuration contains all the information needed to reconstruct the connector object.
Source code in proxystore/connectors/endpoint.py
from_config
classmethod
¶
from_config(config: dict[str, Any]) -> EndpointConnector
Create a new connector instance from a configuration.
Parameters:
Source code in proxystore/connectors/endpoint.py
evict
¶
evict(key: EndpointKey) -> None
Evict the object associated with the key.
Parameters:
-
key(EndpointKey) –Key associated with object to evict.
Source code in proxystore/connectors/endpoint.py
exists
¶
exists(key: EndpointKey) -> bool
Check if an object associated with the key exists.
Parameters:
-
key(EndpointKey) –Key potentially associated with stored object.
Returns:
-
bool–If an object associated with the key exists.
Source code in proxystore/connectors/endpoint.py
get
¶
get(key: EndpointKey) -> BytesLike | None
Get the serialized object associated with the key.
Parameters:
-
key(EndpointKey) –Key associated with the object to retrieve.
Returns:
-
BytesLike | None–Serialized object or
Noneif the object does not exist.
Source code in proxystore/connectors/endpoint.py
get_batch
¶
get_batch(
keys: Sequence[EndpointKey],
) -> list[BytesLike | None]
Get a batch of serialized objects associated with the keys.
Parameters:
-
keys(Sequence[EndpointKey]) –Sequence of keys associated with objects to retrieve.
Note
Objects on peer endpoints are fetched at the same time (up to eight at a time, each with its own connection to the local endpoint) because each request waits for the peer to respond. Objects on the local endpoint are fetched one at a time while the peer requests run, because the local endpoint is not faster when sent requests at the same time.
Returns:
-
list[BytesLike | None]–List with same order as
keyswith the serialized objects orNoneif the corresponding key does not have an associated object.
Source code in proxystore/connectors/endpoint.py
new_key
¶
new_key(obj: BytesLike | None = None) -> EndpointKey
Create a new key.
Warning
The returned key will be associated with this instance's local
endpoint. I.e., when
set()
is called on this key, the connector must be connected to the same
local endpoint.
Parameters:
-
obj(BytesLike | None, default:None) –Optional object which the key will be associated with. Ignored in this implementation.
Returns:
-
EndpointKey–Key which can be used to retrieve an object once
set()has been called on the key.
Source code in proxystore/connectors/endpoint.py
put
¶
put(obj: BytesLike) -> EndpointKey
Put a serialized object in the store.
Parameters:
-
obj(BytesLike) –Serialized object to put in the store.
Returns:
-
EndpointKey–Key which can be used to retrieve the object.
Source code in proxystore/connectors/endpoint.py
put_batch
¶
put_batch(objs: Sequence[BytesLike]) -> list[EndpointKey]
Put a batch of serialized objects in the store.
Parameters:
Returns:
-
list[EndpointKey]–List of keys with the same order as
objswhich can be used to retrieve the objects.
Source code in proxystore/connectors/endpoint.py
set
¶
set(key: EndpointKey, obj: BytesLike) -> None
Set the object associated with a key.
Note
The Connector
provides write-once, read-many semantics. Thus,
set()
should only be called once per key, otherwise unexpected behavior
can occur.
Parameters:
-
key(EndpointKey) –Key that the object will be associated with.
-
obj(BytesLike) –Object to associate with the key.