Convert ArangoDB graphs to DGL & vice-versa.
Project description
ArangoDB-DGL Adapter
The ArangoDB-DGL Adapter exports Graphs from ArangoDB, a multi-model Graph Database, into Deep Graph Library (DGL), a python package for graph neural networks, and vice-versa.
About DGL
The Deep Graph Library (DGL) is an easy-to-use, high performance and scalable Python package for deep learning on graphs. DGL is framework agnostic, meaning if a deep graph model is a component of an end-to-end application, the rest of the logics can be implemented in any major frameworks, such as PyTorch, Apache MXNet or TensorFlow.
Installation
Latest Release
pip install adbdgl-adapter
Current State
pip install git+https://github.com/arangoml/dgl-adapter.git
Quickstart
For a more detailed walk-through, access the official notebook on Colab:
# Import the ArangoDB-DGL Adapter
from adbdgl_adapter import ADBDGL_Adapter
# Import the Python-Arango driver
from arango import ArangoClient
# Import a sample graph from DGL
from dgl.data import KarateClubDataset
# Instantiate driver client based on user preference
# Let's assume that the ArangoDB "fraud detection" dataset is imported to this endpoint for example purposes
db = ArangoClient(hosts="http://localhost:8529").db("_system", username="root", password="openSesame")
# Instantiate the ADBDGL Adapter with driver client
adbdgl_adapter = ADBDGL_Adapter(db)
# Convert ArangoDB to DGL via Graph Name
dgl_fraud_graph = adbdgl_adapter.arangodb_graph_to_dgl("fraud-detection")
# Convert ArangoDB to DGL via Collection Names
dgl_fraud_graph_2 = adbdgl_adapter.arangodb_collections_to_dgl(
"fraud-detection",
{"account", "Class", "customer"}, # Specify vertex collections
{"accountHolder", "Relationship", "transaction"}, # Specify edge collections
)
# Convert ArangoDB to DGL via a Metagraph
metagraph = {
"vertexCollections": {
"account": {"Balance", "account_type", "customer_id", "rank"},
"customer": {"Name", "rank"},
},
"edgeCollections": {
"transaction": {"transaction_amt", "sender_bank_id", "receiver_bank_id"},
"accountHolder": {},
},
}
dgl_fraud_graph_3 = adbdgl_adapter.arangodb_to_dgl("fraud-detection", metagraph)
# Convert DGL to ArangoDB
dgl_karate_graph = KarateClubDataset()[0]
adb_karate_graph = adbdgl_adapter.dgl_to_arangodb("Karate", dgl_karate_graph)
Development & Testing
Prerequisite: arangorestore
git clone https://github.com/arangoml/dgl-adapter.git
cd dgl-adapter
- (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
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
Hashes for adbdgl_adapter-2.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77516906fd9c8d982bbcf3401f3656aeaea50266d3f493368fd10bbb07653cfa |
|
MD5 | e905aae5df395bf9ed41c9d97c217959 |
|
BLAKE2b-256 | a67428f82cc0021a197513253494af260b40b59c8857d705a60b532f345f202f |