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 – Pipeline created response dto.
- DescribeResponse – Brief description of all readers and writers of a pipeline.
- GroupStatus – Pipeline group status response dto.
- PipelinePackage – A package loaded by a pipeline.
- PipelineSpec – Specification of a running pipeline.
- PipelineStatus – Pipeline status response dto.
- PipelineUDF – A UDF accessed by name within a pipeline.
- PipelineWorker – A worker of a pipeline.
- RollAccepted – Unit roll accepted response.
- SPCoordinatorClient – API implementations for SP Coordinator service interaction.
- SearchPipelineResponse – Search pipeline response dto.
- TeardownPipelinesResponse – Teardown pipelines response dto.
- TermStatus – Status of one term, aggregated across the workers reporting it.
- TraceDataResponse – Captured traces of a pipeline.
- TraceStatusResponse – Summary of the captured traces of a pipeline.
- TriggerReadResponse – Trigger read response dto.
- TriggerWriteResponse – Trigger write response dto.
- Unit – A disconnected unit (connected data flow) within a pipeline.
- UnitTermsStatus – A unit's term status, aggregated across its workers.
- UploadResponse – Upload response model.
- Value – A dict that also allows attribute access, for data whose shape the client doesn't own.
CreateResponse¶
Bases: BaseModel
Pipeline created response dto.
Attributes:
- id (
Optional[str]) – Pipeline ID. - error (
Optional[str]) – Error message. - group (
Optional[str]) – Group.
DescribeResponse¶
Bases: BaseModel
Brief description of all readers and writers of a pipeline.
Attributes:
- id (
Optional[str]) – Pipeline ID. - workers (
List[Value]) – Description per worker:name,address,error,readersandwriters.
GroupStatus¶
Bases: BaseModel
Pipeline group status response dto.
Attributes:
- state (
Optional[str]) – Group state:CREATING,INITIALIZING,PARTITIONING,READY,RUNNING,STOPPED,UNRESPONSIVE,ERRORED,TEARING_DOWNorNOTEXIST. - 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:
- package_name (
Optional[str]) – Package name. - package_version (
Optional[str]) – Package version.
PipelineSpec¶
Bases: BaseModel
Specification of a running pipeline.
Attributes:
- vertices (
List[Value]) – Nodes of the pipeline:id,config,inputs,outputsandmetadata. - edges (
List[Value]) – Edges between the nodes:source,destination,edge,metadataandvalid.
PipelineStatus¶
Bases: BaseModel
Pipeline status response dto.
Attributes:
- state (
Optional[str]) – Pipeline state:CREATING,INITIALIZING,PARTITIONING,READY,RUNNING,UNRESPONSIVE,ERRORED,TEARING_DOWN,FINISHEDorNOTEXIST. - error (
Optional[str]) – Error message.
PipelineUDF¶
Bases: BaseModel
A UDF accessed by name within a pipeline.
Attributes:
- package_name (
Optional[str]) – Package name. - package_version (
Optional[str]) – Package version. - udf_name (
Optional[str]) – UDF name.
PipelineWorker¶
Bases: BaseModel
A worker of a pipeline.
Attributes:
- id (
Optional[int]) – Worker ID. - name (
Optional[str]) – Worker name. - group (
Optional[str]) – Group. - address (
Optional[str]) – Worker address. - partitions (
Optional[List[Any]]) – Partitions assigned to the worker. - startTime (
Optional[str]) – Worker start time.
RollAccepted¶
Bases: BaseModel
Unit roll accepted response.
Attributes:
- unitId (
str) – Unit ID. - fromTermId (
int) – Term the unit rolled from. - toTermId (
int) – New current term. - state (
str) –accepted, orfinishedif every operator drained synchronously. - message (
str) – Human readable outcome. - finishingTermStatusUrl (
str) – URL to track the finishing term. - currentTermStatusUrl (
str) – URL to track the new current term. - unitTermsStatusUrl (
str) – URL listing all active terms for the unit.
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:
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¶
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:
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:
unit_terms¶
unit_terms(pipeline_id, unit_id)
Get a unit's active terms, aggregated across every worker running it.
Parameters:
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:
- id (
Optional[str]) – Pipeline ID. - name (
Optional[str]) – Pipeline name. - group (
Optional[str]) – Group. - mode (
Optional[str]) – Mode. - created (
Optional[str]) – Created date. - state (
Optional[str]) – State. - error (
Optional[str]) – Error message.
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:
- unitId (
str) – Unit ID. - termId (
int) – Term ID. - state (
str) – Term state. - canRoll (
bool) – Whether rolling from this term would make progress. - startedAt (
Optional[str]) – Time the term was opened. - endedAt (
Optional[str]) – Time the term ended,Noneuntil every worker has ended it. - workers (
List[Value]) – Per-worker view of the term, each withworker,role,stateand per-node progress undernodes.
TraceDataResponse¶
Bases: BaseModel
Captured traces of a pipeline.
Attributes:
- id (
Optional[str]) – Pipeline ID. - workers (
List[Value]) – Captured traces per worker:name,status,error,traceandstackTrace.
TraceStatusResponse¶
Bases: BaseModel
Summary of the captured traces of a pipeline.
Attributes:
- id (
Optional[str]) – Pipeline ID. - workers (
List[Value]) – Trace status per worker:name,statusanderror.
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:
- id (
Optional[str]) – Unit ID. - nodes (
List[str]) – IDs of the nodes in the unit. - termsUrl (
Optional[str]) – URL of the unit's terms.
UnitTermsStatus¶
Bases: BaseModel
A unit's term status, aggregated across its workers.
Attributes:
- unitId (
str) – Unit ID. - state (
str) – Unit state:notStarted,finished,finishing,runningorerrored. - canRoll (
bool) – Whether the unit's current term can roll. - currentTermId (
Optional[int]) – Current term ID. - previousTermId (
Optional[int]) – Previous term ID,Noneif the unit has never rolled. - workers (
List[Value]) – One entry per worker reporting the unit, each withworker,state,canRoll,currentTermId,previousTermIdandterms.
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
Valueand lists of them.
wrap¶
wrap(obj)
Recursively wrap dicts as Value and lists of them.