Skip to main content

Client for Erubus — temporal knowledge graph for AI agents and robots

Project description

erubus (Python client)

Stdlib-only client for Erubus, a temporal knowledge graph for AI agents and robots. No dependencies.

pip install -e .          # or just copy erubus.py next to your code
python test_erubus.py     # unit tests (in-process HTTP stub; no server needed)
erubus serve &            # optional: live smoke tests run only if already up
from erubus import Erubus

kg = Erubus()                                  # http://127.0.0.1:8080
# Auth / namespace (optional; when set, sent on every request):
# kg = Erubus(token="abc123", ns="prod")       # Authorization: Bearer …, X-Erubus-Ns: …

kg.set_decay("vision:", half_life_secs=5)      # sensor beliefs go stale
kg.assert_fact("pallet-7", "at", "bay-3", confidence=0.9, source="vision:cam1")
# assert_fact defaults: confidence=1.0, source="python"; omit t → server stamps now

kg.value_at("pallet-7", "at")                  # t / known_at optional query params
# {'value': 'bay-3', 'effective_confidence': 0.87, 'server_time': ...}
# effective_confidence reflects set_decay half-lives (no separate decayed() call)

# What did the robot believe when it decided, not what was true:
kg.value_at("pallet-7", "at", t=20.0, known_at=decision_wall_clock)

kg.merge("bay 3", "Bay-03")                    # same entity, two spellings
kg.suggest_merge(q="bay 3")                    # fuzzy candidates (does not merge)
kg.context("pallet-7", depth=2)                # depth-bounded neighbourhood, not the whole reachable set
# context(root, depth=2, t=None): depth bounds nodes (server clamps to 4); no known_at

kg.set_schema("located_in", functional=True)   # schema registry
kg.get_schema()                                # {"relations": [...]}
kg.retention(86400)                            # drop closed edges older than 1d (server min 1h)
kg.backup("/tmp/erubus.db")                    # consistent snapshot → local file

for fact in kg.watch("pallet-7", reconnect=True):   # live SSE stream
    print(fact)

High-rate sensors should batch — one HTTP round-trip per fact is what makes a 30Hz loop expensive:

with kg.batch(max_size=256) as b:              # flushes at max_size and on exit
    for det in detections:
        b.add(det.id, "at", det.bay, confidence=det.score, source="vision:cam1")
# Or one-shot: kg.assert_facts([{...}, {...}]) → accepted count (or ErubusError)

Batches are all-or-nothing: if any fact is invalid (e.g. a clock-skewed timestamp or out-of-range confidence) the server rejects the whole batch, nothing lands, and the client raises ErubusError (not a partial success count), so retrying is safe.

All times are UTC epoch secondstime.time() is already correct. Omit t and the server stamps it. Optional query params (t, known_at) are omitted from the wire when not passed — never sent as null. Writes with a timestamp far in the future are rejected; call kg.clock_skew() to check your clock against the server's.

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

erubus-0.3.0.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

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

erubus-0.3.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file erubus-0.3.0.tar.gz.

File metadata

  • Download URL: erubus-0.3.0.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for erubus-0.3.0.tar.gz
Algorithm Hash digest
SHA256 eaf2d7156474a7e6cf6388db948ba70d6124ca6f66566b60839610f8449951ad
MD5 b70db27bc425962021ac5ab267641c64
BLAKE2b-256 f17d7342ae6db457266fb259b543533ea59adfc4a944cbc2cd8d3d82994ee8a7

See more details on using hashes here.

File details

Details for the file erubus-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: erubus-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for erubus-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e1ad4f24a3277c6426d982ea79a63ff92665a99f1cf638b3f1410e72a4273625
MD5 fd2cd5acc7cf211851f1db1a7eea7dbc
BLAKE2b-256 c280c560b900cb4139671ca61d75cb59bbad1f5ea67db5977ec1092fc72f9891

See more details on using hashes here.

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