graphddb-runtime
Thin DynamoDB executor for GraphDDB-generated Python repositories.
graphddb-runtime is the small, hand-written package that generated
repositories.py modules import as from graphddb_runtime import GraphDDBRuntime.
It interprets the manifest.json / operations.json specifications produced by
graphddb generate python and executes the validated access patterns against
DynamoDB through boto3 — no scans, no hand-written key logic.
Features
- Single-operation core —
GetItem/Queryreads andPutItem/UpdateItem/DeleteItemwrites. - Relations & assembly — relation traversal, multi-operation assembly,
BatchGetItem, result limits, andexplain. - Conditional & transactional writes — conditional writes, declarative
transactions (
execute_transaction, withforEach/whenexpansion andTransactWriteItemsbatching up to 25 items). - Async adapter —
AsyncGraphDDBRuntimeexposes anawait-able surface with behavior identical to the synchronous runtime.
Install
pip install graphddb-runtime
Requires Python 3.9+ and boto3.
Versioning.
graphddb-runtimetracks thegraphddbnpm package version: a given runtime release matches thegraphddbCLI of the same version, so the generatedmanifest.json/operations.jsonand the runtime that interprets them always stay in sync. Install thegraphddb-runtimewhose version equals thegraphddbCLI you generated with.
Usage
Point the runtime at the two JSON specs emitted by graphddb generate python
and pass a boto3 DynamoDB client. The generated repositories wrap it with typed
methods:
import boto3
from graphddb_runtime import GraphDDBRuntime
from generated import UserRepository
runtime = GraphDDBRuntime(
dynamodb_client=boto3.client("dynamodb"),
manifest_path="generated/manifest.json",
operations_path="generated/operations.json",
# Map logical table names to deployed physical names when they differ.
table_mapping={"UserPermissions": "UserPermissions-prod"},
)
users = UserRepository(runtime)
user = users.get_user_by_email(email="alice@example.com")
Async
boto3 is a synchronous SDK, so the runtime core is synchronous.
AsyncGraphDDBRuntime is a thin adapter that runs each blocking call in a worker
thread via asyncio.to_thread, giving an await-able surface with identical
behavior (same params, specs, results, and error types). It does not require
aioboto3.
import boto3
from graphddb_runtime import GraphDDBRuntime, AsyncGraphDDBRuntime
sync = GraphDDBRuntime(
dynamodb_client=boto3.client("dynamodb"),
manifest_path="generated/manifest.json",
operations_path="generated/operations.json",
)
runtime = AsyncGraphDDBRuntime(sync)
user = await runtime.execute_query("getUser", {"userId": "alice"})
await runtime.execute_transaction("addManyMembers", {"groupId": "eng", "members": [...]})
The wrapped synchronous runtime is available as runtime.sync for callers that
need the blocking API directly.
AWS Lambda
The runtime loads the JSON specs from disk and constructs a boto3 client — both are cold-start costs you want to pay once, in module scope, so they are reused across warm invocations (and frozen by SnapStart).
# handler.py — module scope runs once per execution environment (cold start).
import json
import boto3
from graphddb_runtime import GraphDDBRuntime
from generated import UserRepository
_runtime = GraphDDBRuntime(
dynamodb_client=boto3.client("dynamodb"),
manifest_path="generated/manifest.json",
operations_path="generated/operations.json",
table_mapping={"UserPermissions": "UserPermissions-prod"},
)
_users = UserRepository(_runtime)
def handler(event, context):
user = _users.get_user_by_email(email=event["queryStringParameters"]["email"])
if user is None:
return {"statusCode": 404, "body": "not found"}
return {"statusCode": 200, "body": json.dumps(user)}
SnapStart
Lambda SnapStart snapshots the initialized execution environment after the
module-scope code runs, so the global client + GraphDDBRuntime(...) construction
is captured in the snapshot and skipped on restore.
- Initialize the runtime and repositories in module scope (as above), never inside the handler — that is what gets snapshotted.
- Do not cache short-lived state across the snapshot (credentials/tokens with an expiry, random seeds). The DynamoDB client and the loaded specs are safe to snapshot; refresh anything time-sensitive inside the handler.
Packaging
The deployment artifact needs three things: this runtime package, the generated bindings, and the two JSON specs. boto3/botocore are provided by the Lambda Python runtime, so they need not be vendored (pin them only if you require a specific version).
mkdir -p build
pip install graphddb-runtime --target build # the runtime
cp -r generated build/generated # manifest.json, operations.json, *.py
cp handler.py build/
( cd build && zip -r ../function.zip . ) # handler = handler.handler
Make sure the manifest_path / operations_path you pass to GraphDDBRuntime
resolve relative to the deployed working directory (e.g. generated/... when the
specs are zipped under a generated/ folder at the artifact root).
License
MIT
Metadata
Release files for graphddb-runtime 0.8.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| graphddb_runtime-0.8.5.tar.gz | 146.0 kB | Without provenance | Details for graphddb_runtime-0.8.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| graphddb_runtime-0.8.5-py3-none-any.whl | Python 3 | none | any | Details for graphddb_runtime-0.8.5-py3-none-any.whl |
Total release size: 223.2 kB
Release files / graphddb_runtime-0.8.5.tar.gz
| Download URL | graphddb_runtime-0.8.5.tar.gz |
|---|---|
| Size | 146.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
610d12c22f3e6ad7adf0a27130cc1a63bf5e95fadbe5fc66c966a835d26e3736
|
|
BLAKE2b-256 checksum How to use checksums |
13ac409f4bb25e6ca3f55649ff3c5c3aca7ae7253410329e05a816b2a060af0e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.16
|
Release files / graphddb_runtime-0.8.5-py3-none-any.whl
| Download URL | graphddb_runtime-0.8.5-py3-none-any.whl |
|---|---|
| Size | 77.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
939c4b440c5d1d568ff0c20fb9625133a0f68a4dacb949f66d74c4da60bc386e
|
|
BLAKE2b-256 checksum How to use checksums |
6c0a0e017065bafb2abfec534e7f6c45d9f934e73545399f737705de39f2b4c6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.16
|
Security for graphddb-runtime 0.8.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.