Skip to main content

Convert ArangoDB graphs to DGL & vice-versa.

Project description

ArangoDB-DGL Adapter

build CodeQL Coverage Status Last commit

PyPI version badge Python versions badge

License Code style: black Downloads

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.

Quickstart

Get Started on Colab: Open In Colab

# Import the ArangoDB-DGL Adapter
from adbdgl_adapter.adapter import ADBDGL_Adapter

# Import a sample graph from DGL
from dgl.data import KarateClubDataset

# This is the connection information for your ArangoDB instance
# (Let's assume that the ArangoDB fraud-detection data dump is imported to this endpoint)
con = {
    "hostname": "localhost",
    "protocol": "http",
    "port": 8529,
    "username": "root",
    "password": "rootpassword",
    "dbName": "_system",
}

# This instantiates your ADBDGL Adapter with your connection credentials
adbdgl_adapter = ADBDGL_Adapter(con)

# ArangoDB to DGL via Graph
dgl_fraud_graph = adbdgl_adapter.arangodb_graph_to_dgl("fraud-detection")

# ArangoDB to DGL via Collections
dgl_fraud_graph_2 = adbdgl_adapter.arangodb_collections_to_dgl(
        "fraud-detection", 
        {"account", "Class", "customer"}, # Specify vertex collections
        {"accountHolder", "Relationship", "transaction"}, # Specify edge collections
)

# 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)

# DGL to ArangoDB
dgl_karate_graph = KarateClubDataset()[0]
adb_karate_graph = adbdgl_adapter.dgl_to_arangodb("Karate", karate_dgl_g)

Development & Testing

Prerequisite: arangorestore must be installed

  1. git clone https://github.com/arangoml/dgl-adapter.git
  2. cd dgl-adapter
  3. python -m venv .venv
  4. source .venv/bin/activate (MacOS) or .venv/scripts/activate (Windows)
  5. pip install -e . pytest
  6. pytest

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

adbdgl_adapter-1.0.2.tar.gz (22.5 kB view details)

Uploaded Source

Built Distribution

adbdgl_adapter-1.0.2-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

Details for the file adbdgl_adapter-1.0.2.tar.gz.

File metadata

  • Download URL: adbdgl_adapter-1.0.2.tar.gz
  • Upload date:
  • Size: 22.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for adbdgl_adapter-1.0.2.tar.gz
Algorithm Hash digest
SHA256 acfb98e5e139b5259837f1bccddec95b3197b783e2bb30f6af298922537489a2
MD5 78dafce40c6631fc7ddd6b3ad8d1a7e4
BLAKE2b-256 b409eb5ffd3edeef5f523a6dab2ea9ac13fbb738c6695bde1c883c52bce78b6a

See more details on using hashes here.

File details

Details for the file adbdgl_adapter-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: adbdgl_adapter-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 14.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for adbdgl_adapter-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 446f05bab5cf4ad0fc18cb00a72472422964adc5fcc82609446ea9fa16f766bf
MD5 1294445df6dfcb7696ba0bc1cfa2c0e0
BLAKE2b-256 b4a49998c44eeb818e0bcfeeedef2dd4fcd4f493389a0fc960a57428e36fef4c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page