groundhog-sdk package is the synchronous Python client for the Groundhog v1 public API. It
connects to a running groundhog process over a Unix domain socket. Each SDK operation maps to
one public HTTP operation; durability, ordering, idempotency, and query confinement remain
Groundhog responsibilities.
Requirements
- Python 3.10 or newer.
- A running M1-compatible
groundhog serveprocess. - Access to its Unix socket and, when configured, its bearer token.
Installation
Install the published distribution from PyPI:groundhog-sdk; Python code imports groundhog_sdk.
For local development, install from a checkout of the SDK repository with
python -m pip install ..
Connect
Ground accepts:
endpoint must use the unix: scheme. unix:/absolute/path/ground.sock and
unix:relative/path/ground.sock are both accepted. With no explicit endpoint, the client uses
GROUND_URL, then unix:data/ground.sock. With no explicit token, it uses GROUND_TOKEN.
Explicit arguments take precedence over environment variables.
timeout is the transport timeout in seconds. max_retries is the number of attempts after the
initial request when a connection fails or Groundhog refuses admission with HTTP 429. Ingest
also retries a temporarily unavailable writer with capped exponential backoff. A 429 response’s
Retry-After value is honored.
Build events
The constructors produce exactly the connector-owned event fields. Payload values are retained without reshaping.occurred_at syntax, calendar dates, JSON-serializable payload values, finite numbers, malformed
Unicode, and the payload nesting limit before sending. Groundhog performs the authoritative
validation.
Ingest an atomic batch
send(source, events, batch_id) maps to one JSON POST /v1/events request. A batch must contain
between 1 and 10,000 events and its encoded body must not exceed 32 MiB. source follows the
Groundhog source-name grammar; system is reserved. batch_id must be non-empty, at most 256
UTF-8 bytes, and must not begin with the reserved groundhog/ prefix.
The entire batch is buffered and encoded once before the first attempt. If the connection closes
before a response arrives, the SDK retries those identical bytes with the same (source, batch_id). The result converges to one durable batch:
committedmeans this request durably appended the batch;duplicatemeans identical content was already durable and is equally safe;IdempotencyConflictmeans the batch ID was already committed with different content and is never retried.
BatchReceipt with either successful status.
Replay events
events() maps to one GET /v1/events request. Returned events are full fixed-column event
objects in authoritative event_id order. All arguments are optional. Filters are exact matches,
and after is exclusive.
Persist next_after, not last_event_id, as the next scan cursor. A filtered page can contain no
matching events while still advancing next_after past unrelated history. The other page fields
are:
The M1 client returns one page per call; it does not provide
follow or persistent cursor
storage.
Query a published snapshot
query(sql, limit=None, timeout_secs=None) maps to one JSON POST /v1/query request. The SDK
always requests the M1 JSON result form. The server accepts one confined read-only SELECT or
WITH statement and owns SQL validation, row limits, deterministic ordering requirements, and
timeouts.
QueryResult contains columns, array-shaped rows, the mandatory truncated flag, and a
SnapshotReceipt. Every relation read by one query comes from the warehouse generation named by
that receipt:
Replay reads the durable log immediately, while query reads the last published warehouse. Run
groundhog project or groundhog rebuild to publish newly ingested events. A live
groundhog serve process adopts a successful publication between requests.
Read the catalog
catalog(source=None, stream=None) maps to one GET /v1/catalog request. Both exact-match
filters are optional. CatalogResult.streams contains the published stream-level metadata, and
CatalogResult.receipt identifies the same coherent warehouse snapshot used to render it.
Errors
All SDK exceptions derive fromGroundError and retain the server’s message. Server-originated
errors also expose status and the decoded JSON body.
Per-event validation details are available through
ValidationError.errors:
Current M1 surface
The Python package currently exports:follow, persistent cursor helpers, async parity, Arrow or DataFrame adapters,
connector management, or Groundhog installation and process supervision.