proxystore_ex.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,
force_spawn_server: bool = False,
)
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
, default:None
) –The network IP to use for transfer. Has precedence over
interface
if both are provided. -
interface
(str | None
, default:None
) –The network interface to use.
addr
has precedence over this attribute if both are provided. -
timeout
(float
, default:1
) –Timeout in seconds to try connecting to a local server before spawning one.
-
force_spawn_server
(bool
, default:False
) –Force spawn a server rather than waiting to check if one is already running.
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_ex/connectors/dim/margo.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
|
close
¶
close(kill_server: bool = True) -> None
Close the connector.
Parameters:
-
kill_server
(bool
, default:True
) –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_ex/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_ex/connectors/dim/margo.py
from_config
classmethod
¶
from_config(config: dict[str, Any]) -> MargoConnector
Create a new connector instance from a configuration.
Parameters:
Source code in proxystore_ex/connectors/dim/margo.py
evict
¶
evict(key: DIMKey) -> None
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_ex/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_ex/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_ex/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_ex/connectors/dim/margo.py
put_batch
¶
Put a batch of serialized objects in the store.
Parameters:
Returns:
Source code in proxystore_ex/connectors/dim/margo.py
MargoServer
¶
MargoServer implementation.
Source code in proxystore_ex/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_ex/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_ex/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_ex/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_ex/connectors/dim/margo.py
start_server
¶
start_server(url: str) -> None
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_ex/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
) -> 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
, default:5.0
) –Max time in seconds to wait for the server to start.
-
kill_timeout
(float | None
, default:1.0
) –Max time in seconds to wait for the server to shutdown on exit.
Returns:
-
SpawnProcess
–The process that the server is running in.
Source code in proxystore_ex/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
, default:0.1
) –The max time in seconds to wait for server response.
Raises:
-
ServerTimeoutError
–If the server does not respond within the timeout.