Python
The Python binding (bindings/py-graphersal, package graphersal) has the packed snapshot, the
journal and recovery on graphersal.Graph, and the Store as graphersal.Store. Errors raise
graphersal.GraphersalError with the diagnostic and its help text. Build and test instructions:
bindings/py-graphersal/README.md.
Packed snapshots, journal and recovery
import graphersal
graph = graphersal.Graph.tinkerpop_modern()
graph.save("g.gsnap") # {"commit_seq", "vertex_count", "edge_count", "blobs_not_carried"}; name= optional; keeps its embedding models
graph = graphersal.Graph.load("g.gsnap") # no schema re-validation, checksummed; a snapshot over
# the process memory ceiling (graphersal.set_memory_limit) is refused
# before reading (Store.open too)
graph.start_journal("g.wal") # durability="every_commit" (default) | "os" | seconds
graph.execute('g.addV("person").property("name", "ann").next()')
graph.mark("after-ann") # {"name", "commit_seq", "time"}
graph, report = graphersal.Graph.recover("g.gsnap", ["g.wal"]) # to the end
graph, report = graphersal.Graph.recover("g.gsnap", ["g.wal"], mark="after-ann") # or commit_seq=, time=
Graph.recover takes one target: commit_seq=, time= (microseconds since the Unix epoch) or
mark=; without one it replays to the end. An interrupted last write is ignored
(report["torn_tail"]); damage raises GraphersalError with its location. The recovered graph
has no journal: save and start_journal again to continue (see
Journal and Recovery).
The Store
with graphersal.Store.create("data") as store: # or Store.open("data"); "x.gstore": one file
store.graph.execute('g.addV("person").property("name", "ann").next()') # durable when it returns
store.mark("after-ann")
store.checkpoint("nightly")
store.snapshots(); store.marks(); store.verify() # listings and the scrub
store.fork("branch", mark="after-ann") # a new store (commit_seq=, time=, mark=)
store.backup("bk") # full, then incremental: {"incremental", "commit_seq", ...}
store.open_report() # {"clean_close", "commit_seq", "commits_replayed", ...}
| Method | Does | Page |
|---|---|---|
Store.create(path, on_damage="maintenance"), Store.open(path) | create (missing or empty path; on_damage is the damage policy, fixed for the store's life) / open read-write, with recovery; a second writer raises | Opening and Closing |
Store.create_file(path), Store.open_file(path) | a single-file store (create/open of a .gstore path do the same) | |
store.graph | the store's Graph; every commit is durable before it returns | Commits |
store.close(), with ...: | a clean close; the graph refuses commits afterwards | |
store.open_report() | what the open did | |
store.workload_report(history=None) | the workload statistics: queries, property uses, lock times, jobs (Python's queries under the channel python); history="minutes"|"hours"|"days" adds every row's buckets | |
store.checkpoint(name=None) | write a snapshot | Checkpoints |
store.mark(name), store.marks() | name the position; list the marks | Marks |
store.snapshots() | the snapshots, oldest first | |
store.fork(path, commit_seq=, time=, mark=) | a new store from a point in time; the dict lists "marks_not_carried" | Fork |
store.rollback(commit_seq=, time=, mark=, delete=False) | roll back in place; the rest goes to the attic | Rollback |
store.attic(), store.attic_restore(id) | the attic entries; undo a rollback | |
store.backup(path, full=False, from_memory=False) | full or incremental backup, every checksum read in the store and in the copy (damage raises, nothing kept); from_memory=True after damage was found: the graph in memory, nothing written to the store | Backup and Restore |
store.store_id, store.damage_policy, store.damage_found, store.frozen_by_damage | the store id and the policy, fixed at creation; damage found on disk while the store is open; whether it turned read-only | Damage |
Store.open_backup(path), store.backup_marker | a backup, read-only; its marker | |
Store.restore_backup(path) | make a backup the live store (same graph id) | |
store.prune(up_to), store.compact(), store.compaction_advice(min_ratio=, min_reclaimable=, min_size=) | retention and disk space | Prune, Compact |
store.verify() | the scrub: {"ok", "problems", "notes"} | Verify |
store.models() | the embedding models the store keeps, with their licences (license, license_text), files and used_by_schema; the ones the schema names are registered when the store is opened (an embedders= embedder of the same model wins; a missing model is a UserWarning) | Embedding Models in a Store |
store.export(path, commit_seq=None, without_models=False) | the latest (or the given) stored snapshot as a .gsnap, with the store's models and their licences unless without_models=True: {"commit_seq", "models"} | Packed Snapshots |
store.maintenance | None, or the damage report of a store that opened read-only in maintenance mode | Damage |
store.repair_to(path) | a repaired copy: {"commit_seq", "lossless", "marks_not_carried", "lineage_approximate_before", "report"} | Damage |
Store.convert(source, target, single_file=False) | copy a closed store between a directory and a single file | Single-File Store |
Store.upgrade(source, target=None, in_place=False, single_file=False) | convert a store (or backup) of Graphersal 0.1.x to the current format, into target or in place | Format Versions |
with graphersal.Store.open_backup("bk") as backup: # read-only; backup.backup_marker
backup.snapshots()
graphersal.Store.restore_backup("bk") # the live store from now on: Store.open("bk")
with graphersal.Store.create("graph.gstore") as store: # one file
if store.compaction_advice()["recommended"]:
store.compact()
graphersal.Store.convert("graph.gstore", "data") # a closed store into a directory (or back)
graphersal.Store.upgrade("old_store", "new_store") # a store of Graphersal 0.1.x, upgraded (or in_place=True)
Times in Python are microseconds since the Unix epoch (time=), as in Rust.
The system journal
Every graph has a system journal of operational events (a store opened, a checkpoint written, a backup taken, a permission denied); a graph without a store keeps its newest records in memory.
page = store.journal(level="warn", since="2026-10-31T00:00:00Z") # or store.graph.journal(...)
for record in page["records"]: # oldest first
print(record["time"], record["level"], record["kind"], record["message"], record["fields"])
newer = store.journal(after=page["next_after"]) # only what came since
latest = store.journal(newest_first=True, limit=20) # the newest 20, newest first
older = store.journal(newest_first=True, before=latest["next_before"], limit=20)
graphersal.Store.journal_dir("data", kind="store.closed") # a closed store: no lock, nothing written
graphersal.Graph().journal() # a graph without a store: in memory
| Method | Does |
|---|---|
graph.journal(...) | the graph's journal (a Store's graph: the store's) |
store.journal(...) | the open store's journal: the records in journal/ plus the ones not yet written |
Store.journal_dir(path, ...) | the journal of the store in path without opening it (works while another process has it open, like graphersal store journal) |
All three take the same keyword arguments and answer one page, {"records", "next_after", "truncated", "more", "notes"}:
after: the cursor; pass the previous page'snext_afterto read what came since.moresays that another page follows;truncatedthat older records are gone from an in-memory journal;notesnames damaged stored records that were skipped.newest_first=True: the newest matching records, newest first (a stored journal is read from its end); the page then hasnext_before: pass it asbeforefor the next older page (moresays older ones exist), and itsnext_afterfollows what comes next.beforealso bounds an oldest-first page.since(at or after) anduntil(before): microseconds since the Unix epoch, a timezone-awaredatetime, or an ISO 8601 text with a zone (a naivedatetimeraisesValueError).level:"error","warn","notice"or"info", that level and the more severe ones;source: a source and the ones below it ("store"matches"store.backup");kind,op,origin(an instance id, a UUID text);limit(default 1000, at most 10000).policy: anAccessPolicythat must allow("read", "journal")(AccessPolicy.read_only()does), elsePermissionDeniedError; without one reading is allowed, like a script.
Each record is a dict with the keys of graphersal store journal --json: seq, origin
({"id", "name"}), origin_seq, time (microseconds since the Unix epoch), level, source,
kind, message, fields, and op, parent, commit, principal when set.