etha.kvstore.etcd#

EtcdStore implementation using etcd3 library.

Attributes#

Classes#

EtcdStore

KVStore implementation backed by etcd.

Module Contents#

class etha.kvstore.etcd.EtcdStore(host: str = 'localhost', port: int = 2379, timeout: float | None = None, cleanup: bool = False, namespace: str = 'default', component: str = 'tensorbus')#

Bases: etha.kvstore.base.KVStore

KVStore implementation backed by etcd.

Uses etcd’s watch mechanism for efficient waiting.

Initialize EtcdStore.

Parameters:
  • host – etcd server host

  • port – etcd server port

  • timeout – Connection timeout in seconds

  • cleanup – If True, delete all keys in this namespace on init (should only be True for rank 0)

  • namespace – Namespace for key isolation

  • component – Default component name

close(cleanup: bool = True) None#

Close the etcd client.

delete(key: str, *, component: str | None = None) bool#

Delete a key.

exists(key: str, *, component: str | None = None) bool#

Check if a key exists.

get(key: str, *, component: str | None = None) bytes | None#

Get value for a key.

get_bytes(key: str, *, component: str | None = None) bytes | None#

Retrieve binary data directly.

set(key: str, value: str, *, component: str | None = None) None#

Set a key-value pair.

set_bytes(key: str, data: bytes, *, component: str | None = None) None#

Store binary data directly.

wait_for_key(key: str, timeout: float = 3600.0, *, component: str | None = None) bytes#

Wait for a key to exist and return its value.

wait_for_keys(key_pattern: str, expected_count: int, value: str = '1', timeout: float = 3600.0, candidate_keys: list[str] | None = None, *, component: str | None = None) list[str]#

Wait for keys matching pattern using etcd watch.

wait_for_value(key: str, expected: str, timeout: float = 3600.0, *, component: str | None = None) bytes#

Wait for a key to have a specific value.

host = 'localhost'#
port = 2379#
etha.kvstore.etcd.logger#