Skip to content

Python library to perform time-travel queries on RDF datasets compliant with the OpenCitations provenance model.

License

Notifications You must be signed in to change notification settings

opencitations/time-agnostic-library

Repository files navigation

run_tests Coverage PyPI PyPI version GitHub code size in bytes

time-agnostic-library

time-agnostic-library is a Python >=3.10 library that allows performing time-travel queries on RDF datasets compliant with the OCDM v2.0.1 provenance specification.

Tested on Blazegraph, GraphDB, Apache Jena Fuseki, and OpenLink Virtuoso.

Full documentation: https://opencitations.github.io/time-agnostic-library

Quick start

pip install time-agnostic-library
import json
from time_agnostic_library.agnostic_entity import AgnosticEntity

with open("./config.json") as f:
    config = json.load(f)

# Get the full history of an entity
entity = AgnosticEntity(res="https://example.com/br/1", config=config)
history, prov_metadata = entity.get_history(include_prov_metadata=True)

# Get an entity's state at a specific time
entity.get_state_at_time(time=("2023-01-01", "2023-12-31"))
from time_agnostic_library.agnostic_query import VersionQuery, DeltaQuery

# Run a SPARQL query on a specific version
query = VersionQuery(query="SELECT ...", on_time=("2023-01-01", None), config_path="./config.json")
query.run_agnostic_query()

# Track changes across the entire history
delta = DeltaQuery(query="SELECT ...", config_path="./config.json")
delta.run_agnostic_query()

All date/time values must be in ISO 8601 format (e.g., 2023-01-01, 2023-01-01T00:00:00+00:00).

Contributing

See CONTRIBUTING.md for development setup, testing, and release process.

Changelog

All notable changes are documented in CHANGELOG.md.

About

Python library to perform time-travel queries on RDF datasets compliant with the OpenCitations provenance model.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •