Skip to content

Models

Reference

Models

Data classes and type definitions

10 min Beginner
ReferenceAPIModels

The SDK uses immutable Pydantic models (and dataclasses for ops) to represent every API response. All models live in graph_olap.models and are re-exported from the top-level package.

This notebook walks through every model family, showing how to access attributes on real objects returned by the API.

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 {conn.name} | {conn.query_scalar('MATCH (n) RETURN count(n)')} nodes")
2

Instance Models

Instance, InstanceProgress, InstanceStatus, LockStatus

Returned by client.instances.get(), .list(), .create(), and related methods. Key attributes:

AttributeTypeDescription
idintUnique instance ID
namestr | NoneHuman-readable name
statusstr | NoneLifecycle state (running, starting, failed, …)
wrapper_typestr | None"falkordb" or "ryugraph"
owner_usernamestr | NoneOwner of this instance
snapshot_idint | NoneSource snapshot ID
created_atdatetime | NoneCreation timestamp
updated_atdatetime | NoneLast update timestamp
expires_atdatetime | NoneTTL expiry
ttlstr | NoneISO 8601 duration
inactivity_timeoutstr | NoneAuto-terminate after idle
memory_usage_bytesint | NoneMemory consumption
cpu_coresint | NoneCPU allocation

Properties: is_running, memory_mb, disk_mb.

# Fetch a running instance and inspect its attributes
instances = client.instances.list(status="running", limit=1)
inst = instances.items[0]
print(f"id: {inst.id}")
print(f"name: {inst.name}")
print(f"status: {inst.status}")
print(f"wrapper_type: {inst.wrapper_type}")
print(f"owner_username: {inst.owner_username}")
print(f"created_at: {inst.created_at}")
print(f"is_running: {inst.is_running}")
print(f"memory_mb: {inst.memory_mb}")

Enum of valid instance lifecycle states, re-exported from graph_olap_schemas.

ValueDescription
WAITING_FOR_SNAPSHOTPending snapshot creation
STARTINGPod is being provisioned
RUNNINGReady for queries
STOPPINGBeing terminated
FAILEDStartup or runtime failure
from graph_olap.models import InstanceStatus
print("All statuses:")
for s in InstanceStatus:
print(f" {s.name} = {s.value!r}")
# Compare with a live instance
print(f"\nInstance status matches RUNNING: {inst.status == InstanceStatus.RUNNING}")

Returned by client.instances.get_progress(). Tracks startup phases.

AttributeTypeDescription
phasestrCurrent phase (pod_scheduled, downloading, loading_data, ready, …)
progress_percentint0—100 completion percentage
current_stepstr | NoneHuman-readable step description
stepslist[dict]Detailed step list
error_messagestr | NoneError details if failed

Properties: completed_steps, total_steps.

progress = client.instances.get_progress(inst.id)
print(f"phase: {progress.phase}")
print(f"progress_percent: {progress.progress_percent}%")
print(f"current_step: {progress.current_step}")
print(f"completed_steps: {progress.completed_steps}/{progress.total_steps}")

Returned by lock-related instance methods. Shows whether an instance is locked for algorithm execution.

AttributeTypeDescription
lockedboolWhether the instance is locked
holder_idstr | NoneID of the lock holder
holder_namestr | NoneUsername of the lock holder
algorithmstr | NoneAlgorithm holding the lock
algorithm_typestr | None"native" or "networkx"
execution_idstr | NoneExecution that holds the lock
locked_atdatetime | NoneWhen the lock was acquired
3

Mapping Models

Mapping, MappingVersion, MappingDiff, NodeDefinition, EdgeDefinition

Returned by client.mappings.get() and .list(). Represents a graph-to-SQL mapping definition.

AttributeTypeDescription
idintMapping ID
namestr | NoneMapping name
descriptionstr | NoneHuman-readable description
owner_usernamestr | NoneOwner
current_versionint | NoneLatest version number
node_countint | NoneNumber of node types (list endpoint)
edge_type_countint | NoneNumber of edge types (list endpoint)
node_definitionslist[NodeDefinition]Node definitions (detail endpoint)
edge_definitionslist[EdgeDefinition]Edge definitions (detail endpoint)
created_atdatetime | NoneCreation timestamp
updated_atdatetime | NoneLast update timestamp
mappings = client.mappings.list(limit=1)
m = mappings.items[0]
print(f"id: {m.id}")
print(f"name: {m.name}")
print(f"owner_username: {m.owner_username}")
print(f"current_version: {m.current_version}")
print(f"node_count: {m.node_count}")
print(f"edge_type_count: {m.edge_type_count}")
print(f"created_at: {m.created_at}")

An immutable snapshot of a mapping at a specific version.

AttributeTypeDescription
mapping_idint | NoneParent mapping ID
versionintVersion number
change_descriptionstr | NoneWhat changed
node_definitionslist[NodeDefinition]Node definitions
edge_definitionslist[EdgeDefinition]Edge definitions
created_atdatetime | NoneWhen this version was created
created_bystr | NoneWho created it

Describe nodes and edges within a mapping version.

NodeDefinition:

AttributeTypeDescription
labelstrNode label
sqlstrSQL query to populate this node
primary_keydict[str, str]{"name": ..., "type": ...}
propertieslist[PropertyDefinition]Property definitions

EdgeDefinition:

AttributeTypeDescription
typestrRelationship type
from_nodestrSource node label
to_nodestrTarget node label
sqlstrSQL query
from_keystrForeign key on source side
to_keystrForeign key on target side
propertieslist[PropertyDefinition]Property definitions
# Fetch full mapping detail to see definitions
mapping_detail = client.mappings.get(m.id)
for node in mapping_detail.node_definitions:
print(f"Node: {node.label}")
print(f" primary_key: {node.primary_key}")
print(f" properties: {[p.name for p in node.properties]}")
print(f" sql: {node.sql[:60]}...")
print()
for edge in mapping_detail.edge_definitions:
print(f"Edge: {edge.from_node} --[{edge.type}]--> {edge.to_node}")
print(f" from_key: {edge.from_key}, to_key: {edge.to_key}")

Returned by client.mappings.diff(). Semantic comparison between two mapping versions.

AttributeTypeDescription
mapping_idintMapping ID
from_versionintBase version
to_versionintTarget version
summarydict[str, int]Counts of added/removed/modified nodes and edges
changesdictDetailed NodeDiff and EdgeDiff objects

Helper methods: nodes_added(), nodes_removed(), nodes_modified(), edges_added(), edges_removed(), edges_modified().

Re-exported from graph_olap_schemas:

  • PrimaryKeyDefinition — primary key definition with name and type fields.
  • RyugraphType — enum of supported data types (STRING, INT64, DOUBLE, BOOL, DATE, TIMESTAMP, etc.).
4

Query & Schema Models

QueryResult, Schema, AlgorithmExecution, Favorite

Returned by conn.query(). Supports iteration as dicts, conversion to DataFrames, and single-value extraction.

AttributeTypeDescription
columnslist[str]Column names
column_typeslist[str]Ryugraph types (STRING, INT64, …)
rowslist[list]Raw row data
row_countintNumber of rows
execution_time_msintQuery execution time

Key methods: to_polars(), to_pandas(), to_networkx(), scalar(), to_dicts(), to_csv(path), to_parquet(path), show().

result = conn.query(
"MATCH (c:Customer) RETURN c.id AS name, c.bk_sectr AS sector LIMIT 3"
)
print(f"columns: {result.columns}")
print(f"row_count: {result.row_count}")
print(f"execution_time: {result.execution_time_ms}ms")
print()
# Iterate as dicts
print("Rows (dict iteration):")
for row in result:
print(f" {row['name']} ({row['sector']})")
# scalar() -- extract a single value
count = conn.query("MATCH (c:Customer) RETURN count(c) AS cnt").scalar()
print(f"Customer count: {count}")
# to_polars()
df = result.to_polars()
print(f"\nPolars DataFrame:\n{df}")

Returned by conn.schema(). Describes the graph structure of a running instance.

AttributeTypeDescription
node_labelsdict[str, list[str]]Label to property names
relationship_typesdict[str, list[str]]Rel type to property names
node_countintTotal nodes in the graph
relationship_countintTotal relationships
schema = conn.get_schema()
print(f"Nodes: {schema.node_count:,}, Relationships: {schema.relationship_count:,}")
print()
print("Node labels:")
for label, props in schema.node_labels.items():
print(f" :{label} -> {props}")
print()
print("Relationship types:")
for rel_type, props in schema.relationship_types.items():
print(f" :{rel_type} -> {props}")

Returned by algorithm execution methods. Tracks the status and result of a graph algorithm run.

AttributeTypeDescription
execution_idstrUnique execution ID
algorithmstrAlgorithm name
algorithm_typestr | None"native" or "networkx"
statusstr"pending", "running", "completed", "failed", "cancelled"
started_atdatetimeExecution start time
completed_atdatetime | NoneCompletion time
duration_msint | NoneTotal execution time
nodes_updatedint | NoneNodes written to
resultdict | NoneAlgorithm-specific result data
error_messagestr | NoneError details if failed

Represents a user bookmark for a mapping or instance.

AttributeTypeDescription
resource_typestr"mapping" or "instance"
resource_idintID of the bookmarked resource
resource_namestrName of the bookmarked resource
created_atdatetimeWhen the bookmark was created
5

Pagination

PaginatedList for all list endpoints

All list endpoints return PaginatedList. It wraps a page of results with metadata for navigating through large result sets.

AttributeTypeDescription
itemslist[T]Current page of items
totalintTotal number of items across all pages
offsetintCurrent page offset
limitintPage size

Properties: has_more, page_count.

Supports len(), iteration, and indexing.

page = client.instances.list(status="running", limit=2, offset=0)
print(f"items: {len(page.items)} items on this page")
print(f"total: {page.total} total across all pages")
print(f"offset: {page.offset}")
print(f"limit: {page.limit}")
print(f"has_more: {page.has_more}")
print(f"page_count: {page.page_count}")
print()
# Iterate directly
print("Iteration:")
for inst in page:
print(f" [{inst.id}] {inst.name}")
# Index access
print(f"\nFirst item via index: {page[0].name}")
6

Ops Models

Cluster health, configuration, and limits (ops role required)

The following models are returned by client.ops.* methods and require the ops role. They are documented here for completeness but cannot be demonstrated without ops credentials.

AttributeTypeDescription
statusstr"healthy", "degraded", "unhealthy"
componentsdict[str, ComponentHealth]Per-component health
checked_atdatetimeWhen health was last checked
AttributeTypeDescription
statusstrComponent status
latency_msint | NoneResponse latency
errorstr | NoneError message if unhealthy
AttributeTypeDescription
totalintTotal instances across the cluster
by_statusdict[str, int]Instance counts per status
by_ownerlist[OwnerInstanceCount]Instance counts per user
limitsInstanceLimitsCurrent limits
AttributeTypeDescription
per_analystintMax instances per analyst
cluster_totalintMax instances cluster-wide
cluster_usedintCurrently used
cluster_availableintAvailable capacity
AttributeTypeDescription
per_analystintMax concurrent instances per analyst
cluster_totalintMax concurrent instances cluster-wide
updated_atdatetime | NoneLast configuration change
AttributeTypeDescription
mappingResourceLifecycleConfigMapping lifecycle defaults
snapshotResourceLifecycleConfigSnapshot lifecycle defaults
instanceResourceLifecycleConfigInstance lifecycle defaults

Each ResourceLifecycleConfig has: default_ttl, default_inactivity, max_ttl.

AttributeTypeDescription
max_duration_secondsintMaximum export job duration
updated_atdatetime | NoneLast change
updated_bystr | NoneWho changed it
AttributeTypeDescription
enabledboolWhether maintenance mode is active
messagestrMessage shown to users
updated_atdatetime | NoneLast toggle
updated_bystr | NoneWho toggled it
AttributeTypeDescription
statusstr"ok" or error state
versionstr | NoneAPI version
databasestr | NoneDatabase connection status

Key Takeaways

  • All models are immutable (frozen Pydantic models or frozen dataclasses)
  • QueryResult supports multiple output formats: dict iteration, to_polars(), to_pandas(), scalar()
  • PaginatedList wraps every list endpoint with .total, .has_more, and direct iteration
  • Instance and mapping models carry rich metadata -- timestamps, resource usage, lifecycle state
  • Ops models require the ops role and are used for cluster administration