GDS Sessions¶
- class graphdatascience.session.gds_sessions.GdsSessions¶
Primary API class for managing GDS sessions hosted in Neo4j Aura.
- __init__(api_credentials: AuraAPICredentials) None¶
Initializes a new instance of the GdsSessions class.
- Parameters:
api_credentials (AuraAPICredentials) – The Aura API credentials used for establishing a connection.
- Return type:
None
- available_cloud_locations() list[CloudLocation]¶
Retrieves the list of available cloud locations in Aura.
- Returns:
The list of available cloud locations.
- Return type:
Set[CloudLocation]
- delete(*, session_name: str | None = None, session_id: str | None = None) bool¶
Delete a GDS session either by name or id. :param session_name: the name of the session to delete :param session_id: the id of the session to delete
- estimate(node_count: int, relationship_count: int, algorithm_categories: list[AlgorithmCategory] | None = None) SessionMemory¶
Estimates the memory required for a session with the given node and relationship counts.
- Parameters:
node_count (int) – The number of nodes.
relationship_count (int) – The number of relationships.
algorithm_categories (list[AlgorithmCategory] | None) – The algorithm categories to consider.
- Returns:
The estimated memory required for the session.
- Return type:
- get_or_create(session_name: str, memory: SessionMemory, db_connection: DbmsConnectionInfo | None = None, ttl: timedelta | None = None, cloud_location: CloudLocation | None = None, timeout: int | None = None, neo4j_driver_config: dict[str, Any] | None = None, arrow_client_options: dict[str, Any] | None = None) AuraGraphDataScience¶
Retrieves an existing session with the given session name and database connection, or creates a new session if one does not exist.
If the session is close to expiration, a warning will be raised. If the session failed, an exception will be raised.
- Parameters:
session_name (str) – The name of the session.
memory (SessionMemory) – The size of the session specified by memory.
db_connection (DbmsConnectionInfo | None) – The database connection information.
ttl (timedelta | None) – (timedelta | None): The sessions time to live after inactivity in seconds.
cloud_location (CloudLocation | None) – The cloud location. Required if the GDS session is for a self-managed database.
timeout – Optional timeout (in seconds) when waiting for session to become ready. If unset the method will wait forever. If set and session does not become ready an exception will be raised. It is user responsibility to ensure resource gets cleaned up in this situation.
- Returns:
The session.
- Return type:
- list() list[SessionInfo]¶
Retrieves the list of GDS sessions visible by the user associated by the given api-credentials.
- Returns:
A list of SessionInfo objects representing the GDS sessions.
- Return type:
- class graphdatascience.session.gds_sessions.AuraAPICredentials¶
Represents the credentials required for accessing the Aura API.
- project_id¶
The project ID for authentication. Needed if a client belongs to multiple projects.
- Type:
str | None
- static from_env() AuraAPICredentials¶
Create an AuraApi instance from environment variables. The environment variables are: - CLIENT_ID - CLIENT_SECRET - PROJECT_ID
- Return type:
- class graphdatascience.session.gds_sessions.SessionInfo¶
Represents information about a session.
- expiry_date¶
The date the session expires. This is a fixed limit regardless of the user-defined TTL.
- Type:
datetime | None
- created_at¶
The date the session was created.
- Type:
datetime
- cloud_location¶
The provider and region in which the session is located at.
- Type:
CloudLocation | None
- ttl¶
The time until the session is deleted if unused. The TTL gets renewed on every activity. Rounded down to the nearest minute.
- Type:
timedelta | None