Convert ArangoDB graphs to RDF & vice-versa.
Project description
ArangoRDF
Convert RDF Graphs to ArangoDB, and vice-versa.
About RDF
RDF is a standard model for data interchange on the Web. RDF has features that facilitate data merging even if the underlying schemas differ, and it specifically supports the evolution of schemas over time without requiring all the data consumers to be changed.
RDF extends the linking structure of the Web to use URIs to name the relationship between things as well as the two ends of the link (this is usually referred to as a "triple"). Using this simple model, it allows structured and semi-structured data to be mixed, exposed, and shared across different applications.
This linking structure forms a directed, labeled graph, where the edges represent the named link between two resources, represented by the graph nodes. This graph view is the easiest possible mental model for RDF and is often used in easy-to-understand visual explanations.
Resources to get started:
Installation
Latest Release
pip install arango-rdf
Current State
pip install git+https://github.com/ArangoDB-Community/ArangoRDF
Quickstart
from rdflib import Graph
from arango import ArangoClient
from arango_rdf import ArangoRDF
db = ArangoClient().db()
adbrdf = ArangoRDF(db)
def beatles():
g = Graph()
g.parse("https://raw.githubusercontent.com/ArangoDB-Community/ArangoRDF/main/tests/data/rdf/beatles.ttl", format="ttl")
return g
RDF to ArangoDB
Note: RDF-to-ArangoDB functionality has been implemented using concepts described in the paper Transforming RDF-star to Property Graphs: A Preliminary Analysis of Transformation Approaches. So we offer two transformation approaches:
# 1. RDF-Topology Preserving Transformation (RPT)
adbrdf.rdf_to_arangodb_by_rpt(name="BeatlesRPT", rdf_graph=beatles(), overwrite_graph=True)
# 2. Property Graph Transformation (PGT)
adbrdf.rdf_to_arangodb_by_pgt(name="BeatlesPGT", rdf_graph=beatles(), overwrite_graph=True)
ArangoDB to RDF
# Assumption: "BeatlesPGT" loaded in ArangoDB ^
# 1. Graph to RDF
rdf_graph = adbrdf.arangodb_graph_to_rdf("BeatlesPGT", rdf_graph=Graph())
# 2. Collections to RDF
rdf_graph_2 = adbrdf.arangodb_collections_to_rdf(
"BeatlesPGT",
rdf_graph=Graph(),
v_cols={"Album", "Band"},
e_cols={"artist"},
)
# 3. Metagraph to RDF
rdf_graph_3 = adbrdf.arangodb_to_rdf(
name=name,
rdf_graph=Graph(),
metagraph={
"vertexCollections": {
"Album": {"name", "date"},
"Band": {"name"}
},
"edgeCollections": {
"artist": {}
},
},
)
Development & Testing
git clone https://github.com/ArangoDB-Community/ArangoRDF
cd arango-rdf
- (create virtual environment of choice)
pip install -e .[dev]
- (create an ArangoDB instance with method of choice)
pytest --url <> --dbName <> --username <> --password <>
Note: A pytest
parameter can be omitted if the endpoint is using its default value:
def pytest_addoption(parser):
parser.addoption("--url", action="store", default="http://localhost:8529")
parser.addoption("--dbName", action="store", default="_system")
parser.addoption("--username", action="store", default="root")
parser.addoption("--password", action="store", default="")
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 Distribution
File details
Details for the file arango_rdf-1.0.0.tar.gz
.
File metadata
- Download URL: arango_rdf-1.0.0.tar.gz
- Upload date:
- Size: 772.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f3cccf33a0a6c0950a07f4c26ce7727cb48b52f216be69b9c5cc5350b88599e |
|
MD5 | 62b43cfc1a571696a932c2b6c605ade3 |
|
BLAKE2b-256 | 08f855f47082972a4ada54efa6aabb12ebddc6d765779236182a8d6cd42b5e8e |
File details
Details for the file arango_rdf-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: arango_rdf-1.0.0-py3-none-any.whl
- Upload date:
- Size: 47.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 87027ac0ca2475a32de0676712daffe1f6c82e7dd4dd7f4081090cbebdf28d67 |
|
MD5 | c683144d718fb27454c9232c93ba8acc |
|
BLAKE2b-256 | 9e157db15819a527482e6413933fd912ac2f2808633db59b97b4b6cdc1871bf6 |