Skip to content

Sync API

Graph sync and materialization. See HYBRID.md and graph sync operations.

Targets

ontosql.sync.StoreSyncTarget

In-memory graph sync target backed by a TripleModel Store.

ontosql.sync.target.GraphSyncTarget

Bases: Protocol

Backing store that accepts incremental graph updates.

Push and remove

ontosql.sync.push_instance

push_instance(instance: OntoModel, target: GraphSyncTarget | Store, *, mapper: type[Any], mode: GraphSyncMode = 'patch', registry: Any | None = None, prior_nested_iris: set[str] | None = None) -> None

Push a semantic instance into a graph sync target.

ontosql.sync.remove_instance

remove_instance(instance: OntoModel, target: GraphSyncTarget | Store, *, mapper: type[Any], registry: Any | None = None, snapshot: dict[str, Any] | None = None) -> None

Remove an instance subgraph from a graph sync target.

Materialize from SQL

ontosql.sync.materialize.materialize_find

materialize_find(session: Any, entity_type: type[OntoModel], *, where: Any | None = None, order_by: Any | None = None, limit: int | None = None, offset: int | None = None, registry: PrefixRegistry | None = None) -> Store

Materialize find() results as a merged RDF graph (sync session).

ontosql.sync.materialize.materialize_find_async async

materialize_find_async(session: Any, entity_type: type[OntoModel], *, where: Any | None = None, order_by: Any | None = None, limit: int | None = None, offset: int | None = None, registry: PrefixRegistry | None = None) -> Store

Materialize await find() results as a merged RDF graph (async session).

Graph sync mode

ontosql.sync.graph.GraphSyncMode module-attribute

GraphSyncMode = Literal['add', 'replace', 'patch']

Session integration

Graph sync is configured on OntoSession / AsyncOntoSession via graph_sync= — see Session API.

Errors: GraphSyncError, GraphSyncFailuresession reference.