pysepal.solara.session_manager.SessionManager#

class pysepal.solara.session_manager.SessionManager[source]#

A singleton session manager for solara-sepal applications.

This class manages the lifecycle of sessions across different Solara applications, providing a centralized way to handle session creation, retrieval, and cleanup for GEE interfaces, SepalClient and GDriveInterface.

Note: Do not instantiate this class directly. Use the @with_sepal_sessions decorator or the utility functions in sepal_ui.solara.utils instead.

Initialize the SessionManager singleton instance.

Methods

__init__

Initialize the SessionManager singleton instance.

cleanup_session

Clean up a session for the given kernel ID.

create_session

Create a new session with all the interfaces for the given kernel ID.

get_kernel_id

Get the current kernel ID.

get_session_component

Get a specific component from a session.

get_session_info

Get session information for a specific kernel.

is_initialized

Check if the SessionManager has been initialized.

list_sessions

Get all active sessions.

SessionManager.__init__()[source]#

Initialize the SessionManager singleton instance.

SessionManager.cleanup_session(kernel_id)[source]#

Clean up a session for the given kernel ID.

Parameters:

kernel_id (str) – The kernel ID to clean up.

Return type:

None

SessionManager.create_session(module_name='default')[source]#

Create a new session with all the interfaces for the given kernel ID.

Parameters:
  • kernel_id – The kernel ID to create session for. If None, uses current kernel.

  • module_name (str) – The module name for the SepalClient.

Raises:
  • EEClientError – For authentication-related errors.

  • Exception – For other validation or connection errors.

Return type:

None

SessionManager.get_kernel_id()[source]#

Get the current kernel ID.

Return type:

str

SessionManager.get_session_component(component_name, kernel_id=None)[source]#

Get a specific component from a session.

Parameters:
  • component_name (str) – The name/key of the component to retrieve.

  • kernel_id (str | None) – The kernel ID to get component from. If None, uses current kernel.

Returns:

The component instance or None if not found.

Return type:

Any | None

SessionManager.get_session_info(kernel_id=None)[source]#

Get session information for a specific kernel.

Parameters:

kernel_id (str | None) – The kernel ID to get info for. If None, uses current kernel.

Returns:

Dictionary with session information.

Return type:

dict

classmethod SessionManager.is_initialized()[source]#

Check if the SessionManager has been initialized.

Return type:

bool

SessionManager.list_sessions()[source]#

Get all active sessions.

Return type:

Dict[str, Dict[str, Any]]