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.

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: Open In 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

  1. git clone https://github.com/arangoml/dgl-adapter.git
  2. cd dgl-adapter
  3. (create virtual environment of choice)
  4. pip install -e .[dev]
  5. (create an ArangoDB instance with method of choice)
  6. 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

adbdgl_adapter-2.0.0.tar.gz (23.7 kB view details)

Uploaded Source

Built Distribution

adbdgl_adapter-2.0.0-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: adbdgl_adapter-2.0.0.tar.gz
  • Upload date:
  • Size: 23.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.8.12

File hashes

Hashes for adbdgl_adapter-2.0.0.tar.gz
Algorithm Hash digest
SHA256 effa77e2cea8b775e16766ddc1f6eeee8fdb7f96f0a71d77edeb7d2e8189304f
MD5 61b3a67fbca25c0edeebc147f4da4545
BLAKE2b-256 e052437607ddc654680e2faa199fe9abe2a66349c3827200ad3285c817f02066

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for adbdgl_adapter-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b730777543bab621aed0a00a28f4851d9f255f431471cf135aa69f121501ab55
MD5 8067f253c4abbfc24d2a8b22747bdb90
BLAKE2b-256 901e5d37da6bd142265f3c6f425cbcef86e72487ddea1b33489fc0f81dc86949

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