Skip to content

Complete Workflows

Tutorial

Complete Workflows

End-to-end patterns for common graph analytics tasks

45 min Advanced
WorkflowPatternsBest Practices

What You'll Learn

  • Setup - Connect to the platform
  • Discovery - Explore mappings and warehouse schema
  • Instance and Query - Deploy a graph and run Cypher queries
  • Cleanup - Extend or terminate instances when finished
1

Setup

Connect to the platform

# Cell 1 — Parameters
USERNAME = "_FILL_ME_IN_" # Set your email before running
# Cell 2 — Connect
from graph_olap import GraphOLAPClient
client = GraphOLAPClient(username=USERNAME)
# Cell 3 — Provision
from notebook_setup import provision
personas, conn = provision(USERNAME)
analyst = personas["analyst"]
admin = personas["admin"]
ops = personas["ops"]
client = analyst
print(f"Connected to: {client._config.api_url}")
2

Discovery Workflow

Explore mappings and schema before querying

# Step 1: List available mappings
mappings = client.mappings.list()
print(f"Available mappings: {len(mappings)}")
for m in mappings:
print(f" [{m.id}] {m.name}")
# Step 2: Browse the warehouse schema
catalogs = client.schema.list_catalogs()
for cat in catalogs:
schemas = client.schema.list_schemas(cat.catalog_name)
for s in schemas:
tables = client.schema.list_tables(cat.catalog_name, s.schema_name)
print(f"\n{cat.catalog_name}.{s.schema_name}:")
for t in tables:
print(f" {t.table_name}")
3

Instance and Query Workflow

Create an instance, run queries, and analyze results

from graph_olap_schemas import WrapperType
# Step 3: Create an instance from the tutorial mapping
tutorial_mappings = [m for m in mappings if "tutorial-customer-graph" in m.name]
mapping = tutorial_mappings[0] if tutorial_mappings else mappings[0]
instance = client.instances.create_and_wait(
mapping_id=mapping.id,
name="workflow-demo",
wrapper_type=WrapperType.RYUGRAPH,
ttl="PT1H",
timeout=300,
)
print(f"Instance '{instance.name}' is {instance.status}")
# Step 4: Connect and query your customer data
demo_conn = client.instances.connect(instance.id)
result = demo_conn.query("""
MATCH (c:Customer)
RETURN c.id AS name
LIMIT 5
""")
result.show()
# Step 5: Count edges
edge_count = demo_conn.query_scalar("MATCH ()-[r:SHARES_ACCOUNT]->() RETURN count(r)")
print(f"\nSHARES_ACCOUNT edges: {edge_count}")
4

Cleanup Workflow

Extend or terminate instances when finished

Key Takeaways

  • Discovery: use client.mappings.list() and client.schema.* to explore data
  • Deployment: use client.instances.create_and_wait(mapping_id=...) to spin up a graph
  • Querying: use conn.query() for Cypher and conn.query_scalar() for single values
  • Cleanup: always terminate() instances when finished to free resources
# Clean up the demo instance we created
try:
client.instances.terminate(instance.id)
print(f"Terminated instance: {instance.name}")
except Exception as e:
print(f"Cleanup: {e}")