Skip to main content
Version: Next

Pipeline builder

Experimental — breaking changes may land in any release

Pin your version and read the changelog before upgrading.

arkflow.Pipeline is a chainable builder: pick one source, add processors in order, pick one sink. The result compiles to the same config the binary consumes; keyword arguments are passed through to the component builder, so validation errors name the exact key.

Builder methods​

MethodRoleNotes
from_iter(iterable)SourceAny iterable of dicts, lists of dicts, or Arrow PyCapsule objects. In-memory; re-__iter__s the container on re-execution.
from_kafka(**kwargs)SourceSame keys as the Kafka input config (requires the feature).
from_http(**kwargs)SourceHTTP polling; same keys as the HTTP input config.
sql(query)ProcessorDataFusion dialect; the batch is visible as table flow.
map_batches(callable)ProcessorVectorized Python UDF; receives a batch, returns a batch / None (drop) / dicts / PyCapsule.
embedding(**kwargs)ProcessorAI-vector family; same keys as the embedding processor.
llm(**kwargs)ProcessorAI-vector family; same keys as the LLM processor.
to_kafka(**kwargs)SinkSame keys as the Kafka output config.
to_qdrant(**kwargs)SinkAI-vector family; same keys as the Qdrant output.
to_stdout()SinkJSON-encodes batches; works for any schema.

Each method returns a new Pipeline handle sharing the same draft, so chaining is immutable in practice — keep the returned value:

flow = (
arkflow.Pipeline(state_path="./state.db")
.from_kafka(brokers=["b:9092"], topics=["events"], group_id="g")
.sql("SELECT user, SUM(amount) AS total FROM flow GROUP BY user")
.to_stdout()
)

Order and validation​

  • One source and one sink per pipeline; adding a second source or sink replaces the first with the last call.
  • A pipeline without a source or without a sink fails fast at execution (ConfigError) — the builder does not force the order of method calls.
  • Connector keyword arguments follow the component's YAML schema, flattened at the top level (no nested config: mapping).

Composing SQL and UDFs​

Processors compose in declaration order; each sees the previous one's output:

def enrich(batch):
# batch is an Arrow PyCapsule object; return it (or a modified one).
return batch

flow = (
arkflow.Pipeline()
.from_iter(ROWS)
.sql("SELECT v, tag FROM flow WHERE v >= 5")
.map_batches(enrich)
.to_stdout()
)
batches = flow.take(1)

A UDF returning None drops the batch from the output.

Re-execution​

A Pipeline object can run more than once: from_iter re-iterates its container and the engine is rebuilt per execution. Connector-backed pipelines resume from persisted state (see state).

Inspecting the draft​

repr(flow) shows the current source type, processor count, sink type, and state_path without executing anything.