Getting git-style versioning working on RDFlib

Overview

Versioned RDF

from vrdf import DB, BRICK, A
from rdflib import Namespace

BLDG = Namespace("urn:bldg#")
db = DB("test.db")

# using logical timestamps here (0, 1, 2, 3, ...). If these are
# ommitted it defaults to the current system time.
with db.new_changeset("my-building", 1) as cs:
    cs.add((BLDG.vav1, A, BRICK.VAV))
    cs.add((BLDG.vav1, BRICK.feeds, BLDG.zone1))
    cs.add((BLDG.zone1, A, BRICK.HVAC_Zone))
    cs.add((BLDG.zone1, BRICK.hasPart, BLDG.room1))

# WARNING: this is slow for now
with db.new_changeset("brick", 1) as cs:
    # 'cs' is a rdflib.Graph that supports queries -- updates on it
    # are buffered in the transaction and cannot be queried until
    # the transaction is committed (at the end of the context block)
    cs.load_file(
        "https://github.com/BrickSchema/Brick/releases/download/nightly/Brick.ttl"
    )

with db.new_changeset("my-building", 2) as cs:
    cs.add((BLDG.vav2, A, BRICK.VAV))
    cs.add((BLDG.vav2, BRICK.feeds, BLDG.zone1))
    cs.add((BLDG.zone2, A, BRICK.HVAC_Zone))
    cs.remove((BLDG.zone1, BRICK.hasPart, BLDG.room1))

with db.new_changeset("my-building", 3) as cs:
    cs.add((BLDG.vav2, A, BRICK.VAV))
    cs.add((BLDG.vav2, BRICK.feeds, BLDG.zone1))
    cs.add((BLDG.zone2, A, BRICK.HVAC_Zone))
    cs.remove((BLDG.zone1, BRICK.hasPart, BLDG.room1))

with db.new_changeset("my-building", 4) as cs:
    cs.remove((BLDG.vav2, BRICK.feeds, BLDG.zone1))
    cs.add((BLDG.vav2, BRICK.feeds, BLDG.zone2))

print("LATEST!")
for t in db.latest("my-building"):
    print(t)

for logical_ts in range(1, 5):
    print("LOGICAL TS:", logical_ts)
    for t in db.graph_at("my-building", logical_ts):
        print(t)

db.close()
Owner
Gabe Fierro
Asst Prof @ Colorado School of Mines // NREL // CS PhD @ UC Berkeley // Databases, Systems, Semantic Interop, Cyber-Physical Systems
Gabe Fierro
Search for terms(word / table / field name or any) under Snowflake schema names

snowflake-search-terms-in-ddl-views Search for terms(word / table / field name or any) under Snowflake schema names Version : 1.0v How to use ? Run th

Igal Emona 1 Dec 15, 2021
Athens: a great tool for taking notes and organising knowldge

AthensSyncer Athens is a great tool for taking notes and organising knowldge. But it is a bummer that you cannot use it accross multiple devices. Well

6 Dec 14, 2022
BaseCrack is a tool written in Python that can decode all alphanumeric base encoding schemes.

BaseCrack Decoder For Base Encoding Schemes BaseCrack is a tool written in Python that can decode all alphanumeric base encoding schemes. This tool ca

Mufeed VH 383 Dec 27, 2022
Python port of Google's libphonenumber

phonenumbers Python Library This is a Python port of Google's libphonenumber library It supports Python 2.5-2.7 and Python 3.x (in the same codebase,

David Drysdale 3.1k Dec 29, 2022
Adventura is an open source Python Text Adventure Engine

Adventura Adventura is an open source Python Text Adventure Engine, Not yet uplo

5 Oct 02, 2022
Repository containing the code for An-Gocair text normaliser

Scottish Gaelic Text Normaliser The following project contains the code and resources for the Scottish Gaelic text normalisation project. The repo can

3 Jun 28, 2022
Extract price amount and currency symbol from a raw text string

price-parser is a small library for extracting price and currency from raw text strings.

Scrapinghub 252 Dec 31, 2022
text-to-speach bot - You really do NOT have time for read a newsletter? Now you can listen to it

NewsletterReader You really do NOT have time for read a newsletter? Now you can listen to it The Newsletter of Filipe Deschamps is a great place to re

ItanuRomero 8 Sep 18, 2021
Hspell, the free Hebrew spellchecker and morphology engine.

Hspell, the free Hebrew spellchecker and morphology engine.

16 Sep 15, 2022
Word and phrase lists in CSV

Word Lists Word and phrase lists in CSV, collected from different sources. Oxford Word Lists: oxford-5k.csv - Oxford 3000 and 5000 oxford-opal.csv - O

Anton Zhiyanov 14 Oct 14, 2022
A collection of pre-commit hooks for handling text files.

texthooks A collection of pre-commit hooks for handling text files. In particular, hooks for handling unicode characters which may be undesirable in a

Stephen Rosen 5 Oct 28, 2022
🍋 A Python package to process food

Pyfood is a simple Python package to process food, in different languages. Pyfood's ambition is to be the go-to library to deal with food, recipes, on

Local Seasonal 8 Apr 04, 2022
Fuzzy string matching like a boss. It uses Levenshtein Distance to calculate the differences between sequences in a simple-to-use package.

Fuzzy string matching like a boss. It uses Levenshtein Distance to calculate the differences between sequences in a simple-to-use package.

SeatGeek 1.2k Jan 01, 2023
You can encode and decode base85, ascii85, base64, base32, and base16 with this tool.

You can encode and decode base85, ascii85, base64, base32, and base16 with this tool.

8 Dec 20, 2022
An extension to detect if the articles content match its title.

Clickbait Detector An extension to detect if the articles content match its title. This was developed in a period of 24-hours in a hackathon called 'H

Arvind Krishna 5 Jul 26, 2022
WorldCloud Orçamento de Estado 2022

World Cloud Orçamento de Estado 2022 What it does This script creates a worldcloud, masked on a image, from a txt file How to run it? Install all libr

Jorge Gomes 2 Oct 12, 2021
A query extract python package

A query extract python package

Fayas Noushad 4 Nov 28, 2021
Redlines produces a Markdown text showing the differences between two strings/text

Redlines Redlines produces a Markdown text showing the differences between two strings/text. The changes are represented with strike-throughs and unde

Houfu Ang 2 Apr 08, 2022
This is an AI that is supposed to say you if your text is formal or not

This is an AI that is supposed to say you if your text is formal or not. It's written in Python 3 and has some german examples (because I'm german yk) in the text.json file. This file contains the te

1 Jan 12, 2022