kaskada.client

Module Contents

Classes

ClientFactory

Client

A Kaskada Client connects to the Kaskada Manager API

Functions

showtraceback(_self, *_args, **_kwargs)

Upates the IPython interactive shell to show tracebook

reset()

Resets the global variables for the client module.

set_default_slice(slice)

Sets the default slice used in every query

set_default_client(client)

Sets the default client used in every query

get_client([client, validate])

Gets and validates the current client. If no client is provided, the global client is returned.

Attributes

logger

KASKADA_DEFAULT_ENDPOINT

KASKADA_MANAGER_DEFAULT_HEALTH_CHECK_ENDPOINT

KASKADA_ENGINE_DEFAULT_HEALTH_CHECK_ENDPOINT

KASKADA_IS_SECURE

MAX_HEALTH_CHECK_ATTEMPTS

KASKADA_DEFAULT_CLIENT

KASKADA_DEFAULT_SLICE

logger[source]
KASKADA_DEFAULT_ENDPOINT = 'localhost:50051'[source]
KASKADA_MANAGER_DEFAULT_HEALTH_CHECK_ENDPOINT = 'localhost:6666'[source]
KASKADA_ENGINE_DEFAULT_HEALTH_CHECK_ENDPOINT = 'localhost:50052'[source]
KASKADA_IS_SECURE = False[source]
MAX_HEALTH_CHECK_ATTEMPTS = 10[source]
class ClientFactory(client_id, endpoint=KASKADA_DEFAULT_ENDPOINT, is_secure=True, polling_interval_seconds=1)[source]
Parameters:
  • client_id (Optional[str]) –

  • endpoint (str) –

  • is_secure (bool) –

  • polling_interval_seconds (float) –

get_client(should_connect=True, should_check_health=True)[source]

Gets a client.

Parameters:
  • should_connect (bool, optional) – True to connect. False to not connect. Defaults to True.

  • should_check_health (bool, optional) – True to check health. False to not check. Defaults to True.

class Client(client_id, endpoint, is_secure, should_check_health=True, polling_interval_seconds=1.0, should_connect=True)[source]

Bases: object

A Kaskada Client connects to the Kaskada Manager API

Parameters:
  • client_id (Optional[str]) –

  • endpoint (str) –

  • is_secure (bool) –

  • should_check_health (bool) –

  • polling_interval_seconds (float) –

  • should_connect (bool) –

health_check_watcher: Optional[kaskada.health.health_check_servicer.HealthCheckServicer][source]
connect()[source]

Attempts to connect to the manager service. The connection tries up to MAX_HEALTH_CHECK_ATTEMPTS before throwing a ConnectionError. The connection checks the health endpoint of the manager service until reporting SERVING.

Raises:

ConnectionError – if unable to connect after MAX_HEALTH_CHECK_ATTEMPTS

disconnect()[source]

Stops the client.

is_ready(always_check=False)[source]

Determines if the client is ready by querying the health servicer. If should_check_health is set to False, this method always returns True.

Parameters:

always_check (bool, optional) – True to always fetch from the health servicer. False to use the latest cached value. Defaults to False.

Returns:

True if ready for traffic. False if not ready for traffic.

Return type:

bool

get_metadata()[source]

Fetches the metadata for the current client. Renews token if necessary.

Raises:

Exception – invalid token

Returns:

Client metadata

Return type:

List[Tuple[str, str]]

validate()[source]

Validates the client by checking the service stubs

Raises:
  • ValueError – View service stub was not initialized properly.

  • ValueError – Table service stubs was not initialized properly.

  • ValueError – Query service stubs was not initialized properly.

  • ValueError – Materialization service stubs was not initialized properly.

KASKADA_DEFAULT_CLIENT: Optional[Client][source]
KASKADA_DEFAULT_SLICE[source]
showtraceback(_self, *_args, **_kwargs)[source]

Upates the IPython interactive shell to show tracebook

reset()[source]

Resets the global variables for the client module.

set_default_slice(slice)[source]

Sets the default slice used in every query

Parameters:

slice (SliceFilter) – SliceFilter to set the default

set_default_client(client)[source]

Sets the default client used in every query

Parameters:

client (Client) – the target client

get_client(client=None, validate=True)[source]

Gets and validates the current client. If no client is provided, the global client is returned.

Parameters:
  • client (Optional[Client], optional) – An optional client to verify Defaults to the global client.

  • validate (bool) –

Raises:

ValueError – No client is initialized or client is improperly initialized

Returns:

The provided client argument or the global client.

Return type:

Client