atoti.Session.connect#
- classmethod Session.connect(url, *, authentication=None, certificate_authority=None)#
Connect to an existing session.
Here is a breakdown of the Live extension capabilities of the returned session:
Local
If all the following conditions are met:
the target session requires authentication (e.g. it has
security
configured)
the provided authentication or certificate_authority arguments grant ROLE_ADMIN
the target session (the one at url) was
started
with the same version of Atoti Python API (0.9.2)
the target session runs on the same host as the current Python process
Then all
Session
capabilities can be used except for:
Remote
If conditions a., b., and c. are met but not d. (i.e., not on the same host)
Then all local capabilities are available except those needing a shared file system. For example:
load()
withCsvLoad
orParquetLoad
,read_csv()
, andread_parquet()
are not available (unless loading from cloud storage)load()
withpyarrow.Table
orpandas.DataFrame
,read_arrow()
andread_pandas()
methods are not available
No security management
If conditions a. and b. are meet, plus both:
the target session runs the same Atoti Server version (e.g. 6.1.2 for Atoti Python API 0.9.2)
the target session is exposed to Atoti Python API
Depending on whether d. is met, either local or remote capabilities are available, except for
security
management features.
Read-only
If only condition e. is met (i.e. matching Atoti Server versions)
Then capabilities that modify the session data or data model are unavailable. However, some read-only capabilities remain accessible. For example:
Not available:
create_table()
,create_cube()
, andread_csv()
Available:
atoti.tables.Tables.schema
andatoti.Table.query()
Minimal capabilities
Always available:
Note
Data and data model changes made from a connected session are not persisted on the target session. They will be lost if the target session is restarted.
- Parameters:
url (str) – The base URL of the target session. The endpoint
f"{url}/versions/rest"
is expected to exist.authentication (Authenticate | ClientCertificate | None) – The method used to authenticate against the target session.
certificate_authority (Path | None) – Path to the custom certificate authority file to use to verify the HTTPS connection. Required when the target session has been configured with an SSL certificate that is not signed by some trusted public certificate authority.
- Return type:
Example
>>> session_config = tt.SessionConfig(security=tt.SecurityConfig()) >>> secure_session = tt.Session.start(session_config) >>> _ = secure_session.create_table("Example", data_types={"Id": "String"}) >>> secure_session.security.basic_authentication.credentials.update( ... {"user": "passwd", "admin": "passwd"} ... ) >>> secure_session.security.individual_roles.update( ... {"user": {"ROLE_USER"}, "admin": {"ROLE_USER", "ROLE_ADMIN"}} ... ) >>> admin_session = tt.Session.connect( ... secure_session.url, ... authentication=tt.BasicAuthentication("admin", "passwd"), ... ) >>> table = admin_session.tables["Example"] >>> table += ("foo",) >>> table.head() Id 0 foo
Live extension requires the connected session to be granted ROLE_ADMIN:
>>> user_session = tt.Session.connect( ... secure_session.url, ... authentication=tt.BasicAuthentication("user", "passwd"), ... ) >>> list(user_session.tables) Traceback (most recent call last): ... atoti._live_extension_unavailable_error.LiveExtensionUnavailableError: ...
Live extension requires the target session to be secure:
>>> unsecure_session = tt.Session.start() >>> _ = unsecure_session.create_table("Example", data_types={"Id": "String"}) >>> connected_session = tt.Session.connect(unsecure_session.url) >>> list(connected_session.tables) Traceback (most recent call last): ... atoti._live_extension_unavailable_error.LiveExtensionUnavailableError: ...
See also