Skip to main content

SPARQL queries over hybrid infrastructures - time-series and context

Project description

chrontext

SPARQL- and Apache Arrow-based high throughput access to time series data residing in an arbitrary time series database which is contextualized by a knowledge graph. It is built in Rust using pola.rs, spargebra, sparesults and oxrdf from the Oxigraph project.

Chrontext is written with data analysts and data engineers who want to extract contextualised time series data as data frames. Chrontext allows them to do this in an efficient way using SPARQL. It supports data extraction scenarios in industry where data needs to be accessed in cloud data lake and on-premise settings by supporting in principle arbitrary time series database backends. Currently, we support OPC UA HA and Dremio (using SQL over Apache Arrow Flight). Chrontext can be configured to push down query executions into the time series database according to its capabilities in order to offload computations and minimize I/O.

To read more about Chrontext, read the preprint article Chrontext: Portable Sparql Queries Over Contextualised Time Series Data in Industrial Settings. This is joint work by Magnus Bakken and Professor Ahmet Soylu at OsloMet. Please reach out to us if you would like help trying Chrontext.

Metadata

Chrontext assumes that we have a knowledge base in a SPARQL database and a time series database. The knowledge base is annotated to link some URIs to identifiers of time series in the time series database. Chrontext Metadata Representation

Execution

At query time, we rewrite queries that span both "static" data in the SPARQL database and the time series database into parts that concern the SPARQL engine and the time series database respectively. The "static" queries are amended to extract the metadata linking URIs to time series. Query execution is then interleaved and results are combined to produce the answer to the original query. Chrontext sequence diagram

Queries in python

We can make queries in Python. The code assumes that we have a SPARQL-endpoint and an Arrow Flight SQL-endpoint (Dremio) set up.

import pathlib
from chrontext import Engine, TimeseriesDremioDatabase, TimeseriesTable

tables = [
    TimeseriesTable(
        resource_name="my_resource",
        schema="my_nas",
        time_series_table="ts.parquet",
        value_column="v",
        timestamp_column="ts",
        identifier_column="id",
        value_datatype="http://www.w3.org/2001/XMLSchema#unsignedInt")
]
arrow_flight_sql_db = TimeseriesDremioDatabase(host=DREMIO_HOST, port=DREMIO_PORT, username="dremio",
                                                   password="dremio123", tables=tables)
engine = Engine(sparql_endpoint=OXIGRAPH_QUERY_ENDPOINT, timeseries_dremio_db=timeseries_dremio_db)
engine.init()

df = engine.query("""
PREFIX xsd:<http://www.w3.org/2001/XMLSchema#>
PREFIX chrontext:<https://github.com/DataTreehouse/chrontext#>
PREFIX types:<http://example.org/types#>
SELECT ?w ?s ?t ?v WHERE {
    ?w a types:BigWidget .
    ?w types:hasSensor ?s .
    ?s chrontext:hasTimeseries ?ts .
    ?ts chrontext:hasDataPoint ?dp .
    ?dp chrontext:hasTimestamp ?t .
    ?dp chrontext:hasValue ?v .
    FILTER(?t > "2022-06-01T08:46:53"^^xsd:dateTime && ?v < 200) .
}
    """)

Installing pre-built wheels

Chrontext is in pip, just use:

pip install chrontext

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chrontext-0.6.0.tar.gz (8.9 MB view details)

Uploaded Source

Built Distributions

chrontext-0.6.0-cp311-none-win_amd64.whl (19.7 MB view details)

Uploaded CPython 3.11 Windows x86-64

chrontext-0.6.0-cp311-cp311-manylinux_2_28_x86_64.whl (20.9 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.28+ x86-64

chrontext-0.6.0-cp311-cp311-macosx_12_6_x86_64.whl (18.8 MB view details)

Uploaded CPython 3.11 macOS 12.6+ x86-64

chrontext-0.6.0-cp311-cp311-macosx_11_0_arm64.whl (17.5 MB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

chrontext-0.6.0-cp310-none-win_amd64.whl (19.7 MB view details)

Uploaded CPython 3.10 Windows x86-64

chrontext-0.6.0-cp310-cp310-manylinux_2_28_x86_64.whl (20.9 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.28+ x86-64

chrontext-0.6.0-cp310-cp310-macosx_12_6_x86_64.whl (18.8 MB view details)

Uploaded CPython 3.10 macOS 12.6+ x86-64

chrontext-0.6.0-cp310-cp310-macosx_11_0_arm64.whl (17.5 MB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

chrontext-0.6.0-cp39-none-win_amd64.whl (19.7 MB view details)

Uploaded CPython 3.9 Windows x86-64

chrontext-0.6.0-cp39-cp39-manylinux_2_28_x86_64.whl (20.9 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.28+ x86-64

chrontext-0.6.0-cp39-cp39-macosx_12_6_x86_64.whl (18.8 MB view details)

Uploaded CPython 3.9 macOS 12.6+ x86-64

chrontext-0.6.0-cp39-cp39-macosx_11_0_arm64.whl (17.5 MB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

chrontext-0.6.0-cp38-none-win_amd64.whl (19.7 MB view details)

Uploaded CPython 3.8 Windows x86-64

chrontext-0.6.0-cp38-cp38-manylinux_2_28_x86_64.whl (20.9 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.28+ x86-64

chrontext-0.6.0-cp38-cp38-macosx_12_6_x86_64.whl (18.8 MB view details)

Uploaded CPython 3.8 macOS 12.6+ x86-64

chrontext-0.6.0-cp38-cp38-macosx_11_0_arm64.whl (17.5 MB view details)

Uploaded CPython 3.8 macOS 11.0+ ARM64

File details

Details for the file chrontext-0.6.0.tar.gz.

File metadata

  • Download URL: chrontext-0.6.0.tar.gz
  • Upload date:
  • Size: 8.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.2.3

File hashes

Hashes for chrontext-0.6.0.tar.gz
Algorithm Hash digest
SHA256 c3885c612bcfe3ce136e11508da52f01194571053e73a46a7b1ebd52a525c666
MD5 e6131eee6417ad7e2329a12b76ad19aa
BLAKE2b-256 490d4ac296b283fdefaa8a489f4865a6563f71ebe0b7a2ed4c7fa0f4e6af5465

See more details on using hashes here.

File details

Details for the file chrontext-0.6.0-cp311-none-win_amd64.whl.

File metadata

File hashes

Hashes for chrontext-0.6.0-cp311-none-win_amd64.whl
Algorithm Hash digest
SHA256 9274a566c1c3de796ab01d8cb6c643fcec9e3ef33978e34ef2e46ecfcb67ddaf
MD5 c4710ce0d037b280dd90ae0e2864198f
BLAKE2b-256 a03ba4afaa191bcc9ebb635f3ab1be1d80e797b83a4def1ffa8e38de12e4ca8c

See more details on using hashes here.

File details

Details for the file chrontext-0.6.0-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for chrontext-0.6.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 05bc8eb9f8b96d7e62059c67243d1acb08548e4c8231994d9cdb10b2c8b799a6
MD5 1afa5e818f877e7a255f4e1b2686f476
BLAKE2b-256 22c4f5180d7abd06fe146f900f3a67928f928273b6bc5792a6ce6d119894d261

See more details on using hashes here.

File details

Details for the file chrontext-0.6.0-cp311-cp311-macosx_12_6_x86_64.whl.

File metadata

File hashes

Hashes for chrontext-0.6.0-cp311-cp311-macosx_12_6_x86_64.whl
Algorithm Hash digest
SHA256 de237778b8bc9dd723032a717cfacd6341fccea338f3e75d603b346b25454c70
MD5 21a5e7330699649669b1d9ddb03be97f
BLAKE2b-256 3a937dd81d66380af49480939a3b52e40aa826ae4078da0790cedeaebe6246b1

See more details on using hashes here.

File details

Details for the file chrontext-0.6.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for chrontext-0.6.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 25b5b2fb349606c83c3ccdc390d974dd70f08bc532240ecbfb4d0658ca30bc8c
MD5 2aec9dc377848a3a4c7a83fdac1ab0d8
BLAKE2b-256 7d26295db051639c482e2fa58a614b6bc969d9421caedb106c58f8cebe8684b1

See more details on using hashes here.

File details

Details for the file chrontext-0.6.0-cp310-none-win_amd64.whl.

File metadata

File hashes

Hashes for chrontext-0.6.0-cp310-none-win_amd64.whl
Algorithm Hash digest
SHA256 8f54b8730f7949512a083799562bda526e8a396f0dbc8feabfc46668c0f465fe
MD5 71388fa3c1e2ab24a8cf981621c00e87
BLAKE2b-256 e673da0b8983c61c63c29e2f0516acd36e06074cfb271eb429d34b7ea7516684

See more details on using hashes here.

File details

Details for the file chrontext-0.6.0-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for chrontext-0.6.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3c3ced643f41954df2942e0f4c2106cac99b092a420dc52945cac0b24e5f71bb
MD5 12b3570182e9dce316784cc705211dcd
BLAKE2b-256 9db21c2b6af15c4d012bd0202b1245b52478ff205f46de4478d2d4caf2440a92

See more details on using hashes here.

File details

Details for the file chrontext-0.6.0-cp310-cp310-macosx_12_6_x86_64.whl.

File metadata

File hashes

Hashes for chrontext-0.6.0-cp310-cp310-macosx_12_6_x86_64.whl
Algorithm Hash digest
SHA256 27040ed6b06f2b7297a38c5f486e4829d9acf62f8797acb87f08ef1185009dd2
MD5 8a5e654aa1aa8417c4336cb68103c3dd
BLAKE2b-256 0224e6974498839c2786c4a9fb0bc0dde9a7268f4b582070ea381761a8403e92

See more details on using hashes here.

File details

Details for the file chrontext-0.6.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for chrontext-0.6.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5bd5ffbae3a1e18d7dc5b23430c0b1dcf7157bbe9a525a8f329cc86127a05c4a
MD5 fa0f792f26a0508e4acec70a8765325a
BLAKE2b-256 a70cd03e0443b23c09790a5207ff58d75b2287549af14361deb32ad6948c85b6

See more details on using hashes here.

File details

Details for the file chrontext-0.6.0-cp39-none-win_amd64.whl.

File metadata

File hashes

Hashes for chrontext-0.6.0-cp39-none-win_amd64.whl
Algorithm Hash digest
SHA256 6ab747fef10801d9085e3880f35299aa0bbb23927cff2d83c2d72810729f0187
MD5 b9a5982f4a9f1fb70ae63bd46a608b54
BLAKE2b-256 9b0e519558f4785cf5073d58be582af9de98a2c9aaedb3616b89e3366f4148bb

See more details on using hashes here.

File details

Details for the file chrontext-0.6.0-cp39-cp39-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for chrontext-0.6.0-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ec1fc3e6253345cbde4cbb2c3a3ed9019e4d2f59af9cffee2b71291bfda1547e
MD5 9c2d93e64461544bf7e6be6de0156b57
BLAKE2b-256 9cb6518f7fadedf6d96ffbff1fa07a138345ecbe36c5a53b9c8f0d40fb44e229

See more details on using hashes here.

File details

Details for the file chrontext-0.6.0-cp39-cp39-macosx_12_6_x86_64.whl.

File metadata

File hashes

Hashes for chrontext-0.6.0-cp39-cp39-macosx_12_6_x86_64.whl
Algorithm Hash digest
SHA256 d8066da6d61013505ef87888cdc8591e6d5bc6f0215cd2cc964b0620ea0cf3ad
MD5 5c312929d839ba81513aba7d77e3208b
BLAKE2b-256 f088e9d974313237799360fed98d41f93b5371d0175e0144b6d5a2140900bc28

See more details on using hashes here.

File details

Details for the file chrontext-0.6.0-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for chrontext-0.6.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4d99f8498a227d654a7a748ff689ade19f24f90d489161d31076d8367c9262eb
MD5 0f6b92de146f4ccf903dc8867935d008
BLAKE2b-256 8e761760b8ba41dd9c9b8fce764bd0a66cd479c9adc3e298c16e654e641e4549

See more details on using hashes here.

File details

Details for the file chrontext-0.6.0-cp38-none-win_amd64.whl.

File metadata

File hashes

Hashes for chrontext-0.6.0-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 4b738255c3b552a90e4e765426995ca88ba5c1b31427df639ab526c0bf1a6ca4
MD5 dd450d92cd82bb80a7bd3785056d4aa4
BLAKE2b-256 44c3ee3a126caaefc4d17b901bcf5908b5add990192736988e5a88414f09e568

See more details on using hashes here.

File details

Details for the file chrontext-0.6.0-cp38-cp38-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for chrontext-0.6.0-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fb48800fe7941ddc8a0305aecc972933993ef812f0be84e4024b6da73086be7e
MD5 185f75cc64d47318d054fe597edd6161
BLAKE2b-256 d6ae289457549c0f8d05add06622008487a87f129f2881985e457ac21328c95f

See more details on using hashes here.

File details

Details for the file chrontext-0.6.0-cp38-cp38-macosx_12_6_x86_64.whl.

File metadata

File hashes

Hashes for chrontext-0.6.0-cp38-cp38-macosx_12_6_x86_64.whl
Algorithm Hash digest
SHA256 79701a65160e1fa6312dc9addfc7c51b9672b7a08026727fd289b8fc4254821b
MD5 5047d400532135531108dd0d3f9bb0b9
BLAKE2b-256 1a5b4d41c5f1299510c4204cd582e62b79430c054efd348195b5c6d728d315ad

See more details on using hashes here.

File details

Details for the file chrontext-0.6.0-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for chrontext-0.6.0-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 164eb7536baa111a252879ddbd7b8be6f881daaa55f43a3aee0ea5fa38c932ab
MD5 ee13b68bf7b6cd86acee278e7db14430
BLAKE2b-256 6206fc9e7ca3b8e37a0771647c74beade2cfc1ac622c13996ef4c196cd07719e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page