Skip to content

Sp Coordinator

SP Coordinator API client.

Use SPCoordinatorClient to create, inspect and drive Stream Processor pipelines on a kdb Insights Enterprise instance, including the lifecycle of a pipeline's units.

Example

List a pipeline's units, roll one, and wait for its previous term to drain:

import time

from kxi.sp_coordinator import SPCoordinatorClient

client = SPCoordinatorClient(host="https://<host>")

unit = client.units("my-pipeline")[0]
terms = client.unit_terms("my-pipeline", unit.id)
if terms.canRoll:
    rolled = client.roll_unit("my-pipeline", unit.id, from_term_id=terms.currentTermId)
    while client.unit_term("my-pipeline", unit.id, rolled.fromTermId).state != "finished":
        time.sleep(1)

# Force a read on the pipeline's readers
client.trigger_read("my-pipeline")

Classes:

CreateResponse

Bases: BaseModel

Pipeline created response dto.

Attributes:

DescribeResponse

Bases: BaseModel

Brief description of all readers and writers of a pipeline.

Attributes:

GroupStatus

Bases: BaseModel

Pipeline group status response dto.

Attributes:

  • state (Optional[str]) – Group state: CREATING, INITIALIZING, PARTITIONING, READY, RUNNING, STOPPED, UNRESPONSIVE, ERRORED, TEARING_DOWN or NOTEXIST.
  • error (Optional[str]) – Error message.
  • replicas (Optional[Any]) – Controller replicas table (column name to values), containing id, state and any error messages.

PipelinePackage

Bases: BaseModel

A package loaded by a pipeline.

Attributes:

PipelineSpec

Bases: BaseModel

Specification of a running pipeline.

Attributes:

  • vertices (List[Value]) – Nodes of the pipeline: id, config, inputs, outputs and metadata.
  • edges (List[Value]) – Edges between the nodes: source, destination, edge, metadata and valid.

PipelineStatus

Bases: BaseModel

Pipeline status response dto.

Attributes:

  • state (Optional[str]) – Pipeline state: CREATING, INITIALIZING, PARTITIONING, READY, RUNNING, UNRESPONSIVE, ERRORED, TEARING_DOWN, FINISHED or NOTEXIST.
  • error (Optional[str]) – Error message.

PipelineUDF

Bases: BaseModel

A UDF accessed by name within a pipeline.

Attributes:

PipelineWorker

Bases: BaseModel

A worker of a pipeline.

Attributes:

RollAccepted

Bases: BaseModel

Unit roll accepted response.

Attributes:

SPCoordinatorClient

Bases: ApiClient

API implementations for SP Coordinator service interaction.

Functions:

  • create – Create pipeline.
  • describe – Get a brief description of all readers and writers of a pipeline.
  • graph – Get the Graphviz (dot) source describing a pipeline.
  • group_status – Get the status of a pipeline group.
  • group_workers – List the workers in a pipeline group.
  • list – List all the pipelines.
  • packages – List the packages loaded by a running pipeline.
  • roll_unit – Roll a unit from its current term on every worker running it.
  • search – Search many pipelines by name.
  • spec – Get the specification of a running pipeline.
  • status – Get the status of a pipeline.
  • teardown – Teardown pipelines.
  • teardown_all – Teardown all pipelines, including all controllers and their workers.
  • teardown_group – Teardown all the pipelines (replicas) sharing a group ID.
  • trace_data – Get all captured traces of a pipeline.
  • trace_status – Get a summary of the state of the captured traces of a pipeline.
  • trigger_read – Trigger a read on the readers of a pipeline.
  • trigger_write – Trigger a write on the writers of a pipeline.
  • udfs – List the UDFs accessed by name within a running pipeline.
  • unit_term – Get the status of one term of a unit.
  • unit_terms – Get a unit's active terms, aggregated across every worker running it.
  • units – List the units (disconnected data flows) in a pipeline.
  • upload – Upload to worker with fromUpload node.
  • workers – List the workers of a pipeline.

create

create(create_request)

Create pipeline.

Parameters:

  • create_request (Dict[str, Any]) – Create request.

describe

describe(pipeline_id)

Get a brief description of all readers and writers of a pipeline.

Parameters:

  • pipeline_id (str) – Pipeline ID.

graph

graph(pipeline_id)

Get the Graphviz (dot) source describing a pipeline.

The service sends the text as a JSON-encoded string, which the client decodes.

Parameters:

  • pipeline_id (str) – Pipeline ID.

group_status

group_status(group)

Get the status of a pipeline group.

Parameters:

  • group (str) – Group ID.

group_workers

group_workers(group)

List the workers in a pipeline group.

Parameters:

  • group (str) – Group ID.

list

list()

List all the pipelines.

packages

packages(pipeline_id)

List the packages loaded by a running pipeline.

Parameters:

  • pipeline_id (str) – Pipeline ID.

roll_unit

roll_unit(pipeline_id, unit_id, from_term_id, force=False)

Roll a unit from its current term on every worker running it.

A successful response means the roll was sent, not that it has landed; poll unit_terms to see where it landed. Repeating a roll from the same term is a no-op on workers that already rolled.

Parameters:

  • pipeline_id (str) – Pipeline ID.
  • unit_id (str) – Unit ID.
  • from_term_id (int) – The unit's current term ID.
  • force (bool) – Roll even if the unit's previous term is still finishing, abandoning it and discarding its operators' outstanding work. Defaults to False.
search(names)

Search many pipelines by name.

spec

spec(pipeline_id)

Get the specification of a running pipeline.

Parameters:

  • pipeline_id (str) – Pipeline ID.

status

status(pipeline_id)

Get the status of a pipeline.

Parameters:

  • pipeline_id (str) – Pipeline ID.

teardown

teardown(ids, clear_checkpoints=None)

Teardown pipelines.

Parameters:

  • ids (List[str]) – Pipeline IDs.
  • clear_checkpoints (Optional[bool]) – Clear the pipelines' checkpoints. Defaults to None.

teardown_all

teardown_all(clear_checkpoints=None)

Teardown all pipelines, including all controllers and their workers.

This affects every pipeline on the deployment, not only your own.

Parameters:

  • clear_checkpoints (Optional[bool]) – Clear the pipelines' checkpoints. Defaults to None.

teardown_group

teardown_group(group, clear_checkpoints=None)

Teardown all the pipelines (replicas) sharing a group ID.

Parameters:

  • group (str) – Group ID.
  • clear_checkpoints (Optional[bool]) – Clear the pipelines' checkpoints. Defaults to None.

trace_data

trace_data(pipeline_id, structured_text=False)

Get all captured traces of a pipeline.

Parameters:

  • pipeline_id (str) – Pipeline ID.
  • structured_text (bool) – Return the traces in structuredText format. Defaults to False.

trace_status

trace_status(pipeline_id)

Get a summary of the state of the captured traces of a pipeline.

Parameters:

  • pipeline_id (str) – Pipeline ID.

trigger_read

trigger_read(pipeline_id, op_ids=None, op_args=None)

Trigger a read on the readers of a pipeline.

Parameters:

  • pipeline_id (str) – Pipeline ID.
  • op_ids (Optional[List[str]]) – IDs of specific reader operators to trigger. Defaults to every reader configured for triggering.
  • op_args (Optional[Dict[str, Dict[str, Any]]]) – Arguments for the triggered readers, keyed by operator ID, e.g. {"reader1": {"query": "select ..."}}. Defaults to None.

trigger_write

trigger_write(pipeline_id, op_ids=None)

Trigger a write on the writers of a pipeline.

Parameters:

  • pipeline_id (str) – Pipeline ID.
  • op_ids (Optional[List[str]]) – IDs of specific writer operators to trigger. Defaults to every writer configured for triggering.

udfs

udfs(pipeline_id)

List the UDFs accessed by name within a running pipeline.

Parameters:

  • pipeline_id (str) – Pipeline ID.

unit_term

unit_term(pipeline_id, unit_id, term_id)

Get the status of one term of a unit.

Poll this to wait for a rolled term to drain: state is finished only once every worker reporting the term has finished it.

Parameters:

  • pipeline_id (str) – Pipeline ID.
  • unit_id (str) – Unit ID.
  • term_id (int) – Term ID.

unit_terms

unit_terms(pipeline_id, unit_id)

Get a unit's active terms, aggregated across every worker running it.

Parameters:

  • pipeline_id (str) – Pipeline ID.
  • unit_id (str) – Unit ID.

units

units(pipeline_id)

List the units (disconnected data flows) in a pipeline.

Parameters:

  • pipeline_id (str) – Pipeline ID.

upload

upload(name, data, finish=False, table=None)

Upload to worker with fromUpload node.

Parameters:

  • name (str) – Name of upload.
  • data (Dict | bytes | str) – Data payload. It can be a python dictionary.
  • finish (bool) – Finish the operator. Defaults to False.
  • table (Optional[str]) – Table name, passed to operator as metadata. Defaults to None.

workers

workers(pipeline_id)

List the workers of a pipeline.

Parameters:

  • pipeline_id (str) – Pipeline ID.

SearchPipelineResponse

Bases: BaseModel

Search pipeline response dto.

Attributes:

TeardownPipelinesResponse

Bases: BaseModel

Teardown pipelines response dto.

Attributes:

TermStatus

Bases: BaseModel

Status of one term, aggregated across the workers reporting it.

state is finished only once every reporting worker has finished the term.

Attributes:

TraceDataResponse

Bases: BaseModel

Captured traces of a pipeline.

Attributes:

TraceStatusResponse

Bases: BaseModel

Summary of the captured traces of a pipeline.

Attributes:

TriggerReadResponse

Bases: BaseModel

Trigger read response dto.

Attributes:

TriggerWriteResponse

Bases: BaseModel

Trigger write response dto.

Attributes:

Unit

Bases: BaseModel

A disconnected unit (connected data flow) within a pipeline.

Attributes:

UnitTermsStatus

Bases: BaseModel

A unit's term status, aggregated across its workers.

Attributes:

UploadResponse

Bases: BaseModel

Upload response model.

Attributes:

Value

Bases: dict

A dict that also allows attribute access, for data whose shape the client doesn't own.

Nested dicts and lists are wrapped too, so resp.workers[0].terms[0].nodes.A.state works. Unknown keys are kept, and a missing key raises AttributeError as an attribute and KeyError as an item. Keys that aren't identifiers, or that clash with a dict method (e.g. values, items), are reached with item access: value["values"].

Functions:

  • wrap – Recursively wrap dicts as Value and lists of them.

wrap

wrap(obj)

Recursively wrap dicts as Value and lists of them.

Back to top