Skip to content

Keep in step with Workspace

Your application can follow the project’s changes instead of polling everything. client is an ophiolite.Client for your project — see Build on Ophiolite for a key and the SDK.

sync = client.sync("state/checkpoint.json")
first = sync.run() # the first run reads everything you may read, then saves a checkpoint

Later — in the same process or after a restart — catch up from the checkpoint:

before = sync.checkpoint.values["cursor"]
changed = sync.run() # only the changes after the checkpoint
events = [e for page in sync.changes(sync.checkpoint.values["epoch"], before) for e in page["changes"]]
print(changed, [(e["kind"], e["subject_id"]) for e in events])

An event names what changed (subject_kind, subject_id); it never carries the new state. Read the subject again before acting (sync.cache already holds the refreshed wells, assets and result groups). For live changes, iterate sync.follow(); it resumes where it stopped after a reconnect. ophiolite init sync-worker starts a worker that does this.