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.
- 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
- Returns:
True iff a session was deleted as a result of this call.
- 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 (Optional[list[AlgorithmCategory]]) – 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) 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 (Optional[DbmsConnectionInfo]) – The database connection information.
ttl – (Optional[timedelta]): The sessions time to live after inactivity in seconds.
cloud_location (Optional[CloudLocation]) – The cloud location. Required if the GDS session is for a self-managed database.
timeout (Optional[int]) – 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:
AuraGraphDataScience
- 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.
- class graphdatascience.session.gds_sessions.AuraAPICredentials¶
Represents the credentials required for accessing the Aura API.
- client_id¶
The client ID for authentication.
- Type:
str
- client_secret¶
The client secret for authentication.
- Type:
str
- project_id¶
The project ID for authentication. Needed if a client belongs to multiple projects.
- Type:
Optional[str]
- __init__(client_id: str, client_secret: str, project_id: str | None = None) None ¶
- class graphdatascience.session.gds_sessions.SessionInfo¶
Represents information about a session.
- id¶
The ID of the session.
- Type:
str
- name¶
The name of the session.
- Type:
str
- memory¶
The size of the session.
- Type:
str
- instance_id¶
The ID of the AuraDB instance the session is attached to.
- Type:
Optional[str]
- status¶
The status of the session.
- Type:
str
- expiry_date¶
The date the session expires.
- Type:
Optional[datetime]
- created_at¶
The date the session was created.
- Type:
datetime
- user_id¶
The Aura console user-id of the user who created the session.
- Type:
str
- cloud_location¶
The provider and region in which the session is located at.
- Type:
Optional[CloudLocation]
- ttl¶
The time until the session is deleted if unused. The TTL gets renewed on every activity. Rounded down to the nearest minute.
- Type:
Optional[timedelta]
- errors¶
The list of errors related to the session.
- Type:
list[SessionError]
- __init__(id: str, name: str, memory: SessionMemoryValue, instance_id: str | None, status: str, expiry_date: datetime | None, created_at: datetime, user_id: str, cloud_location: CloudLocation | None, ttl: timedelta | None = None, errors: list[SessionErrorData] | None = None) None ¶