Convert ArangoDB graphs to DGL & vice-versa.
Project description
ArangoDB-DGL Adapter
The ArangoDB-DGL Adapter exports Graphs from ArangoDB, the multi-model database for graph & beyond, 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
Also available as an ArangoDB Lunch & Learn session: Graph & Beyond Course #2.8
from arango import ArangoClient # Python-Arango driver
from dgl.data import KarateClubDataset # Sample graph from DGL
# Let's assume that the ArangoDB "fraud detection" dataset is imported to this endpoint
db = ArangoClient(hosts="http://localhost:8529").db("_system", username="root", password="")
adbdgl_adapter = ADBDGL_Adapter(db)
# Use Case 1.1: ArangoDB to DGL via Graph name
dgl_fraud_graph = adbdgl_adapter.arangodb_graph_to_dgl("fraud-detection")
# Use Case 1.2: ArangoDB to DGL via Collection names
dgl_fraud_graph_2 = adbdgl_adapter.arangodb_collections_to_dgl(
"fraud-detection",
{"account", "Class", "customer"}, # Vertex collections
{"accountHolder", "Relationship", "transaction"}, # Edge collections
)
# Use Case 1.3: ArangoDB to DGL via 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)
# Use Case 2: 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.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d1d87a796045a526e30f79935b0589ef39fbf305fa59b444c5012c1156cab95d |
|
MD5 | 278dc714ce3d7b9e442e5d6c46b2f91d |
|
BLAKE2b-256 | c5d2b299817a4d08ebe4ad88d4688e13daf8613e48dfc9b5cc05a7ed3eb1611f |