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.1.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.1-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: erubus-0.3.1.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.1.tar.gz
Algorithm Hash digest
SHA256 c2786297f84bf049c9785be0f6251b3afb5528e253dc60ba147941e81a0c641e
MD5 662e21b16a2c8d2ae9fd930146e95614
BLAKE2b-256 e7ffb1a369405f1add077d8965acb001dac8e4c019c555c2ce2b54c03bb80155

See more details on using hashes here.

File details

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

File metadata

  • Download URL: erubus-0.3.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0d68390b5bc43c809784f056b9d1030ac4293f0d00ea035057c76e0e2d4f5e0b
MD5 ab87c4e1efefd199f014204eba988417
BLAKE2b-256 ec2c4d73ea53d1e33ed0d66b36c0f11012d8672a6a777c96516bcf6c9cd15616

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