deephaven_enterprise.client.session_manager¶
- class DndSession(session_manager, pqinfo, host=None, port=None, auth_type='io.deephaven.proto.auth.Token', auth_token=None, extra_headers=None, delete_on_close=None, session_arguments=None)[source]¶
Bases:
Session
Wrapper around a basic Community session. For queries that are ephemeral, they are explicitly deleted on session close.
Initializes a Session object that connects to the Deephaven server
- Parameters:
host (str) – the host name or IP address of the remote machine, default is ‘localhost’
port (int) – the port number that Deephaven server is listening on, default is 10000
auth_type (str) – the authentication type string, can be “Anonymous’, ‘Basic”, or any custom-built authenticator in the server, such as “io.deephaven.authentication.psk.PskAuthenticationHandler”, default is ‘Anonymous’.
auth_token (str) – the authentication token string. When auth_type is ‘Basic’, it must be “user:password”; when auth_type is “Anonymous’, it will be ignored; when auth_type is a custom-built authenticator, it must conform to the specific requirement of the authenticator
never_timeout (bool) – never allow the session to timeout, default is True
session_type (str) – the Deephaven session type. Defaults to ‘python’
use_tls (bool) – if True, use a TLS connection. Defaults to False
tls_root_certs (bytes) – PEM encoded root certificates to use for TLS connection, or None to use system defaults. If not None implies use a TLS connection and the use_tls argument should have been passed as True. Defaults to None
client_cert_chain (bytes) – PEM encoded client certificate if using mutual TLS. Defaults to None, which implies not using mutual TLS.
client_private_key (bytes) – PEM encoded client private key for client_cert_chain if using mutual TLS. Defaults to None, which implies not using mutual TLS.
client_opts (List[Tuple[str,Union[int,str]]) –
list of tuples for name and value of options to the underlying grpc channel creation. Defaults to None, which implies not using any channel options. See https://grpc.github.io/grpc/cpp/group__grpc__arg__keys.html for a list of valid options. Example options:
- [ (‘grpc.target_name_override’, ‘idonthaveadnsforthishost’),
(‘grpc.min_reconnect_backoff_ms’, 2000) ]
extra_headers (Dict[bytes, bytes]) – additional headers (and values) to add to server requests. Defaults to None, which implies not using any extra headers.
- Raises:
DHError –
- bind_table(name, table)¶
Binds a table to the given name on the server so that it can be referenced by that name.
- catalog_table()[source]¶
Fetches the catalog table from the database on the server.
- Returns:
a Table object
- Raise:
DHError
- empty_table(size)¶
Creates an empty table on the server.
- historical_table(namespace, table_name)[source]¶
Fetches a historical table from the database on the server.
- import_table(data)¶
Imports the pyarrow table as a new Deephaven table on the server.
Deephaven supports most of the Arrow data types. However, if the pyarrow table contains any field with a data type not supported by Deephaven, the import operation will fail.
- Parameters:
data (pa.Table) – a pyarrow Table object
- Return type:
- Returns:
a Table object
- Raises:
DHError –
- input_table(schema=None, init_table=None, key_cols=None)¶
Creates an InputTable from either Arrow schema or initial table. When key columns are provided, the InputTable will be keyed, otherwise it will be append-only.
- Parameters:
- Return type:
- Returns:
an InputTable
- Raises:
DHError, ValueError –
- property is_alive¶
Whether the session is alive.
- merge_tables(tables, order_by=None)¶
Merges several tables into one table on the server.
- open_table(name)¶
Opens a table in the global scope with the given name on the server.
- plugin_client(exportable_obj)¶
Wraps a ticket as a PluginClient. Capabilities here vary based on the server implementation of the ObjectType, but most will at least send a response payload to the client, possibly including references to other objects. In some cases, depending on the server implementation, the client will also be able to send the same sort of messages back to the server.
Part of the experimental plugin API.
- Return type:
- query(table)¶
Creates a Query object to define a sequence of operations on a Deephaven table.
- Parameters:
table (Table) – a Table object
- Return type:
- Returns:
a Query object
- Raises:
DHError –
- run_script(script)¶
Runs the supplied Python script on the server.
- time_table(period, start_time=None, blink_table=False)¶
Creates a time table on the server.
- Parameters:
period (Union[int, str]) – the interval at which the time table ticks (adds a row); units are nanoseconds or a time interval string, e.g. “PT00:00:.001” or “PT1S”
start_time (Union[int, str]) – the start time for the time table in nanoseconds or as a date time formatted string; default is None (meaning now)
blink_table (bool, optional) – if the time table should be a blink table, defaults to False
- Return type:
- Returns:
a Table object
- Raises:
DHError –
- class SessionManager(url=None, json=None)[source]¶
Bases:
object
The SessionManager authenticates to the Deephaven Enterprise server and allows you to create sessions for DnD workers by either creating a new temporary Persistent Query or connecting to an existing Persistent Query.
Create a SessionManager for the specified JSON, which may either be a string or a URL to download. The Deephaven server typically provides the JSON as “https://host:port/iris/connection.json”. Exactly one of url or json must be provided.
The JSON must have the following parameters: auth_host, auth_port, controller_host, controller_port. If the truststore_url is set, then a trust store PEM file is downloaded from the given URL. If the override_authorities, parameter is set then the authority used for the SSL connection is “authserver”.
- Parameters:
- close()[source]¶
Terminate this session managers connection to the authentication server and controller.
- connect_to_new_worker(name, heap_size_gb, server=None, extra_jvm_args=None, extra_environment_vars=None, engine='DeephavenCommunity', auto_delete_timeout=600, admin_groups=None, viewer_groups=None, timeout_seconds=60, configuration_transformer=None, session_arguments=None)[source]¶
Create a new worker (as a temporary PersistentQuery) and establish a session to it.
- Parameters:
name – the name of the persistent query. Defaults to None, which means a name based on the current time is used
heap_size_gb (float) – the heap size of the worker
server (str) – the server to connect to. Defaults to None, which means the first available server
extra_jvm_args (List[str]) – extra JVM arguments for starting the worker. Defaults to None.
extra_environment_vars (List[str]) – extra Environment variables for the worker. Defaults to None.
engine (str) – which engine (worker kind) to use for the backend worker. Defaults to None, which means “DeephavenCommunity”
auto_delete_timeout (Optional[int]) – after how many seconds should the query be automatically deleted after inactivity. Defaults to ten minutes. If none, auto-delete is disabled. If zero, the query is deleted immediately after a client connection is lost
admin_groups (List[str]) – list of groups that may administer the query. Defaults to None, which means only the current user may administer the query.
viewer_groups (List[str]) – list of groups that may view the query. Defaults to None, which means only the current user may view the query.
timeout_seconds (float) – how long to wait for the query to start. Defaults to 60 seconds.
configuration_transformer (Callable[[PersistentQueryConfigMessage], PersistentQueryConfigMessage]) – a function that can replace (or edit) the automatically generated persistent query configuration, enabling you to set more advanced options than the other function parameters provide. Defaults to None.
session_arguments (Dict[str, any]) – a dictionary of additional arguments to pass to the pydeephaven.Session created and wrapped by a DndSession
- Return type:
DndSession
- Returns:
a session connected to a new Interactive Console PQ worker
- connect_to_persistent_query(name=None, serial=None, session_arguments=None)[source]¶
Connect to an existing persistent query by name or serial number. The query must be running.
- Parameters:
name (
Optional
[str
]) – the name of the persistent query to connect toserial (
Optional
[int
]) – the serial number of the persistent query to connect tosession_arguments (
Optional
[Dict
[str
,any
]]) – a dictionary of additional arguments to pass to the pydeephaven.Session created and wrapped by a DndSession
- Return type:
DndSession
- Returns:
a session connected to the persistent query
- password(user, password, effective_user=None)[source]¶
Authenticates to the server using a username and password.
- ping()[source]¶
Send a ping to the authentication server and controller. :return: False if either ping was not sent, True if both pings were sent.
- private_key(file)[source]¶
Authenticate to the server using a Deephaven format private key file.
- Parameters:
file (Union[str | io.StringIO]) – a string file name containing the private key produced by generate-iris-keys, or alternatively an
io.StringIO instance (which may be closed after it is read)