Skip to content

hyperion.adapters.keyval.dynamodb

hyperion.adapters.keyval.dynamodb

DynamoDB-backed :class:KeyValueStore adapter (requires boto3 -- [aws]).

The table must have a key attribute and a value attribute.

DynamoDBStore

DynamoDBStore(prefix=None, compression=None, table_name=None, key_attribute='key', value_attribute='value')

Bases: KeyValueStore

A key-value store using DynamoDB.

The table must have a key attribute and a value attribute.

Source code in hyperion/adapters/keyval/dynamodb.py
def __init__(
    self,
    prefix: str | None = None,
    compression: CompressionType | None = None,
    table_name: str | None = None,
    key_attribute: str = "key",
    value_attribute: str = "value",
):
    super().__init__(prefix, compression)
    self.client = boto3.resource("dynamodb")
    if table_name is None:
        raise ValueError("No table name provided for DynamoDBStore.")
    self.table_name = table_name
    self.table = self.client.Table(self.table_name)
    self.key_attribute = key_attribute
    self.value_attribute = value_attribute