Session

class composapy.session.Session(uri: str | None = None, auth_mode: AuthMode = AuthMode.WINDOWS, credentials=None)

A valid, registered, session is required to access and use Composable resources.

from composapy.session import Session
from composapy.auth import AuthMode

Composapy looks for the environment variable APPLICATION_URI by default (set by DataLabs). If you are using Composapy outside of the DataLabs environment and the APPLICATION_URI environment variable is not set, you can set it with keyword argument uri. You can create a session with Windows Authentication (if you are in a DataLab, this will be the same as the key on the DataLab edit screen), a string API Token (can be generated on the Composable website), or with a string tuple containing username and password.

session = Session(auth_mode=AuthMode.WINDOWS)                                                                           # Windows Auth
session = Session(auth_mode=AuthMode.TOKEN, credentials="<your-api-token-here>", uri="http://localhost/CompAnalytics/") # Token
session = Session(auth_mode=AuthMode.FORM, credentials=("username", "password"))                                        # Form

session.register()  # register your session so that composapy uses this
session.register(save=True)  # optionally, save for autoload with configuration file "composapy.ini"
Parameters:
  • uri – The Composable application uri used to access your resources. If using Composapy within DataLabs, uses the environment variable “APPLICATION_URI” that it sets during DataLabs startup. Setting the uri kwarg will override the usage of this environment variable.

  • auth_mode – options are - AuthMode.WINDOWS (default), AuthMode.FORM, AuthMode.TOKEN

  • credentials – The credentials for your specified auth_mode. WINDOWS uses the DataLab user credentials automatically (will raise error if any credentials are given), FORM takes a tuple of (username, password), and TOKEN takes a string token that can be generated in the Composable application.

property app_service: IApplicationService

A Composable csharp binding to the IServices.IApplicationService.

property auth_mode: AuthMode

The current auth mode associated with this Session object instance.

classmethod clear_registration() None

Used to unregister the currently registered session.

Session.clear_registration()
property file_upload_service: IFileUploadService

A Composable csharp binding to the IServices.IFileUploadService object.

property property_service: IPropertyService

A Composable csharp binding to the IServices.IPropertyService.

property queryview_service: IQueryViewService

A Composable csharp binding to the IServices.IQueryViewService object.

register(save=False) None

Used to register a class instance of session that is used implicitly across the kernel. Only one session can registered at a time.

session = Session(auth_mode=AuthMode.WINDOWS)
session.register(save=True)
Parameters:

save – If true, saves configuration in local composapy.ini file. Default is false.

property resource_manager: ResourceManager

A Composable csharp binding to the IServices.Deploy.ResourceManager object.

property table_service: ITableService

A Composable csharp binding to the IServices.ITableService object.

property uri: str

Sometimes referred to as ‘application uri’.