The Storing notebook showed that the store metadata can contain a version of a specific resource. This notebook demonstrates other functionalities that are related to versions.
from kgforge.core import KnowledgeGraphForge
forge = KnowledgeGraphForge("../../configurations/forge.yml")
from kgforge.core import Resource
Tagging is used to provide a string identifier (tag) to a specific version of a resource.
jane = Resource(type="Person", name="Jane Doe")
forge.register(jane)
jane._synchronized
forge.tag(jane, "v1")
john = Resource(type="Person", name="John Smith")
john._synchronized
forge.tag(john, "v1")
john._last_action
When linking resources it is possible to refer to specific version by freezing it. In this demo example, the version is attached to the resource identifier, and this is specified in the versioned_id_template
property on the Store section in the configuration file.
jane = Resource(type="Person", name="Jane Doe")
forge.register(jane)
association = Resource(type="Association", agent=jane)
forge.register(association)
print(association)
try:
# DemoStore
print(jane._store_metadata.version)
except:
# BlueBrainNexus
print(jane._store_metadata._rev)
try:
# DemoStore
print(association._store_metadata.version)
except:
# BlueBrainNexus
print(association._store_metadata._rev)
forge.freeze(association)
print(association)