Skip to content

Example 2 Build a Sequential Pipeline

Fernando Koch edited this page Mar 30, 2026 · 3 revisions

Example 2: Build A Sequential Pipeline

Goal

Understand how GraphK turns several nodes into one ordered architecture.

Scenario

One processing step is rarely enough. You want the session to pass through several named stages in sequence.

Example

import graphk


pipeline = graphk.SequencePipe(
    nodes=[
        graphk.demo.IncrementNode("A", increment=1, target_key="total", order_key="order", response=True),
        graphk.demo.IncrementNode("B", increment=2, target_key="total", order_key="order", response=True),
        graphk.demo.IncrementNode("C", increment=3, target_key="total", order_key="order", response=True),
    ]
)

program = graphk.Program({"sequence": pipeline})
emitter = graphk.Emitter(program)
emitter.request("sequence", graphk.Session(task="sequence"))

print(emitter.response())

What Happens?

  • the program stores the sequential pipeline
  • the emitter dispatches a session to that pipeline id
  • each node runs in order
  • every node updates the same session

Why This Example Matters

This is where GraphK stops looking like a single callable and starts looking like an explicit stored execution graph.

Run The Full Example

Clone this wiki locally