Hybrid SPARQL query engine for timeseries data
Project description
chrontext: High-performance hybrid query engine for knowledge graphs and time-series
Chrontext allows you to use your knowledge graph to access time-series data. It uses a commodity SPARQL Triplestore and your existing infrastructure for time-series. It currently supports time-series stored in Google Cloud BigQuery (SQL) and OPC UA HA, but can easily be extended to other APIs and databases.
Chrontext forms a semantic layer that allows self-service data access, abstracting away technical infrastructure. Users can create query-based inputs for data products, that maintains these data products as the knowledge graph is maintained, and that can be deployed across heterogeneous on-premise and cloud infrastructures with the same API.
Chrontext is a high-performance Python library built in Rust using Polars, and relies heavily on packages from the Oxigraph project. Chrontext works with Apache Arrow, prefers time-series transport using Apache Arrow Flight and delivers results as Polars DataFrames.
Please reach out to Data Treehouse if you would like help trying Chrontext, or require support for a different time-series backend.
Installing
Chrontext is in pip, just use:
pip install chrontext
The API is documented HERE.
Queries in python
We can make queries in Python. The code assumes that we have a SPARQL-endpoint and BigQuery set up with time-series.
from chrontext import *
import os
SCHEMA = os.getenv("SCHEMA")
BIGQUERY_CONN = os.getenv("BIGQUERY_CONN")
tables = [
TimeseriesTable(
resource_name="nist",
schema=SCHEMA,
time_series_table="nist2",
value_column="VALUE",
timestamp_column="TIMESTAMP",
identifier_column="external_id",
),
]
bq_db = TimeseriesBigQueryDatabase(key=os.getenv("BIGQUERY_CONN"), tables=tables)
engine = Engine(timeseries_bigquery_db=bq_db, sparql_endpoint=SPARQL)
engine.init()
df = engine.query("""
PREFIX xsd:<http://www.w3.org/2001/XMLSchema#>
PREFIX ct:<https://github.com/DataTreehouse/chrontext#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rds: <https://github.com/DataTreehouse/solar_demo/rds_power#>
SELECT ?inv_path WHERE {
# We are navigating th Solar PV site "Metropolis", identifying every inverter.
?site a rds:Site .
?site rdfs:label "Metropolis" .
?site rds:functionalAspect+ ?inv .
?inv a rds:TBB . # RDS code TBB: Inverter
?inv rds:path ?inv_path .
# Find the timeseries associated with the inverter
?inv ct:hasTimeseries ?ts_pow .
?ts_pow rdfs:label "InvPDC_kW" .
DT {
timestamp = ?t,
timeseries = ?ts_pow,
interval = "10m",
from = "2018-12-25T00:00:00Z",
aggregation = "avg" }
}
ORDER BY ?inv_path ?t
""")
This produces the following DataFrame:
inv_path | t | ts_pow_value_avg |
---|---|---|
str | datetime[ns] | f64 |
=<Metropolis>.A1.RG1.TBB1 | 2018-12-25 00:00:00 | 0.0 |
… | … | … |
=<Metropolis>.A5.RG9.TBB1 | 2019-01-01 04:50:00 | 0.0 |
Not much power being produced at night in the middle of winter :-)
API
The API is documented HERE.
References
Chrontext is joint work by Magnus Bakken and Professor Ahmet Soylu at OsloMet. To read more about Chrontext, read the article Chrontext: Portable Sparql Queries Over Contextualised Time Series Data in Industrial Settings.
License
All code produced since August 1st. 2023 is copyrighted to Data Treehouse AS with an Apache 2.0 license unless otherwise noted.
All code which was produced before August 1st. 2023 copyrighted to Prediktor AS with an Apache 2.0 license unless otherwise noted, and has been financed by The Research Council of Norway (grant no. 316656) and Prediktor AS as part of a PhD Degree. The code at this state is archived in the repository at https://github.com/DataTreehouse/chrontext.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file chrontext-0.8.20.tar.gz
.
File metadata
- Download URL: chrontext-0.8.20.tar.gz
- Upload date:
- Size: 8.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.5.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f8ec8972eb3ceef2d6ab5e785397b61dfe7cc4d86e67f3025e961ea0c605cd52 |
|
MD5 | 23ea7da42dd728303978e3167ebdc043 |
|
BLAKE2b-256 | 23958ec3f2fa2d344462cfef0ef34523fc43fd75f21ca7f24146410047150fcc |
File details
Details for the file chrontext-0.8.20-cp311-none-win_amd64.whl
.
File metadata
- Download URL: chrontext-0.8.20-cp311-none-win_amd64.whl
- Upload date:
- Size: 25.6 MB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.5.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f28f4a21174b2a1f3b397979524eca8826596b4be120d71a96b085b0f8b33075 |
|
MD5 | 32ab0947ef82b473ed676c8cc46b3ceb |
|
BLAKE2b-256 | fcb50a53200a05ded85348905afe47b2f5b3ff72dfed02d10791d5467d27f682 |
File details
Details for the file chrontext-0.8.20-cp311-cp311-manylinux_2_28_x86_64.whl
.
File metadata
- Download URL: chrontext-0.8.20-cp311-cp311-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 30.6 MB
- Tags: CPython 3.11, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.5.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e300982d0ae7f0c74aa6b6f804e553727a13241af4a17c475acc3e8dd86f5d84 |
|
MD5 | 2e97d07b5b8ce9b261be925a7610eddb |
|
BLAKE2b-256 | 9296857cc8b69171191d24f323c24bf86a84290b2558191129d2e60254aa3247 |
File details
Details for the file chrontext-0.8.20-cp311-cp311-macosx_12_0_arm64.whl
.
File metadata
- Download URL: chrontext-0.8.20-cp311-cp311-macosx_12_0_arm64.whl
- Upload date:
- Size: 22.5 MB
- Tags: CPython 3.11, macOS 12.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.5.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2cc34fd85147c1d4c9375d0adcd4391734800f2f861e98c709edd2978d80043f |
|
MD5 | 35e41798ee2bb962f8752e17d04dc184 |
|
BLAKE2b-256 | c9cff1ee700a687f564e23bb1724c57dedc0d3f203810cca4cd24160e67522b8 |
File details
Details for the file chrontext-0.8.20-cp311-cp311-macosx_11_0_arm64.whl
.
File metadata
- Download URL: chrontext-0.8.20-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 22.5 MB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.5.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 95eb36e873c513e52ba71139b3b49b68a2e5f82229ecb761760cb6985cd5c20e |
|
MD5 | 775db68f451b47c8ffb1810e55722421 |
|
BLAKE2b-256 | 649cf0a2eefd56660433ec151fb290b58258679d753a1565f9a83fd24810dcd5 |
File details
Details for the file chrontext-0.8.20-cp310-none-win_amd64.whl
.
File metadata
- Download URL: chrontext-0.8.20-cp310-none-win_amd64.whl
- Upload date:
- Size: 25.6 MB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.5.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 113a65b480f2caa0f4bbbb6d16586d7e6f544f75c05b013baf9b300ba4549188 |
|
MD5 | 116426495c374ed783945e327fe510b3 |
|
BLAKE2b-256 | aa2ba5303d90a4a641b9e4c28e9555bec0b7067c9edcdc51912a830918524ac0 |
File details
Details for the file chrontext-0.8.20-cp310-cp310-manylinux_2_28_x86_64.whl
.
File metadata
- Download URL: chrontext-0.8.20-cp310-cp310-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 30.6 MB
- Tags: CPython 3.10, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.5.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fdbd23c411f270f67c84db5968e4a26e9b7fede8c3a5174d6bb494efec45859f |
|
MD5 | 7a014b6c3f24af09a4af22624653f715 |
|
BLAKE2b-256 | c6ff6ebde0817b94a8d2d33b0fb10298838d07c7d124e734e5742f988790c8b5 |
File details
Details for the file chrontext-0.8.20-cp310-cp310-macosx_12_0_arm64.whl
.
File metadata
- Download URL: chrontext-0.8.20-cp310-cp310-macosx_12_0_arm64.whl
- Upload date:
- Size: 22.5 MB
- Tags: CPython 3.10, macOS 12.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.5.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 70beee4da5acc44fc755144c9642c6ecc712cc5279e5f901740e82e100caba57 |
|
MD5 | 24ba842c87f692accd1786ec0d79ee1d |
|
BLAKE2b-256 | d92610dd277a6cf5d09a65cde6f6504e85db1aa2b5677ef552c347ec3b0d93f4 |
File details
Details for the file chrontext-0.8.20-cp310-cp310-macosx_11_0_arm64.whl
.
File metadata
- Download URL: chrontext-0.8.20-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 22.5 MB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.5.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0de545af6288098f56994a2a5870cc5921b1a3671cc98f213c43b1edad0723b |
|
MD5 | f111cb86bfdf7f90bc8c59fd1627f892 |
|
BLAKE2b-256 | b76279516775a0ed0f17accbaea7e990e039a5b3c14a65cb616628c368f132fe |
File details
Details for the file chrontext-0.8.20-cp39-none-win_amd64.whl
.
File metadata
- Download URL: chrontext-0.8.20-cp39-none-win_amd64.whl
- Upload date:
- Size: 25.6 MB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.5.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f838e28940ebe8baf4b142ec85c7560dae06c6e7f4c0be074a253512dd28a0de |
|
MD5 | 64588dab68e5432420f26b9eb546f17b |
|
BLAKE2b-256 | d328d435b54a2716d82cd8fdb5ac7a743e25521093148a75f3370ea5a75286b5 |
File details
Details for the file chrontext-0.8.20-cp39-cp39-manylinux_2_28_x86_64.whl
.
File metadata
- Download URL: chrontext-0.8.20-cp39-cp39-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 30.6 MB
- Tags: CPython 3.9, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.5.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1261140d961d542ce6de3144e38536504a0a68fa6c0f427eba4b3926d0d8dfb4 |
|
MD5 | 6422c76a0f9b979bd1cc671b303a5a79 |
|
BLAKE2b-256 | 6c488d90b75299812f903c4b9596a2ff18fbe6448d657db356725aa17d6a2010 |
File details
Details for the file chrontext-0.8.20-cp39-cp39-macosx_12_0_arm64.whl
.
File metadata
- Download URL: chrontext-0.8.20-cp39-cp39-macosx_12_0_arm64.whl
- Upload date:
- Size: 22.5 MB
- Tags: CPython 3.9, macOS 12.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.5.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa35e6e4148db4c61fb53823c50ae5c404c536bbb7e7cb9f10d2771905bd85fd |
|
MD5 | 25340fa3efe0e482ac37a97e41322787 |
|
BLAKE2b-256 | 8986db0beb727e75af4b3df707c5cf62c157e31104333f003a9aaf84e6cd59bd |
File details
Details for the file chrontext-0.8.20-cp39-cp39-macosx_11_0_arm64.whl
.
File metadata
- Download URL: chrontext-0.8.20-cp39-cp39-macosx_11_0_arm64.whl
- Upload date:
- Size: 22.5 MB
- Tags: CPython 3.9, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.5.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f817b808087dae78d95d0a11f44c9a222c1570bce2b95d7588f6638b0d708a5 |
|
MD5 | 26ceea9a57ea764a21eeb360d4d4fe1d |
|
BLAKE2b-256 | 3254908d96cf71d21df59a3594bbf66427173e980e0dd1f61f767d3a4e3c23de |
File details
Details for the file chrontext-0.8.20-cp38-none-win_amd64.whl
.
File metadata
- Download URL: chrontext-0.8.20-cp38-none-win_amd64.whl
- Upload date:
- Size: 25.6 MB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.5.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25fe1145d9ec7e44f9937e128de442a55106edd9c1c3f496e0e3b8cd39e96dc4 |
|
MD5 | 61a48ff8ceb0e3e72f09f69ac466f7db |
|
BLAKE2b-256 | 439bea23a8a538917639f6818928c5ca94f3ff48de7317ae16a0d517ddba5006 |
File details
Details for the file chrontext-0.8.20-cp38-cp38-manylinux_2_28_x86_64.whl
.
File metadata
- Download URL: chrontext-0.8.20-cp38-cp38-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 30.6 MB
- Tags: CPython 3.8, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.5.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b41920f79cef171592007e4f035e9e02586b52721479d43b008e5bda00a447e4 |
|
MD5 | 543b5dc11103470c337ffbef7af0cab1 |
|
BLAKE2b-256 | 976ce36a2b123fba2b1d0498d8b5fe7375f8d2482b2f0668a5401130204fcc76 |
File details
Details for the file chrontext-0.8.20-cp38-cp38-macosx_12_0_arm64.whl
.
File metadata
- Download URL: chrontext-0.8.20-cp38-cp38-macosx_12_0_arm64.whl
- Upload date:
- Size: 22.5 MB
- Tags: CPython 3.8, macOS 12.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.5.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6bf52947304a6a15120edef88fa21306d0579de204c8e59f58ab9f91271d8f35 |
|
MD5 | 00a4d586237c538d01a1cfe7b75b29c2 |
|
BLAKE2b-256 | 19569a90f95555c8a637612db0fdb3e49d7f2a2b79e80f2056878fa9a9716cfc |
File details
Details for the file chrontext-0.8.20-cp38-cp38-macosx_11_0_arm64.whl
.
File metadata
- Download URL: chrontext-0.8.20-cp38-cp38-macosx_11_0_arm64.whl
- Upload date:
- Size: 22.5 MB
- Tags: CPython 3.8, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.5.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 230b381e82371dc5df1178167717fd6461b1f4487d033782ec246c270117fcd5 |
|
MD5 | 8801c320827f301a50f0eeee02478230 |
|
BLAKE2b-256 | d70e1816648d9efc2aebeb80c7f1ed640e4ef877b7a48728063596cb9b142fb8 |