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, 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

Open In Collab

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

  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.1.0.tar.gz (24.1 kB view details)

Uploaded Source

Built Distribution

adbdgl_adapter-2.1.0-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: adbdgl_adapter-2.1.0.tar.gz
  • Upload date:
  • Size: 24.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.13

File hashes

Hashes for adbdgl_adapter-2.1.0.tar.gz
Algorithm Hash digest
SHA256 729d52a8efab69937fee4ae7491f62711abb0413a87a774e3ca19098fb3788db
MD5 361a63dca83a11b0c73c9a6823cf8cb7
BLAKE2b-256 b211a837d31d84f3701d469176c436ce041b79b206d139e5dfaf6e0fd1c0b3b8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for adbdgl_adapter-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d1d87a796045a526e30f79935b0589ef39fbf305fa59b444c5012c1156cab95d
MD5 278dc714ce3d7b9e442e5d6c46b2f91d
BLAKE2b-256 c5d2b299817a4d08ebe4ad88d4688e13daf8613e48dfc9b5cc05a7ed3eb1611f

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