Graphistry for Neptune using pygraphistry bolt connector#
This example uses pygraphistry bolt helper class to run queries against AWS Neptune and retrieve query results as graph, then the bolt helper function extracts all the nodes and edges into the dataframes automatically. Then visualize the resulting datasets using Graphistry.#
[ ]:
!pip install --user neo4j
[ ]:
!pip install --user awswrangler
[ ]:
!pip install --user graphistry
make sure to restart kernel after pip install#
[ ]:
import awswrangler as wr
import pandas as pd
import graphistry
graphistry.__version__
Configure graphistry connnection#
[ ]:
# To specify Graphistry account & server, use:
# graphistry.register(api=3, username='...', password='...', protocol='https', server='hub.graphistry.com')
# To run from a graphistry-host jupyter notebook:
# graphistry.register(api=3, username="...", password="...", protocol="http", server="nginx")
# to use personal keys:
# graphistry.register(api=3, protocol="...", server="...", personal_key_id='pkey_id', personal_key_secret='pkey_secret') # Key instead of username+password+org_name
# For more options, see https://github.com/graphistry/pygraphistry#configure
graphistry.register(api=3, username="...", password="...", protocol="...", server="...")
Configure Neptune connection endpoint:#
[ ]:
# update with your Neptune endpoint name:
url='NEPTUNE_NAME.REGION.neptune.amazonaws.com'
[ ]:
iam_enabled = False # Set to True/False based on the configuration of your cluster
neptune_port = 8182 # Set to the Neptune Cluster Port, Default is 8182
neptune_region = 'us-east-1' # Set to neptune region
client = wr.neptune.connect(url, neptune_port, iam_enabled=iam_enabled, region=neptune_region)
[ ]:
# check status of neptune connection:
client.status()
Connect to Neptune using pygraphistry bolt connector#
[ ]:
from neo4j import GraphDatabase
uri = f"bolt://{url}:8182"
driver = GraphDatabase.driver(uri, auth=("ignored", "ignored"), encrypted=True)
graphistry.register(bolt=driver)
g = graphistry.cypher("MATCH (a)-[r]->(b) return a, r, b limit 10000")
[ ]:
g.plot()
[ ]: