Skip to main content

Hybrid SPARQL query engine for timeseries data

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.8.14.tar.gz (8.9 MB view details)

Uploaded Source

Built Distributions

chrontext-0.8.14-cp311-none-win_amd64.whl (23.5 MB view details)

Uploaded CPython 3.11 Windows x86-64

chrontext-0.8.14-cp311-cp311-manylinux_2_28_x86_64.whl (29.8 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.28+ x86-64

chrontext-0.8.14-cp311-cp311-macosx_12_0_x86_64.whl (22.1 MB view details)

Uploaded CPython 3.11 macOS 12.0+ x86-64

chrontext-0.8.14-cp311-cp311-macosx_11_0_arm64.whl (20.8 MB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

chrontext-0.8.14-cp310-none-win_amd64.whl (23.5 MB view details)

Uploaded CPython 3.10 Windows x86-64

chrontext-0.8.14-cp310-cp310-manylinux_2_28_x86_64.whl (29.8 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.28+ x86-64

chrontext-0.8.14-cp310-cp310-macosx_12_0_x86_64.whl (22.1 MB view details)

Uploaded CPython 3.10 macOS 12.0+ x86-64

chrontext-0.8.14-cp310-cp310-macosx_11_0_arm64.whl (20.8 MB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

chrontext-0.8.14-cp39-none-win_amd64.whl (23.5 MB view details)

Uploaded CPython 3.9 Windows x86-64

chrontext-0.8.14-cp39-cp39-manylinux_2_28_x86_64.whl (29.8 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.28+ x86-64

chrontext-0.8.14-cp39-cp39-macosx_12_0_x86_64.whl (22.1 MB view details)

Uploaded CPython 3.9 macOS 12.0+ x86-64

chrontext-0.8.14-cp39-cp39-macosx_11_0_arm64.whl (20.8 MB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

chrontext-0.8.14-cp38-none-win_amd64.whl (23.5 MB view details)

Uploaded CPython 3.8 Windows x86-64

chrontext-0.8.14-cp38-cp38-manylinux_2_28_x86_64.whl (29.8 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.28+ x86-64

chrontext-0.8.14-cp38-cp38-macosx_12_0_x86_64.whl (22.1 MB view details)

Uploaded CPython 3.8 macOS 12.0+ x86-64

chrontext-0.8.14-cp38-cp38-macosx_11_0_arm64.whl (20.8 MB view details)

Uploaded CPython 3.8 macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for chrontext-0.8.14.tar.gz
Algorithm Hash digest
SHA256 2b1f5b1c8ca5544b13cdc187ef291bcc57531232ca10fd72284f7d749615e7cb
MD5 f0d5870f142181f9b3b767d97c005c82
BLAKE2b-256 4839b0087bd99c3808a416b6108b7aa0b649e988a771ac4a814966dba9f0f7e8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chrontext-0.8.14-cp311-none-win_amd64.whl
Algorithm Hash digest
SHA256 00bd3ec66d5e79b162c3d7aac3073956956abd02b4e8b41f764b52949b4c3f1b
MD5 66f1332ada04bddca00bf17648a13257
BLAKE2b-256 d638917b7811f94d6111af9831a2859bc102bd2eae76d02687d98c257f6c1661

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chrontext-0.8.14-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c784fb812b6935e800ee5e71b7151309ea6dddb32b313652b963229fd2271789
MD5 a95a5a4326670a6d58c6f0e5a8e42896
BLAKE2b-256 4a27d8e34e0bd7473605c0c16aa3e870ec56e2a838d1e804689847582d48b86e

See more details on using hashes here.

File details

Details for the file chrontext-0.8.14-cp311-cp311-macosx_12_0_x86_64.whl.

File metadata

File hashes

Hashes for chrontext-0.8.14-cp311-cp311-macosx_12_0_x86_64.whl
Algorithm Hash digest
SHA256 ba1d9b0fa85f189a0896bbb3f4d35a6bb9baafced7a8ecba4746778b31807f93
MD5 1f83c32c309a62a0667023e2305de9b8
BLAKE2b-256 27588f582a0c20e1ac75c67963c17678bcd0fea48dce7cb249e1a5412460f445

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chrontext-0.8.14-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 79b4d195ac5e49827c3b25f5e08b1ce7cbadd344d47bfe6dce417424ecfef561
MD5 53425a9dd8292a9ea4828200b2bfdedb
BLAKE2b-256 258d0a59c387ade5f11ddaebbffe2b41b01aa12790633d7710bb8239519ff25d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chrontext-0.8.14-cp310-none-win_amd64.whl
Algorithm Hash digest
SHA256 c7aa822d75a5c3f26c5fe5cc95c6898996ce64be49a1aea342ad1e15badad684
MD5 ef6857b804d4b92793a73fbed6925f45
BLAKE2b-256 209a289271a0a7fd85283ab021dc2436d32eef61a051423b0d6173b3f6d83851

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chrontext-0.8.14-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e98f2b00411d3efe881eb57a3ac4bc24820a70ac2277f692fec022e8e5dfb192
MD5 4caca81d212e09aea7485a37c108fa83
BLAKE2b-256 9546d19ecd53362c1576a266237a37022a455c760ac185039e0333a7492ce38f

See more details on using hashes here.

File details

Details for the file chrontext-0.8.14-cp310-cp310-macosx_12_0_x86_64.whl.

File metadata

File hashes

Hashes for chrontext-0.8.14-cp310-cp310-macosx_12_0_x86_64.whl
Algorithm Hash digest
SHA256 c67b16c3421283054f9ae51ef46409b51ee9add4a3aa72430aafff4fd91e8728
MD5 ab6188f01752f1ef3846ec5b7fba57db
BLAKE2b-256 63b39fae5b6ab00b29be17a73aa2ed2f3f608a1dd58e76bd8e8967aff11ecb44

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chrontext-0.8.14-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8ac2ae077cfe07ad92a898d3eda4ab13ed1a51ef8b93a80ab919f623e578da61
MD5 8efa1f37da6e0f36f3c0723f77998c8e
BLAKE2b-256 bd771917e7478a0e61fd5d0a4f781eaa5e5188d96f145020461925f014d6428c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chrontext-0.8.14-cp39-none-win_amd64.whl
Algorithm Hash digest
SHA256 caf173375d08ecce80a9c23bdca13593ecb4a3ec8bb4e504cd117472fb7e10ee
MD5 2265c55c96ba10814834e4c98babc405
BLAKE2b-256 5a8163f8e95d673c4c25c32241d830a287c7773e3a86659141ce41e8fc649ae5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chrontext-0.8.14-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 020b1b4c27390814685422842e9e92de078ef4f1b257feeb8c73e323156b8d85
MD5 cd07c86fa2185d14428fb387165ee6e2
BLAKE2b-256 3d7305a0655a8289a7d55b37966fb57c544ab8ddd681dad7b827b5da3ea2a69b

See more details on using hashes here.

File details

Details for the file chrontext-0.8.14-cp39-cp39-macosx_12_0_x86_64.whl.

File metadata

File hashes

Hashes for chrontext-0.8.14-cp39-cp39-macosx_12_0_x86_64.whl
Algorithm Hash digest
SHA256 91610cbfd8a4d6f8d0b38c5118f71c17084406e537b961115dc8cbfb8336b26d
MD5 0c9052b9c49c795627d0c43c474aa2cd
BLAKE2b-256 c0fb9bc00ada595f8e2b9254dc4c0a3c7ea040d2fb62a6cc65e5e54e7dfea0ff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chrontext-0.8.14-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c29da5e70cae1c9e839bd02d3d369fe5d757bee8960d453bbed398ea3c903ec0
MD5 f27d2b9c67bf136b5e345c35e814e85a
BLAKE2b-256 554046de1f573091d6ba69608e8ee541568814f6924d26df5286457021dd70f6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chrontext-0.8.14-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 5c1a3d5d7495bb80695499c052791bbfbb9d1dea8b3c5c4727cf9a7b8aa15dfe
MD5 75da8913aee6d39a0ed25585845beac8
BLAKE2b-256 7f0a770afae39605c9871c94c729499f35246fa8f1e081ae781e55f6bdd28f66

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chrontext-0.8.14-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3cd592c30dcb1d3202a20d38655901f360b8a784d7554b1fa49ab85da1524734
MD5 8f21101e5875ae7f7f45da267f8a958c
BLAKE2b-256 ca3f641de80f4a06e25f229d03d313b8e65a442f07bffdd65daf6e4a505d77b7

See more details on using hashes here.

File details

Details for the file chrontext-0.8.14-cp38-cp38-macosx_12_0_x86_64.whl.

File metadata

File hashes

Hashes for chrontext-0.8.14-cp38-cp38-macosx_12_0_x86_64.whl
Algorithm Hash digest
SHA256 6cf5d81322f591e650ce9758ba4aacd21021eb594476deaae21eada52627676a
MD5 140cd8fcff9fed89acbcdd62f94e1cae
BLAKE2b-256 0d45337d4c950b127c9d1a2dcf095ae110539865a6a5af11b34a9d5469df3716

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chrontext-0.8.14-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d089c9fdd2f0e655c9af37b750eb68d0bf830e913c0a337e0bd8800f8ea90223
MD5 955289c88380f398d4c4b3ced5da68ba
BLAKE2b-256 aee0b0d87d2b2fc000a851db323e017d66399a5188f20bf2c250c5a38093e6a3

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