Skip to content

VersionedGraphCollection "Redo" Doesn't Bring Changes Back to Same Graph Name #98

@rileywong311

Description

@rileywong311

It appears that redo() for the VersionedGraphCollection, although indeed adding the changeset back to the collection, it doesn't do it under the same graph name. So if I serialize the entire graph collection after undoing and redoing, it appears in the graph/file, but if I serialize only the specific graph I specified originally, it no longer appears in the file even though it is part of the graph collection.

from brickschema.persistent import VersionedGraphCollection, Changeset
from brickschema.namespaces import A, BRICK
from rdflib import Namespace

vg = VersionedGraphCollection("sqlite://")

BLDG = Namespace("test:") 

with vg.new_changeset("my-building") as cs:
    cs.add((BLDG.zone1, A, BRICK.HVAC_Zone))

with vg.new_changeset("my-building") as cs:
    cs.add((BLDG.zone2, A, BRICK.HVAC_Zone))

vg.undo()
vg.redo()

vg.serialize("UndoRedo1.ttl") # serialize the entire graph collection
vg.graph_at(graph="my-building").serialize("UndoRedo2.ttl") # serialize only the graph "my-building"

A potential fix that seems to work might be this (persistent.py on line 171):

# persistent.py
# redo():
triple = pickle.loads(row["triple"])
graph = self.get_context(redo_record["graph"])
if row["is_insertion"]:
  graph.remove((triple[0], triple[1], triple[2]))
else:
  graph.add((triple[0], triple[1], triple[2]))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions