Pipeline builder
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
| Method | Role | Notes |
|---|---|---|
from_iter(iterable) | Source | Any iterable of dicts, lists of dicts, or Arrow PyCapsule objects. In-memory; re-__iter__s the container on re-execution. |
from_kafka(**kwargs) | Source | Same keys as the Kafka input config (requires the feature). |
from_http(**kwargs) | Source | HTTP polling; same keys as the HTTP input config. |
sql(query) | Processor | DataFusion dialect; the batch is visible as table flow. |
map_batches(callable) | Processor | Vectorized Python UDF; receives a batch, returns a batch / None (drop) / dicts / PyCapsule. |
embedding(**kwargs) | Processor | AI-vector family; same keys as the embedding processor. |
llm(**kwargs) | Processor | AI-vector family; same keys as the LLM processor. |
to_kafka(**kwargs) | Sink | Same keys as the Kafka output config. |
to_qdrant(**kwargs) | Sink | AI-vector family; same keys as the Qdrant output. |
to_stdout() | Sink | JSON-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.