proxystore.connectors.dim.margo¶
Margo RPC-based distributed in-memory connector implementation.
Protocol ¶
MargoConnector ¶
MargoConnector(
port: int,
protocol: Protocol | str,
address: str | None = None,
interface: str | None = None,
timeout: float = 1,
) -> None
Margo RPC-based distributed in-memory connector.
Note
The first instance of this connector created on a process will
spawn a MargoServer
that will store data. Hence, this connector just acts as an interface
to that server.
Parameters:
-
port
(
int
) –The desired port for the spawned server.
-
protocol
(
Protocol | str
) –The communication protocol to use.
-
address
(
str | None
) –The network IP to use for transfer. Has precedence over
interface
if both are provided. -
interface
(
str | None
) –The network interface to use.
addr
has precedence over this attribute if both are provided. -
timeout
(
float
) –Timeout in seconds to try connecting to a local server before spawning one.
Raises:
-
ServerTimeoutError
–If a local server cannot be connected to within
timeout
seconds, and a new local server does not respond withintimeout
seconds after being started.
Source code in proxystore/connectors/dim/margo.py
close() ¶
Close the connector.
Parameters:
-
kill_server
(
bool
) –Whether to kill the server process. If this instance did not spawn the local node's server process, this is a no-op.
Source code in proxystore/connectors/dim/margo.py
config() ¶
Get the connector configuration.
The configuration contains all the information needed to reconstruct the connector object.
Source code in proxystore/connectors/dim/margo.py
from_config()
classmethod
¶
Create a new connector instance from a configuration.
Parameters:
Source code in proxystore/connectors/dim/margo.py
evict() ¶
Evict the object associated with the key.
Parameters:
-
key
(
DIMKey
) –Key associated with object to evict.
exists() ¶
Check if an object associated with the key exists.
Parameters:
-
key
(
DIMKey
) –Key potentially associated with stored object.
Returns:
-
bool
–If an object associated with the key exists.
Source code in proxystore/connectors/dim/margo.py
get() ¶
Get the serialized object associated with the key.
Parameters:
-
key
(
DIMKey
) –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/dim/margo.py
get_batch() ¶
Get a batch of serialized objects associated with the keys.
Parameters:
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/dim/margo.py
put() ¶
Put a serialized object in the store.
Parameters:
-
obj
(
bytes
) –Serialized object to put in the store.
Returns:
-
DIMKey
–Key which can be used to retrieve the object.
Source code in proxystore/connectors/dim/margo.py
put_batch() ¶
Put a batch of serialized objects in the store.
Parameters:
Returns:
Source code in proxystore/connectors/dim/margo.py
MargoServer ¶
MargoServer implementation.
Source code in proxystore/connectors/dim/margo.py
evict() ¶
Remove key from local dictionary.
Parameters:
-
handle
(
Handle
) –The client handle.
-
bulk_str
(
Bulk
) –The buffer that will store shared data.
-
bulk_size
(
int
) –The size of the data to be received.
-
key
(
DIMKey
) –The data's key.
Source code in proxystore/connectors/dim/margo.py
exists() ¶
Check if key exists within local dictionary.
Parameters:
-
handle
(
Handle
) –The client handle.
-
bulk_str
(
Bulk
) –The buffer that will store shared data.
-
bulk_size
(
int
) –The size of the data to be received.
-
key
(
DIMKey
) –The data's key.
Source code in proxystore/connectors/dim/margo.py
get() ¶
Return data at a given key back to the client.
Parameters:
-
handle
(
Handle
) –The client handle.
-
bulk_str
(
Bulk
) –The buffer that will store shared data.
-
bulk_size
(
int
) –The size of the data to be received.
-
key
(
DIMKey
) –The data's key.
Source code in proxystore/connectors/dim/margo.py
put() ¶
Obtain data from the client and store it in local dictionary.
Parameters:
-
handle
(
Handle
) –The client handle.
-
bulk_str
(
Bulk
) –The buffer containing the data to be shared.
-
bulk_size
(
int
) –The size of the data being transferred.
-
key
(
DIMKey
) –The data key.
Source code in proxystore/connectors/dim/margo.py
start_server() ¶
Start and wait on a Margo server.
Parameters:
-
url
(
str
) –URL of the engine that will be started. Should take the form
{protocol}://{host}:{port}
.
Source code in proxystore/connectors/dim/margo.py
spawn_server() ¶
spawn_server(
protocol: str,
address: str,
port: int,
*,
spawn_timeout: float = 5.0,
kill_timeout: float | None = 1.0
) -> multiprocessing.context.SpawnProcess
Spawn a local server running in a separate process.
Note
An atexit
callback is registered which will terminate the spawned
server process when the calling process exits.
Parameters:
-
protocol
(
str
) –Communication protocol.
-
address
(
str
) –Host IP of the server to wait on.
-
port
(
int
) –Port of the server to wait on.
-
spawn_timeout
(
float
) –Max time in seconds to wait for the server to start.
-
kill_timeout
(
float | None
) –Max time in seconds to wait for the server to shutdown on exit.
Returns:
-
multiprocessing.context.SpawnProcess
–The process that the server is running in.
Source code in proxystore/connectors/dim/margo.py
wait_for_server() ¶
Wait until the server responds.
Warning
Due to how Margo blocks internally, the timeout is not very accurate.
Parameters:
-
protocol
(
str
) –Communication protocol.
-
address
(
str
) –Host IP of the server to wait on.
-
port
(
int
) –Port of the server to wait on.
-
timeout
(
float
) –The max time in seconds to wait for server response.
Raises:
-
ServerTimeoutError
–If the server does not respond within the timeout.