proxystore.connectors.protocols¶
Connector protocol.
Connector
¶
Bases: Protocol[KeyT]
Connector protocol for interfacing with external object storage.
The Connector protocol defines the interface for interacting with a byte-level object store.
close
¶
config
¶
Get the connector configuration.
The configuration contains all the information needed to reconstruct the connector object.
Returns:
from_config
classmethod
¶
Create a new connector instance from a configuration.
Parameters:
Returns:
Source code in proxystore/connectors/protocols.py
evict
¶
Evict the object associated with the key.
Parameters:
-
key
(KeyT
) –Key associated with object to evict.
exists
¶
exists(key: KeyT) -> bool
Check if an object associated with the key exists.
Parameters:
-
key
(KeyT
) –Key potentially associated with stored object.
Returns:
-
bool
–If an object associated with the key exists.
get
¶
get(key: KeyT) -> bytes | None
Get the serialized object associated with the key.
Parameters:
-
key
(KeyT
) –Key associated with the object to retrieve.
Returns:
-
bytes | None
–Serialized object or
None
if the object does not exist.
Source code in proxystore/connectors/protocols.py
get_batch
¶
Get a batch of serialized objects associated with the keys.
Parameters:
-
keys
(Sequence[KeyT]
) –Sequence of keys associated with objects to retrieve.
Returns:
-
list[bytes | None]
–List with same order as
keys
with the serialized objects orNone
if the corresponding key does not have an associated object.
Source code in proxystore/connectors/protocols.py
put
¶
put(obj: bytes) -> KeyT
Put a serialized object in the store.
Parameters:
-
obj
(bytes
) –Serialized object to put in the store.
Returns:
-
KeyT
–Key which can be used to retrieve the object.
DeferrableConnector
¶
Bases: Protocol[KeyT]
Extension of the Connector
with set
semantics.
Extends the Connector
protocol with additional methods necessary for creating a key while
deferring associated an object with the key.
new_key
¶
new_key(obj: bytes | None = None) -> KeyT
Create a new key.
Note
Implementations may choose to require the object be provided, or place restrictions on the scope of the key.
Parameters:
-
obj
(bytes | None
, default:None
) –Optional object which the key will be associated with.
Returns:
-
KeyT
–Key which can be used to retrieve an object once
set()
has been called on the key.
Source code in proxystore/connectors/protocols.py
set
¶
set(key: KeyT, obj: bytes) -> 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.
Warning
This method is not required to be atomic and could therefore
result in race conditions with calls to
get()
.
Parameters:
-
key
(KeyT
) –Key that the object will be associated with.
-
obj
(bytes
) –Object to associate with the key.