AuraGraphDataScience

class graphdatascience.session.AuraGraphDataScience

Primary API class for interacting with Neo4j database + Graph Data Science Session. Always bind this object to a variable called gds.

arrow_client() GdsArrowClient

Returns a GdsArrowClient that is authenticated to communicate with the Aura Graph Analytics Session. This client can be used to get direct access to the specific session’s Arrow Flight server.

Returns:

A GdsArrowClient

Return type:

GdsArrowClient


bookmarks() Any | None

Get the Neo4j bookmarks defining the currently required states for cypher queries to execute

Return type:

The (possibly None) Neo4j bookmarks defining the currently required state

close() None

Close the GraphDataScience object and release any resources held by it.

Return type:

None

database() str | None

Get the database which cypher queries are run against.

Returns:

The name of the database.

Return type:

str | None

delete() bool

Delete a GDS session.

Return type:

bool

driver_config() dict[str, Any]

Get the configuration used to create the underlying driver used to make queries to Neo4j.

Returns:

The configuration as a dictionary.

Return type:

dict[str, Any]

find_node_id(labels: list[str] = [], properties: dict[str, Any] = {}) int

Find the node id of a node with the given labels and properties.

Parameters:
  • labels (list[str]) – The labels of the node to find.

  • properties (dict[str, Any]) – The properties of the node to find.

Returns:

The node id of the node with the given labels and properties.

Return type:

int

last_bookmarks() Any | None

Get the Neo4j bookmarks defining the state following the most recently called query

Return type:

The (possibly None) Neo4j bookmarks defining the state following the most recently called query

list() DataFrame

List all available GDS procedures.

Returns:

A DataFrame containing all available GDS procedures.

Return type:

DataFrame

lp_pipe(name: str) LPTrainingPipeline

Create a Link Prediction training pipeline, with all default settings.

Parameters:

name (str) – The name to give the pipeline. Must be unique within the Pipeline Catalog.

Returns:

A new instance of a Link Prediction pipeline object.

Return type:

LPTrainingPipeline

nc_pipe(name: str) NCTrainingPipeline

Create a Node Classification training pipeline, with all default settings.

Parameters:

name (str) – The name to give the pipeline. Must be unique within the Pipeline Catalog.

Returns:

A new instance of a Node Classification pipeline object.

Return type:

NCTrainingPipeline

nr_pipe(name: str) NRTrainingPipeline

Create a Node Regression training pipeline, with all default settings.

Parameters:

name (str) – The name to give the pipeline. Must be unique within the Pipeline Catalog.

Returns:

A new instance of a Node Regression pipeline object.

Return type:

NRTrainingPipeline

run_cypher(query: str, params: dict[str, Any] | None = None, database: str | None = None, retryable: bool = False, mode: QueryMode = QueryMode.WRITE) DataFrame

Run a Cypher query against the Neo4j database.

Parameters:
  • query (str) – the Cypher query

  • params (dict[str, Any]) – parameters to the query

  • database (str) – the database on which to run the query

  • retryable (bool) – whether the query can be automatically retried. Make sure the query is idempotent if set to True.

  • mode (QueryMode) – the query mode to use (READ or WRITE). Set based on the operation performed in the query.

Returns:

The query result as a DataFrame

Return type:

DataFrame

server_version() ServerVersion

Get the version of the GDS library.

Returns:

The version of the GDS library.

Return type:

ServerVersion

set_bookmarks(bookmarks: Any) None

Set Neo4j bookmarks to require a certain state before the next query gets executed

Parameters:

bookmarks (Bookmark(s)) – The Neo4j bookmarks defining the required state

Return type:

None

set_database(database: str) None

Set the database which cypher queries are run against.

Parameters:

database (str) – The name of the database to run queries against.

Return type:

None

set_show_progress(show_progress: bool) None

Set whether to show progress for running procedures.

Parameters:

show_progress (bool) – Whether to show progress for procedures.

Return type:

None

property v2: SessionV2Endpoints

Return preview v2 endpoints. These endpoints may change without warning. These endpoints are a preview of the API for the next major version of this library.

verify_connectivity() None

Verifies that Aura Graph Analytics Session is ready and the connection to the Aura Graph Analytics Session can be established. Also verifies the connection to the Neo4j database, if specified.

Raises:

Exception – if the session is not running anymore, the session cannot be reached or the database driver cannot connect to the remote.

Return type:

None

version() str

Get the version of the GDS library.

Returns:

The version of the GDS library.

Return type:

str