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.

Parameters:
  • name (str) – name for the table

  • table (Table) – a Table object

Raises:

DHError

Return type:

None

catalog_table()[source]#

Fetches the catalog table from the database on the server.

Returns:

a Table object

Raise:

DHError

close()[source]#

Closes the Session object if it hasn’t timed out already.

Raises:

DHError

empty_table(size)#

Creates an empty table on the server.

Parameters:

size (int) – the size of the empty table in number of rows

Return type:

Table

Returns:

a Table object

Raises:

DHError

historical_table(namespace, table_name)[source]#

Fetches a historical table from the database on the server.

Parameters:
  • namespace (str) – the namespace of the table

  • table_name (str) – the name of the table

Returns:

a Table object

Raise:

DHError

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:

Table

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:
  • schema (pa.Schema) – the schema for the InputTable

  • init_table (Table) – the initial table

  • key_cols (Union[str, Sequence[str]) – the name(s) of the key column(s)

Return type:

InputTable

Returns:

an InputTable

Raises:

DHError, ValueError

property is_alive#

Whether the session is alive.

live_table(namespace, table_name)[source]#

Fetches a live table from the database on the server.

Parameters:
  • namespace (str) – the namespace of the table

  • table_name (str) – the name of the table

Returns:

a Table object

Raise:

DHError

merge_tables(tables, order_by=None)#

Merges several tables into one table on the server.

Parameters:
  • tables (list[Table]) – the list of Table objects to merge

  • order_by (str, optional) – if specified the resultant table will be sorted on this column

Return type:

Table

Returns:

a Table object

Raises:

DHError

open_table(name)#

Opens a table in the global scope with the given name on the server.

Parameters:

name (str) – the name of the table

Return type:

Table

Returns:

a Table object

Raises:

DHError

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:

PluginClient

pqinfo()[source]#

Retrieve the persistent query information for this query.

Return type:

PersistentQueryInfoMessage

Returns:

query(table)#

Creates a Query object to define a sequence of operations on a Deephaven table.

Parameters:

table (Table) – a Table object

Return type:

Query

Returns:

a Query object

Raises:

DHError

run_script(script)#

Runs the supplied Python script on the server.

Parameters:

script (str) – the Python script code

Raises:

DHError

Return type:

None

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:

Table

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:
  • url (Optional[str]) – a URL to get the JSON connection information from

  • json (Optional[str]) – a JSON document containing connection information

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 – the heap size of the worker

  • server – the server to connect to. Defaults to None, which means the first available server

  • extra_jvm_args – extra JVM arguments for starting the worker. Defaults to None.

  • extra_environment_vars – extra Environment variables for the worker. Defaults to None.

  • engine – which engine (worker kind) to use for the backend worker. Defaults to None, which means “DeephavenCommunity”

  • auto_delete_timeout – 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 of groups that may administer the query. Defaults to None, which means only the current user may administer the query.

  • viewer_groups – list of groups that may view the query. Defaults to None, which means only the current user may view the query.

  • timeout_seconds – how long to wait for the query to start. Defaults to 60 seconds.

  • configuration_transformer – 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 – a dictionary of additional arguments to pass to the pydeephaven.Session created and wrapped by a 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 – the name of the persistent query to connect to

  • serial – the serial number of the persistent query to connect to

  • session_arguments – a dictionary of additional arguments to pass to the pydeephaven.Session created and wrapped by a 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.

Parameters:
  • user (str) – the user to authenticate

  • password (str) – the user’s password

  • effective_user (Optional[str]) – the user to operate as, defaults to the user to authenticate

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.

https://deephaven.io/enterprise/docs/resources/how-to/connect-from-java/#instructions-for-setting-up-private-keys

Parameters:

file (str) – the file containing the private key produced by generate-iris-keys