Understanding Resources
Tutorial
Understanding Resources
Learn the Mapping → Instance resource model
What You'll Learn
- Resource Model - Understand the Mapping → Instance flow
- Mappings - Browse and inspect graph schema definitions
- Instances - Create, connect, and manage graph databases
- Lifecycle - Extend TTL and terminate instances
1
Setup
Connect to the Graph OLAP platform
# Cell 1 — ParametersUSERNAME = "_FILL_ME_IN_" # Set your email before running# Cell 2 — Connectfrom graph_olap import GraphOLAPClientclient = GraphOLAPClient(username=USERNAME)
# Cell 3 — Provisionfrom notebook_setup import provisionpersonas, conn = provision(USERNAME)analyst = personas["analyst"]admin = personas["admin"]ops = personas["ops"]client = analyst
print(f"Connected to: {client._config.api_url}")
2
Working with Mappings
Browse available graph schema definitions
# List all available mappingsmappings = client.mappings.list()print(f"Available mappings: {len(mappings)}")for m in mappings: print(f" [{m.id}] {m.name}")
# Find the tutorial mapping by name (not by index — parallel CI has multiple)tutorial_mappings = [m for m in mappings if "tutorial-customer-graph" in m.name]mapping = tutorial_mappings[0] if tutorial_mappings else mappings[0]mapping_detail = client.mappings.get(mapping.id)print(f"\nMapping detail: {mapping_detail.name} (id={mapping_detail.id})")
3
Creating Instances
Deploy a queryable graph database from a mapping
from graph_olap_schemas import WrapperType
# Create an instance directly from the tutorial mappinginstance = client.instances.create_and_wait( mapping_id=mapping.id, name="resources-demo", wrapper_type=WrapperType.RYUGRAPH, ttl="PT1H",)print(f"Instance: {instance.name} (status={instance.status})")
# Connect to OUR instance and query it to prove it worksdemo_conn = client.instances.connect(instance.id)result = demo_conn.query("MATCH (c:Customer) RETURN c.id AS name LIMIT 3")result.show()
4
Instance Lifecycle
Extend TTL and terminate instances
# Extend instance TTL to keep it running longerclient.instances.extend_ttl(instance.id, hours=24)print(f"Extended TTL for instance {instance.name} by 24 hours")# Clean up the demo instance we createdtry: client.instances.terminate(instance.id) print(f"Terminated instance: {instance.name}")except Exception as e: print(f"Cleanup: {e}")Key Takeaways
- Mappings define the graph schema (nodes, edges, properties from warehouse tables)
- Instances are created directly from mappings using
create_and_wait() - Use
extend_ttl()to keep instances running andterminate()to free resources - Resource lifecycle: pending → running → terminated