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 versioning data such as tagging.
from kgforge.core import KnowledgeGraphForge
A configuration file is needed in order to create a KnowledgeGraphForge session. A configuration can be generated using the notebook 00-Initialization.ipynb.
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 to a resource it is possible to refer to a 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)
forge.as_json(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)
forge.as_json(association)