Skip to main content

Python client SDK for Lantern, an in-memory graph key-vertex-store served over gRPC.

Project description

lantern-sdk (Python)

Python client SDK for Lantern, an in-memory graph key-vertex-store served over gRPC. Mirrors the Go SDK feature set: single + batch vertex/edge operations, prefix scans, prefix delete, Illuminate (k-bounded BFS with TF-IDF / MST / SPT post-processing), and the gRPC health check.

v0.1.x is sync-only (grpc blocking stubs). An asyncio companion built on grpc.aio is planned for v0.2; see the tracking issue.

Install

Distributed on PyPI as lantern-sdk; the Python import package name remains lantern_client.

pip install lantern-sdk
# or with uv
uv add lantern-sdk

Quick start

from lantern_client import Lantern

with Lantern.connect("localhost:6380") as cli:
    cli.put_vertex("user:1", {"name": "alice"}, ttl_seconds=3600)
    v = cli.get_vertex("user:1")
    print(v)  # Vertex(key='user:1', value={'name': 'alice'}, ...)

    cli.add_edge("user:1", "post:42", weight=1.5, ttl_seconds=3600)
    graph = cli.illuminate("user:1", step=2, k=10)
    print(graph.vertices, graph.edges)

Lantern.connect accepts the same target forms as the Go SDK:

  • "host:port" — single endpoint.
  • "dns:///host:port" — DNS fan-out with round-robin load balancing.
  • Lantern.connect_endpoints([...]) — explicit static endpoint list.

See examples/quickstart.py for the full surface.

Value types

put_vertex accepts native Python values; the SDK picks the right protobuf oneof variant. Supported types: int, float, bool, str, bytes, datetime.datetime, datetime.timedelta, None (tombstone).

int values land in int64 or uint64 based on sign; float always lands in float64. Use the explicit constructors in lantern_client.values (int32, uint32, float32) to pin a narrower wire type. Reading is symmetric — vertex.value returns the natural Python type; vertex.kind is the VertexKind enum if you need to dispatch without isinstance.

Codegen

Generated protobuf / gRPC stubs live under src/lantern_client/_pb/ and are committed to the repo, mirroring how Lantern's Go module keeps pb/ in-tree. To regenerate after a .proto change:

uv run --dev scripts/codegen.sh

License

Apache-2.0 — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lantern_sdk-0.1.1.tar.gz (28.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lantern_sdk-0.1.1-py3-none-any.whl (33.4 kB view details)

Uploaded Python 3

File details

Details for the file lantern_sdk-0.1.1.tar.gz.

File metadata

  • Download URL: lantern_sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 28.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for lantern_sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 52c09f266e71bc5025050ca1fa66d02388a90e05157686bb32192050fabb24bf
MD5 1c5841bab68919b2fed65c55d7b558d6
BLAKE2b-256 dd30a487bb8b9e6cb306da1b4f5c6ff07ff60339f964a43cb7bf0bd0cd96d8fe

See more details on using hashes here.

Provenance

The following attestation bundles were made for lantern_sdk-0.1.1.tar.gz:

Publisher: python-sdk.yml on anaregdesign/lantern

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lantern_sdk-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: lantern_sdk-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 33.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for lantern_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6bfa0d3bb3c5a4d81a6735766280ba70c9cf4665ce737fd3a9a5df3b0c3d7e56
MD5 eb143faccf89bd6f22323eae344800da
BLAKE2b-256 11cb33a10d134ee017dc7ea5b4cca4124717d36e21aa59da83c874b10dd36d73

See more details on using hashes here.

Provenance

The following attestation bundles were made for lantern_sdk-0.1.1-py3-none-any.whl:

Publisher: python-sdk.yml on anaregdesign/lantern

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page