Skip to content

Quickstart

Terminal window
pip install "hypermesh[engine]"

hm.connect() chooses the backend from the target: a filesystem path opens the embedded engine; an http(s):// URL returns a remote client.

import hypermesh as hm
# Embedded engine (build the index from a CSV on first open)
db = hm.connect("/var/lib/hypermesh/data", hyperedges_csv="hyperedges.csv")
# Or remote
# db = hm.connect("https://hypermesh.internal:8000", api_key="...")
res = db.execute(
"MATCH HYPEREDGE (he:CoProximity) "
"WHERE he.event_ts >= $start AND he.event_ts <= $end "
"RETURN *",
parameters={"start": 0, "end": 300},
)
print(res.num_tuples, "hyperedges")
for row in res:
print(row["event_ts"], row.members, row.weight)
print(res.query_plan) # TPI pushdown stats
db.insert(event_ts=9999, members=[1, 2, 3], weight=0.95, formation="WEDGE")
db.delete(event_ts=9999, members=[1, 2, 3])
db.compact()
db.close()

All SDK errors derive from hm.exceptions.HyperMeshError:

try:
db.execute("MATCH ...")
except hm.exceptions.QueryError:
...
except hm.exceptions.HyperMeshError:
...

The library is silent by default (NullHandler). Turn on debug logging:

hm.enable_debug_logging()