# langgraph-checkpoint-dynamodb
Implementation of a LangGraph CheckpointSaver that uses a AWS's DynamoDB
## Inspiration
Based on: https://github.com/researchwiseai/langgraphjs-checkpoint-dynamodb
## Required DynamoDB Tables
To be able to use this checkpointer, two DynamoDB table's are needed, one to store
checkpoints and the other to store writes. Below are some examples of how you
can create the required tables.
### Terraform
```hcl
# Variables for table names
variable "checkpoints_table_name" {
type = string
}
variable "writes_table_name" {
type = string
}
# Checkpoints Table
resource "aws_dynamodb_table" "checkpoints_table" {
name = var.checkpoints_table_name
billing_mode = "PAY_PER_REQUEST"
hash_key = "thread_id"
range_key = "checkpoint_id"
attribute {
name = "thread_id"
type = "S"
}
attribute {
name = "checkpoint_id"
type = "S"
}
}
# Writes Table
resource "aws_dynamodb_table" "writes_table" {
name = var.writes_table_name
billing_mode = "PAY_PER_REQUEST"
hash_key = "thread_id_checkpoint_id_checkpoint_ns"
range_key = "task_id_idx"
attribute {
name = "thread_id_checkpoint_id_checkpoint_ns"
type = "S"
}
attribute {
name = "task_id_idx"
type = "S"
}
}
```
### AWS CDK
```python
from aws_cdk import (
Stack,
aws_dynamodb as dynamodb,
)
from constructs import Construct
class DynamoDbStack(Stack):
def __init__(self, scope: Construct, id: str, **kwargs):
super().__init__(scope, id, **kwargs)
checkpoints_table_name = 'YourCheckpointsTableName'
writes_table_name = 'YourWritesTableName'
# Checkpoints Table
dynamodb.Table(
self,
'CheckpointsTable',
table_name=checkpoints_table_name,
billing_mode=dynamodb.BillingMode.PAY_PER_REQUEST,
partition_key=dynamodb.Attribute(
name='thread_id',
type=dynamodb.AttributeType.STRING,
),
sort_key=dynamodb.Attribute(
name='checkpoint_id',
type=dynamodb.AttributeType.STRING,
),
)
# Writes Table
dynamodb.Table(
self,
'WritesTable',
table_name=writes_table_name,
billing_mode=dynamodb.BillingMode.PAY_PER_REQUEST,
partition_key=dynamodb.Attribute(
name='thread_id_checkpoint_id_checkpoint_ns',
type=dynamodb.AttributeType.STRING,
),
sort_key=dynamodb.Attribute(
name='task_id_idx',
type=dynamodb.AttributeType.STRING,
),
)
```
## Using the Checkpoint Saver
### Default
To use the DynamoDB checkpoint saver, you only need to specify the names of
the checkpoints and writes tables. In this scenario the DynamoDB client will
be instantiated with the default configuration, great for running on AWS Lambda.
```python
from langgraph_checkpoint_dynamodb import DynamoDBSaver
...
checkpoints_table_name = 'YourCheckpointsTableName'
writes_table_name = 'YourWritesTableName'
memory = DynamoDBSaver(
checkpoints_table_name=checkpoints_table_name,
writes_table_name=writes_table_name,
)
graph = workflow.compile(checkpointer=memory)
```
### Providing Client Configuration
If you need to provide custom configuration to the DynamoDB client, you can
pass in an object with the configuration options. Below is an example of how
you can provide custom configuration.
```python
memory = DynamoDBSaver(
checkpoints_table_name=checkpoints_table_name,
writes_table_name=writes_table_name,
client_config={
'region': 'us-west-2',
'accessKeyId': 'your-access-key-id',
'secretAccessKey': 'your-secret-access-key',
}
)
```
Raw data
{
"_id": null,
"home_page": "https://github.com/justinram11/langgraph-checkpoint-dynamodb",
"name": "langgraph-checkpoint-dynamodb",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": null,
"author": "Justin Ramsey",
"author_email": "justin@rflow.io",
"download_url": "https://files.pythonhosted.org/packages/07/58/400d36651e29726a9d552b8d09d73baf70a48f70d86dab64894a28d927ce/langgraph_checkpoint_dynamodb-0.1.0.tar.gz",
"platform": null,
"description": "# langgraph-checkpoint-dynamodb\n\nImplementation of a LangGraph CheckpointSaver that uses a AWS's DynamoDB\n\n## Inspiration\n\nBased on: https://github.com/researchwiseai/langgraphjs-checkpoint-dynamodb\n\n## Required DynamoDB Tables\n\nTo be able to use this checkpointer, two DynamoDB table's are needed, one to store\ncheckpoints and the other to store writes. Below are some examples of how you\ncan create the required tables.\n\n### Terraform\n\n```hcl\n# Variables for table names\nvariable \"checkpoints_table_name\" {\n type = string\n}\n\nvariable \"writes_table_name\" {\n type = string\n}\n\n# Checkpoints Table\nresource \"aws_dynamodb_table\" \"checkpoints_table\" {\n name = var.checkpoints_table_name\n billing_mode = \"PAY_PER_REQUEST\"\n\n hash_key = \"thread_id\"\n range_key = \"checkpoint_id\"\n\n attribute {\n name = \"thread_id\"\n type = \"S\"\n }\n\n attribute {\n name = \"checkpoint_id\"\n type = \"S\"\n }\n}\n\n# Writes Table\nresource \"aws_dynamodb_table\" \"writes_table\" {\n name = var.writes_table_name\n billing_mode = \"PAY_PER_REQUEST\"\n\n hash_key = \"thread_id_checkpoint_id_checkpoint_ns\"\n range_key = \"task_id_idx\"\n\n attribute {\n name = \"thread_id_checkpoint_id_checkpoint_ns\"\n type = \"S\"\n }\n\n attribute {\n name = \"task_id_idx\"\n type = \"S\"\n }\n}\n```\n\n### AWS CDK\n\n```python\nfrom aws_cdk import (\n Stack,\n aws_dynamodb as dynamodb,\n)\nfrom constructs import Construct\n\nclass DynamoDbStack(Stack):\n def __init__(self, scope: Construct, id: str, **kwargs):\n super().__init__(scope, id, **kwargs)\n\n checkpoints_table_name = 'YourCheckpointsTableName'\n writes_table_name = 'YourWritesTableName'\n\n # Checkpoints Table\n dynamodb.Table(\n self,\n 'CheckpointsTable',\n table_name=checkpoints_table_name,\n billing_mode=dynamodb.BillingMode.PAY_PER_REQUEST,\n partition_key=dynamodb.Attribute(\n name='thread_id',\n type=dynamodb.AttributeType.STRING,\n ),\n sort_key=dynamodb.Attribute(\n name='checkpoint_id',\n type=dynamodb.AttributeType.STRING,\n ),\n )\n\n # Writes Table\n dynamodb.Table(\n self,\n 'WritesTable',\n table_name=writes_table_name,\n billing_mode=dynamodb.BillingMode.PAY_PER_REQUEST,\n partition_key=dynamodb.Attribute(\n name='thread_id_checkpoint_id_checkpoint_ns',\n type=dynamodb.AttributeType.STRING,\n ),\n sort_key=dynamodb.Attribute(\n name='task_id_idx',\n type=dynamodb.AttributeType.STRING,\n ),\n )\n```\n\n## Using the Checkpoint Saver\n\n### Default\n\nTo use the DynamoDB checkpoint saver, you only need to specify the names of\nthe checkpoints and writes tables. In this scenario the DynamoDB client will\nbe instantiated with the default configuration, great for running on AWS Lambda.\n\n```python\nfrom langgraph_checkpoint_dynamodb import DynamoDBSaver\n...\ncheckpoints_table_name = 'YourCheckpointsTableName'\nwrites_table_name = 'YourWritesTableName'\n\nmemory = DynamoDBSaver(\n checkpoints_table_name=checkpoints_table_name,\n writes_table_name=writes_table_name,\n)\n\ngraph = workflow.compile(checkpointer=memory)\n```\n\n### Providing Client Configuration\n\nIf you need to provide custom configuration to the DynamoDB client, you can\npass in an object with the configuration options. Below is an example of how\nyou can provide custom configuration.\n\n```python\nmemory = DynamoDBSaver(\n checkpoints_table_name=checkpoints_table_name,\n writes_table_name=writes_table_name,\n client_config={\n 'region': 'us-west-2',\n 'accessKeyId': 'your-access-key-id',\n 'secretAccessKey': 'your-secret-access-key',\n }\n)\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "DynamoDB Saver for LangGraph Checkpoints",
"version": "0.1.0",
"project_urls": {
"Homepage": "https://github.com/justinram11/langgraph-checkpoint-dynamodb"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "c9f354da77f0242523c1908481bcd99134cb413cdab63b933c7c214c5cb1fbea",
"md5": "05bbccbf1690be6d4784a92eabcfe9e1",
"sha256": "5992954728862b2a4b2f9947c989cedc9e945c526b9f6ecf42eb21f787fc6ce2"
},
"downloads": -1,
"filename": "langgraph_checkpoint_dynamodb-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "05bbccbf1690be6d4784a92eabcfe9e1",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 6615,
"upload_time": "2024-12-13T07:06:50",
"upload_time_iso_8601": "2024-12-13T07:06:50.657999Z",
"url": "https://files.pythonhosted.org/packages/c9/f3/54da77f0242523c1908481bcd99134cb413cdab63b933c7c214c5cb1fbea/langgraph_checkpoint_dynamodb-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "0758400d36651e29726a9d552b8d09d73baf70a48f70d86dab64894a28d927ce",
"md5": "4f44a9db071e0af4c4d281c5e4cd63bb",
"sha256": "7135d6ee58b1388421a0ef17c6659f031d1d42e1a33b3a5907b8deebe781e1d7"
},
"downloads": -1,
"filename": "langgraph_checkpoint_dynamodb-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "4f44a9db071e0af4c4d281c5e4cd63bb",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 5593,
"upload_time": "2024-12-13T07:06:53",
"upload_time_iso_8601": "2024-12-13T07:06:53.051762Z",
"url": "https://files.pythonhosted.org/packages/07/58/400d36651e29726a9d552b8d09d73baf70a48f70d86dab64894a28d927ce/langgraph_checkpoint_dynamodb-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-13 07:06:53",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "justinram11",
"github_project": "langgraph-checkpoint-dynamodb",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "aiohappyeyeballs",
"specs": [
[
"==",
"2.4.3"
]
]
},
{
"name": "aiohttp",
"specs": [
[
"==",
"3.11.8"
]
]
},
{
"name": "aiosignal",
"specs": [
[
"==",
"1.3.1"
]
]
},
{
"name": "annotated-types",
"specs": [
[
"==",
"0.7.0"
]
]
},
{
"name": "anyio",
"specs": [
[
"==",
"4.6.2.post1"
]
]
},
{
"name": "attrs",
"specs": [
[
"==",
"24.2.0"
]
]
},
{
"name": "boto3",
"specs": [
[
"==",
"1.35.71"
]
]
},
{
"name": "botocore",
"specs": [
[
"==",
"1.35.71"
]
]
},
{
"name": "certifi",
"specs": [
[
"==",
"2024.8.30"
]
]
},
{
"name": "charset-normalizer",
"specs": [
[
"==",
"3.4.0"
]
]
},
{
"name": "frozenlist",
"specs": [
[
"==",
"1.5.0"
]
]
},
{
"name": "h11",
"specs": [
[
"==",
"0.14.0"
]
]
},
{
"name": "httpcore",
"specs": [
[
"==",
"1.0.7"
]
]
},
{
"name": "httpx",
"specs": [
[
"==",
"0.28.0"
]
]
},
{
"name": "httpx-sse",
"specs": [
[
"==",
"0.4.0"
]
]
},
{
"name": "idna",
"specs": [
[
"==",
"3.10"
]
]
},
{
"name": "jmespath",
"specs": [
[
"==",
"1.0.1"
]
]
},
{
"name": "jsonpatch",
"specs": [
[
"==",
"1.33"
]
]
},
{
"name": "jsonpointer",
"specs": [
[
"==",
"3.0.0"
]
]
},
{
"name": "langchain",
"specs": [
[
"==",
"0.3.9"
]
]
},
{
"name": "langchain-core",
"specs": [
[
"==",
"0.3.21"
]
]
},
{
"name": "langchain-text-splitters",
"specs": [
[
"==",
"0.3.2"
]
]
},
{
"name": "langgraph",
"specs": [
[
"==",
"0.2.53"
]
]
},
{
"name": "langgraph-checkpoint",
"specs": [
[
"==",
"2.0.7"
]
]
},
{
"name": "langgraph-sdk",
"specs": [
[
"==",
"0.1.40"
]
]
},
{
"name": "langsmith",
"specs": [
[
"==",
"0.1.147"
]
]
},
{
"name": "msgpack",
"specs": [
[
"==",
"1.1.0"
]
]
},
{
"name": "multidict",
"specs": [
[
"==",
"6.1.0"
]
]
},
{
"name": "numpy",
"specs": [
[
"==",
"2.1.3"
]
]
},
{
"name": "orjson",
"specs": [
[
"==",
"3.10.12"
]
]
},
{
"name": "packaging",
"specs": [
[
"==",
"24.2"
]
]
},
{
"name": "propcache",
"specs": [
[
"==",
"0.2.0"
]
]
},
{
"name": "pydantic",
"specs": [
[
"==",
"2.10.2"
]
]
},
{
"name": "pydantic_core",
"specs": [
[
"==",
"2.27.1"
]
]
},
{
"name": "python-dateutil",
"specs": [
[
"==",
"2.9.0.post0"
]
]
},
{
"name": "PyYAML",
"specs": [
[
"==",
"6.0.2"
]
]
},
{
"name": "requests",
"specs": [
[
"==",
"2.32.3"
]
]
},
{
"name": "requests-toolbelt",
"specs": [
[
"==",
"1.0.0"
]
]
},
{
"name": "s3transfer",
"specs": [
[
"==",
"0.10.4"
]
]
},
{
"name": "setuptools",
"specs": [
[
"==",
"75.6.0"
]
]
},
{
"name": "six",
"specs": [
[
"==",
"1.16.0"
]
]
},
{
"name": "sniffio",
"specs": [
[
"==",
"1.3.1"
]
]
},
{
"name": "SQLAlchemy",
"specs": [
[
"==",
"2.0.36"
]
]
},
{
"name": "tenacity",
"specs": [
[
"==",
"9.0.0"
]
]
},
{
"name": "typing_extensions",
"specs": [
[
"==",
"4.12.2"
]
]
},
{
"name": "urllib3",
"specs": [
[
"==",
"2.2.3"
]
]
},
{
"name": "yarl",
"specs": [
[
"==",
"1.18.0"
]
]
}
],
"lcname": "langgraph-checkpoint-dynamodb"
}