# OpenFlange developer documentation, full text The quickstart, the concepts, the CLI reference, the standard-pipe table and the ETL guide of openflange.dev as one Markdown text. Each part starts with the URL of the page it comes from. A shorter guide written for agents is at https://openflange.dev/agents.md; the index is https://openflange.dev/llms.txt; the normative specifications are at https://openflange.org/llms.txt. --- Source: https://openflange.dev/quickstart/ # Quickstart Install the CLI, turn one line of logic into a reusable step, check it, run it, and connect it to a second step. About five minutes once Go is installed. ## Install the CLI You need Go 1.27 or newer, a terminal and a text editor. One command builds the `openflange` binary of release v0.0.1 and puts it in your Go bin directory: ```bash go install github.com/openflange/openflange-go/cmd/openflange@v0.0.1 ``` > **v0.0.1 is experimental** > > [v0.0.1](https://github.com/openflange/openflange-go/releases/tag/v0.0.1) is the first release and is experimental: the format may still change before 1.0 ([changelog](https://github.com/openflange/openflange-go/blob/main/CHANGELOG.md)). Prebuilt binaries and a Homebrew formula are planned. For the latest development version, use `@main` instead of `@v0.0.1`. Check that it is on your `PATH`. The second line is what it printed on the Linux machine where this guide was checked; yours shows your own Go version and platform. ```bash openflange version # openflange 0.0.1 (go1.27.1 linux/amd64) ``` You can also clone the [repository](https://github.com/openflange/openflange-go) and build it there. You will want the clone anyway: step 4 copies a pipe from it, and every example runs from it. ```bash # or, from a clone (git checkout v0.0.1 for the release): git clone https://github.com/openflange/openflange-go cd openflange-go go build -o openflange ./cmd/openflange && export PATH="$PWD:$PATH" ``` The steps in this guide run inside the runner itself (Starlark), so there is no other language to install. ## 1. Write a pipe A pipe is a directory with one file in it: `OPENFLANGE.md`. The header is the contract; the rest is your documentation. `pipes/lowercase/OPENFLANGE.md`: ```markdown --- spec: openflange.org/pipe/v0.1 id: lowercase version: 0.1.0 inputs: text: {schema: {format: json-schema, definition: {type: string}}} outputs: text: {schema: {format: json-schema, definition: {type: string}}} implementation: type: expression language: starlark expression: text.lower() --- # Lowercase Implements the [OpenFlange](https://openflange.org/) specification. ``` Read it top to bottom: it takes one input called `text`, gives one output called `text`, both strings, and the work is the expression `text.lower()`. The link to openflange.org is required, and it must be a visible link. Create the directory `pipes/lowercase` and save the file there. In a hurry? `openflange init ./my-pipe` scaffolds a working pipe of the same shape, with a test. ## 2. Validate it Check the contract before running anything. Mistakes are reported with a code and a location. ```bash openflange validate ./pipes/lowercase ``` It answers: ```text valid: ./pipes/lowercase (1 node, 2 edges) ``` ## 3. Run it One input and one output means stdin and stdout. Each line is one JSON value, so a string keeps its quotes. Input (stdin): ```text "Alice@Example.COM" ``` Command: ```text printf '%s\n' '"Alice@Example.COM"' \ | openflange run ./pipes/lowercase ``` Output (stdout): ```text "alice@example.com" ``` ## 4. Connect two pipes Add a second pipe, `mask-email`, that hides the middle of the address. It is a short Starlark script with its own manifest, so copy it from your clone of the repository instead of typing it: ```bash cp -r openflange-go/examples/email/pipes/mask-email pipes/ ``` Then write the file that connects them. Each input says which output it reads from. `pipeline.yaml`: ```yaml spec: openflange.org/pipeline/v0.1 nodes: lowercase: pipe: ./pipes/lowercase inputs: text: {from: inputs.email} mask: pipe: ./pipes/mask-email inputs: email: {from: lowercase.outputs.text} parameters: character: "*" outputs: email: {from: mask.outputs.email} ``` Validate the whole graph and print the plan the runner will execute: ```bash openflange validate ./pipeline.yaml --plan ``` ```text PLAN ./pipeline.yaml INPUTS email records NODES (execution order) 1. lowercase ./pipes/lowercase [starlark, local-go] pipe lowercase@0.1.0 in text <- inputs.email out text -> mask.inputs.email 2. mask ./pipes/mask-email [starlark, local-go] pipe mask-email@0.1.0 params character="*" preserveFirst=1 preserveLast=1 in email <- lowercase.outputs.text out email -> outputs.email out rejected -> (not connected) OUTPUTS email values <- mask.outputs.email EDGES inputs.email -> lowercase.inputs.text application/x-ndjson lowercase.outputs.text -> mask.inputs.email application/x-ndjson mask.outputs.email -> outputs.email application/x-ndjson CONVERSIONS (none) valid: ./pipeline.yaml (2 nodes, 3 edges) ``` Then run it: Input (stdin): ```text "Alice@Example.COM" ``` Command: ```text printf '%s\n' '"Alice@Example.COM"' \ | openflange run ./pipeline.yaml ``` Output (stdout): ```text "a***e@example.com" ``` The rules of `mask-email` for short and invalid addresses are in the [email-masking example](https://openflange.dev/examples/email-masking/). ## 5. Test it A test is a small YAML file beside the manifest: inputs in, expected outputs out. It travels with the pipe, so anyone who reuses it can re-run it. `pipes/lowercase/tests/lowercase.test.yaml`: ```yaml spec: openflange.org/test/v0.1 tests: - name: lowercases mixed case inputs: text: {values: ["Alice@Example.COM"]} expect: outputs: text: values: ["alice@example.com"] ``` ```bash openflange test ./pipes/lowercase ``` The timing differs from run to run: ```text pipes/lowercase/tests/lowercase.test.yaml ok lowercases mixed case ok 1 test passed in 1 file (8ms) ``` ## 6. Lock it Record exactly what each reference resolved to, commit that file, and run against it. A locked run refuses anything that has changed since (`E_LOCK`, exit status 2). ```bash openflange resolve # ok: 2 references locked in openflange.lock.yaml (2 added, 0 changed) printf '%s\n' '"Alice@Example.COM"' | openflange run ./pipeline.yaml --locked # "a***e@example.com" ``` ## Prefer a visual designer? [DataTug](https://datatug.io/) is the tool to build pipelines visually and to execute them using different databases as sources: design the pipeline on a canvas, feed it from a query against SQL Server, PostgreSQL, SQLite, DuckDB or another database, preview each step’s output, and materialise the result into a DuckDB dataset. It reads and writes the same `OPENFLANGE.md` and `pipeline.yaml` files as this guide. In development OpenFlange does not need DataTug. It is the first visual implementation, and any tool can implement the standard. Illustration, not a product screenshot: the same two pipes on a canvas, fed by a SQL query and materialised into a DuckDB dataset. --- Source: https://openflange.dev/concepts/manifest/ # Manifest — one Markdown file that is both the docs and the contract Nobody can tell what a step expects or produces until it breaks. ## The problem A script's real interface lives in its author's head: which file it reads, which columns it needs, which flags matter. Documentation drifts away from the code because nothing checks it. ## The fix Put one file named `OPENFLANGE.md` next to the code. The YAML header at the top is the contract a runner reads. Everything below it is ordinary Markdown for people. They cannot drift far apart, because they are the same file. ```markdown --- spec: openflange.org/pipe/v0.1 id: lowercase version: 0.1.0 inputs: text: {schema: {format: json-schema, definition: {type: string}}} outputs: text: {schema: {format: json-schema, definition: {type: string}}} implementation: type: expression language: starlark expression: text.lower() --- # Lowercase Implements the [OpenFlange](https://openflange.org/) specification. ``` ## The precise terms - The header is the **frontmatter**; it is the authoritative, machine-readable **pipe contract**. - `spec`, `id`, `version` and `implementation` are required. `inputs`, `outputs`, `parameters` and `permissions` describe the rest. - The body must contain a visible link to `https://openflange.org/`. A validator checks this, so anyone who finds the file can find the standard. - A directory with an `OPENFLANGE.md` at its root is a **package**. [Normative text: Pipe specification](https://openflange.org/pipe/v0.1/) --- Source: https://openflange.dev/concepts/ports/ # Ports — so a step says what it takes and gives Wiring two outputs and a reject stream needs a framework. Unix pipes stop at one stdin and one stdout. ## The problem A Unix pipe has exactly one way in and one way out. The moment a step needs a second input (a lookup table) or a second output (the records it rejected), you are writing temporary files and conventions. ## The fix A step names each way in and each way out. Those names are its **ports**. ```yaml inputs: email: {schema: {format: json-schema, definition: {type: string}}} outputs: email: {schema: {format: json-schema, definition: {type: string}}} rejected: {required: false} ``` Now “the rejected output of the mask step” is something a pipeline can point at: `mask.outputs.rejected`. ## The precise terms - A port has a **kind**: `records` (the default), `values`, `batches`, `windows`, `text` or `binary`. - A port may have a **schema** (JSON Schema by default, Arrow for typed batches) describing one item. A port without a schema is untyped. - Ports are **required** by default. An optional output that nothing reads is simply switched off, and the step is told so before it starts. - A step with no inputs is a **source**; with no outputs, a **sink**; otherwise a **pipe**. [Normative text: Pipe specification](https://openflange.org/pipe/v0.1/) --- Source: https://openflange.dev/concepts/streams/ # Streams — records flow through; nothing piles up A fast step floods a slow one, memory grows, and somewhere records quietly go missing. ## The problem Hand-wired steps either load everything into memory or pass data through unbounded queues. Both work on the sample file and fall over on the real one. ## The fix What travels between two ports is a **stream**: an ordered sequence of items. By default it is one JSON value per line. ```json {"value":10} {"value":20} {"value":30} ``` The buffer between two steps is bounded. When it is full the producer waits. Nothing is dropped, and memory stays flat however large the input is. ## The precise terms - The default encoding is **NDJSON** (`application/x-ndjson`): UTF-8, one JSON value per line, a final newline, no blank lines. A string value is a JSON string line: `"a@b.c"`. - Numbers pass through unchanged, digit for digit, so large integers and decimals survive. - A waiting producer is **backpressure**. With two consumers of one output (a **broadcast**), the slowest sets the pace. - Order is preserved per stream. Only conversions that lose nothing are inserted automatically, and they are listed in the execution plan. - When a step fails, the run fails fast and says so. Output already written is not rolled back; the final status reports `partialOutput: true`. - A **window** is a meaningful group of records with a boundary. A **batch** is only a transport unit. They are never confused. - Batch mode — a declared `batch: {maxItems, maxWaitMs}` — lets the runner hand a subprocess or Starlark pipe several records at a time. It is experimental and in v0.0.1: see [Batch mode](https://openflange.dev/concepts/batch/). [Normative text: Pipeline specification](https://openflange.org/pipeline/v0.1/) --- Source: https://openflange.dev/concepts/pipelines/ # Pipelines — say what feeds what, and nothing else Your R script, SQL query and Python service cannot be plugged together without glue code. ## The problem Connecting steps by hand means a shell script full of temporary files, format conversions and assumptions. It is checked by running it. ## The fix A **pipeline** is a short YAML file. Each step lists its inputs, and each input names the output it reads from. ```yaml spec: openflange.org/pipeline/v0.1 nodes: lowercase: pipe: ./pipes/lowercase inputs: text: {from: inputs.email} mask: pipe: ./pipes/mask-email inputs: email: {from: lowercase.outputs.text} parameters: character: "*" outputs: email: {from: mask.outputs.email} ``` That is the whole format. There is no separate list of connections to keep in sync. ## The precise terms - Each entry under `nodes` is a **node**: one use of a pipe, with its own id. - A source is written `inputs.` (a pipeline input) or `.outputs.` (another node's output). Mappings are always written on the **consumer** side. - Two consumers of one output is a **broadcast**: the producer runs once. Two producers into one input needs an explicit `std:merge` node. - The graph must have no cycles. A pipeline can itself be the implementation of a pipe, so pipelines nest (a **composite**). - Before running, the file is compiled into an **execution plan**. Unknown ports, cycles, unconnected required ports and incompatible schemas are reported with a code and a location: `openflange validate ./pipeline.yaml --plan`. - Canvas coordinates live in a separate `pipeline.layout.yaml` that runners ignore. [Normative text: Pipeline specification](https://openflange.org/pipeline/v0.1/) --- Source: https://openflange.dev/concepts/permissions/ # Permissions — a step gets only what you grant You cannot safely run someone else’s step: it just gets your credentials. ## The problem A downloaded script starts with your whole environment: every token, your network, your home directory. You learn what it used afterwards, if at all. ## The fix A step **declares** what it needs. You **grant** it, per step, in the pipeline. A runner that cannot enforce a grant refuses to run the step. ```yaml nodes: enrich: pipe: ./pipes/enrich inputs: records: {from: inputs.records} grants: network: ["api.example.com:443"] remoteData: ["api.example.com"] ``` ## The precise terms - Permission kinds: `network`, `filesystem`, `subprocess`, `environment`, `secrets` and `remoteData` (record data leaves the machine). - Steps that run inside the runner (built-ins, Starlark) need no grants. An `executable` needs `subprocess`; an `http` pipe needs `network` and `remoteData` for its host. - A subprocess gets a minimal environment plus what was granted, never your ambient secrets. Secrets are references delivered out of band, never parameters. - A nested pipeline cannot give its children more than it was given. - `--trusted` grants everything a pipe declares, and says plainly that this is **not** a sandbox. A subprocess alone does not isolate untrusted code. [Normative text: Pipe specification](https://openflange.org/pipe/v0.1/) --- Source: https://openflange.dev/concepts/lockfiles/ # Lockfile — the same run tomorrow Reusing a colleague’s step means copy-pasting code and hoping. ## The problem “Use the masking step from the other repo” becomes a copied folder that silently diverges, or a reference to a branch that changes under you. ## The fix Reference the step where it lives. Then lock it: one command records exactly what each reference resolved to. ```yaml spec: openflange.org/lock/v0.1 dependencies: "./pipes/lowercase": resolved: ./pipes/lowercase version: 0.1.0 integrity: sha256- ``` A locked run compares before it starts, and refuses if anything is different. ## The precise terms - References can be a path, `std:`, `npm:`, `git:`, an `https://` URL of a remote pipe, or `/` resolved through a registry index. - `openflange resolve` writes `openflange.lock.yaml`. Each entry records the resolved location, the contract **version**, a **revision** (commit, package checksum, or what a server reports) and an **integrity** hash. - `openflange run --locked` fails with `E_LOCK` when a reference is missing from the lockfile or its integrity differs. `openflange update` re-resolves deliberately. - Commit the lockfile. Installing `pypi:`, `cran:` and `oci:` references is recognised but not supported by v0.1 runners. [Normative text: Lockfile specification](https://openflange.org/lock/v0.1/) --- Source: https://openflange.dev/concepts/batch/ # Batch mode — let the runner hand your script a batch Calling an API once per record is slow and expensive, and so is any script that pays a round trip for every line. ## The problem A step that runs in another process pays for every record: a line to parse, a line to print, a round trip through two operating-system pipes. Three kinds of step feel it most. A request to a language model, an embedding service or a database costs per *call*, whatever the call carries. R and NumPy-style Python are fast on vectors and slow on scalars. And tools such as DuckDB want a file, not a stream of lines. The usual answer is to buffer inside the program, with a home-made flush timer. Then every script reinvents it, and the runner — the program that runs pipes, and the place where waiting and memory are decided — knows nothing about it. ## The fix The pipe says in its manifest that it wants its input in batches. The runner collects records and hands the script up to `maxItems` at a time, and never holds a record back for longer than `maxWaitMs` milliseconds. This is the manifest of the R example in the repository, with the port declarations left out: ```yaml cardinality: one-to-one deterministic: true batch: maxItems: 1000 maxWaitMs: 200 # … inputs and outputs: one port each … implementation: type: script language: r path: tidy.R permissions: subprocess: true ``` `maxItems` is required. `maxWaitMs` is optional and defaults to 0: the runner never waits for a batch to fill. While the script works on one batch the runner keeps collecting the next, so a busy script gets fuller batches by itself. The script reads **one JSON array per line** and answers each line with one JSON array. The answer line is also how the runner knows the batch is done, so the script flushes it. This is the loop of the same example, `tidy.R`; `tidy` is a vectorised function defined above it in the file: ```r con <- file("stdin", open = "r") while (length(line <- readLines(con, n = 1, warn = FALSE)) > 0) { df <- fromJSON(line) # a batch: array of records -> data frame cat(toJSON(tidy(df), digits = NA), "\n", sep = "") # one answer line per batch flush(stdout()) } ``` Some tools want a file. With `delivery: file` each batch is a plain NDJSON file, one record per line. If the command contains `{batch.input}`, the runner starts it once per batch and puts the path of the file there; `{batch.output}` is where the tool writes its result. This DuckDB pipe has no script at all (`{{` is a literal `{`): ```yaml batch: maxItems: 50000 maxWaitMs: 1000 delivery: file # … inputs and outputs … implementation: type: executable command: - duckdb - -no-init - -bail - -c - >- copy ( select id, qty, unitCents, taxRate, qty * unitCents as netCents, cast(round(qty * unitCents * taxRate) as bigint) as taxCents, qty * unitCents + cast(round(qty * unitCents * taxRate) as bigint) as grossCents from read_json('{batch.input}', format = 'newline_delimited', columns = {{id: 'BIGINT', qty: 'BIGINT', unitCents: 'BIGINT', taxRate: 'DOUBLE'}) ) to '{batch.output}' (format json) ``` Without `{batch.output}` the output of the batch is read from standard output. A command without placeholders is started once and is told the paths on standard input, one line per batch. ## The precise terms - Batch mode is declared with `batch: {maxItems, maxWaitMs, delivery}`. `maxItems` is required. `maxWaitMs` (default 0) and `delivery` (`lines`, the default, or `file`) are optional. - It is for pipes whose code lives outside the runner or in a script: **executable** pipes and **script** pipes (Starlark, R, Python, Node). A Starlark script defines `process_batch(items, params)` and always receives a list in memory; `delivery: file` is for executables and for R, Python and Node scripts. Built-in, expression, composite and HTTP pipes cannot declare batch mode. - The pipe must have exactly one input port, of kind `records`, `values` or `windows`. - A batch is delivered when it holds `maxItems` items, when `maxWaitMs` has passed since its first item arrived, or when the input ends. There is no minimum size, and one batch is in flight at a time. - **Batch boundaries carry no meaning.** A conformant pipe gives the same output, in the same order, however its input is cut. A sum or a rank *across* a batch is a bug. Grouping that means something is a window (`std:window`); a statistic over the whole input is `scope: dataset`. - Memory stays bounded: a node holds at most twice `maxItems` items. A pipeline node or a test may only **tighten** the settings, never loosen them. - Batch mode grants nothing. A pipe that sends batches to a remote service still declares `network` and `remoteData`. The examples in the repository call no network service; for an API the script has the same shape — one request per array instead of one per record. - Batch mode is **experimental** and in release v0.0.1 of the reference runner. It was accepted in [RFC 0003](https://openflange.org/rfcs/0003-batch-mode/); the wire format is in the CLI specification, sections [5.1](https://openflange.org/cli/v0.1/#51-batch-framing) and [5.2](https://openflange.org/cli/v0.1/#52-batch-files). - Runnable examples: [Python](https://openflange.dev/examples/batch-python/), [R](https://openflange.dev/examples/batch-r/), [Starlark](https://openflange.dev/examples/batch-starlark/) and [DuckDB with batch files](https://openflange.dev/examples/batch-file-duckdb/). [Normative text: Pipe specification, section 5.7 (batch mode)](https://openflange.org/pipe/v0.1/#57-batch-mode) --- Source: https://openflange.dev/cli/ # CLI reference One binary, openflange, that validates, runs, serves and tests pipes and pipelines on your machine. No server, no account. > **Release v0.0.1, experimental** > > Install with `go install github.com/openflange/openflange-go/cmd/openflange@v0.0.1` (requires Go); binaries and a Homebrew formula are planned. `openflange help ` is the reference for every flag, and [docs/cli.md](https://github.com/openflange/openflange-go/blob/main/docs/cli.md) in the repository documents what scripts may rely on. ## Commands | Command | What it does | |---|---| | `openflange search ` | Find pipes in the configured registry index. | | `openflange inspect ` | Show a pipe’s contract: ports, parameters, implementation, permissions. | | `openflange validate [--plan] [--json]` | Check a manifest or a pipeline without running it. `--plan` prints the execution plan. | | `openflange resolve` | Resolve every reference and create or complete `openflange.lock.yaml`. | | `openflange update [ref]` | Re-resolve all references, or one, and update the lockfile. | | `openflange run [--locked] [--input name=path\|-] [--output name=path\|-] [--param k=v] [--grant ...] [--trusted] [--report path\|-]` | Execute. The sole input is bound to stdin and the sole output to stdout by default. | | `openflange serve [--addr 127.0.0.1:8080] [--token ...]` | Expose pipes over the HTTP Pipe Protocol. Loopback by default; a non-loopback address needs a token. | | `openflange test ` | Run the portable tests beside a manifest. | | `openflange init [dir]` | Scaffold a new, working pipe in `dir` (default: the current directory): a manifest with a Starlark expression and a test file. Existing files are never overwritten. | | `openflange version [--capabilities] [--json]` | Print the version. `--capabilities` lists the supported specification versions, adapters and languages, standard pipes and features. | | `openflange completion bash\|zsh\|fish` | Print a shell completion script. | | `openflange help ` | Show help for a command: flags and examples. | The table gives the syntax of the CLI specification plus the commands the implementation adds. The implementation accepts a little more — for example `validate` without a target checks the current directory, and `run` binds the only *required* port to stdin or stdout. Every reporting command accepts `--json`. ## A complete run From a clone of the repository: Input (stdin): ```text "Alice@Example.COM" ``` Command: ```text printf '"Alice@Example.COM"\n' | openflange run ./examples/email/normalize-and-mask-email ``` Output (stdout): ```text "a***e@example.com" ``` With more than one input or output, name them. `-` means stdin or stdout. With `in.ndjson` holding `"Alice@Example.COM"` and `"BOB@example.org"`: ```bash openflange run ./examples/email/normalize-and-mask-email-branching \ --input email=in.ndjson \ --output masked=- \ --output normalized=norm.ndjson \ --report report.json # stdout (masked): # "a***e@example.com" # "b*b@example.org" # norm.ndjson: # "alice@example.com" # "bob@example.org" ``` Diagnostics go to stderr and never into a data stream. `--report` writes a JSON run report: state, duration, and record and byte counts per port. Parameters are set with `--param`: ```bash openflange run ./examples/email/normalize-and-mask-email --param character=# < in.ndjson # "a###e@example.com" # "b#b@example.org" ``` ## Output contract - **stdout carries data only**: the records of a run, or the one JSON document of a reporting command given `--json`. Diagnostics, progress and summaries go to stderr. - Colour and the live status line appear only on a terminal. `NO_COLOR` or `--no-color` disables them; `--quiet` prints errors only. - Piped output is plain, one finding per line, and starts with the error code: ```text E_PARAM: unknown parameter "charcter" (pipeline.yaml:13:7, at nodes.mask.parameters.charcter) ``` ## Exit codes | Code | Meaning | |---|---| | 0 | Success. | | 1 | A run failed or was cancelled, or a test failed. | | 2 | Usage or validation error. Nothing was executed. | ## Choosing a registry Registry references such as `openflange/lowercase` are resolved through an index file. Point the CLI at any index, local or remote: ```bash openflange search email --registry ./registry/dist/index.json OPENFLANGE_REGISTRY=https://registry.example.com/index.json openflange search email ``` > **The default public index is not live** > > The default is `https://openflange.com/index.json`, which is not published yet. A local path or your own URL works without it; no central registry is required. ## Permissions A pipe that starts a subprocess, opens a network connection or reads a secret declares it. Nothing is granted by default. Grant per node in `pipeline.yaml` (`grants:`), or for a whole run with `--grant`. `--trusted` grants everything the pipes declare and prints that restrictions are **not** sandbox-enforced. See [Permissions](https://openflange.dev/concepts/permissions/). ## What your program sees If your pipe is a program, this is the entire protocol for the simple case: - One input arrives on **stdin**, one output leaves on **stdout**, one JSON value per line. - **stderr** is for diagnostics. Exit `0` for success, anything else for failure. - Parameters arrive as environment variables named `OPENFLANGE_PARAM_`. With more ports, the path in `OPENFLANGE_CONFIG` points to a JSON file listing each port and a local endpoint for the extra ones. Your program GETs extra inputs and POSTs extra outputs. See the [multi-port example](https://openflange.dev/examples/go-multiport/). ## Performance The CLI starts in under 20 ms, and a test streams a million records through a three-step pipeline with bounded memory. Measured as single runs on a shared virtual machine (AMD EPYC 9655P, 8 virtual CPUs, 16 GB RAM, Linux 6.12); the method, the variance and the remaining costs are in [docs/performance.md](https://github.com/openflange/openflange-go/blob/main/docs/performance.md). Batch mode for executable and Starlark pipes is in v0.0.1 and experimental: a pipe declares `batch: {maxItems, maxWaitMs}` and receives several records per call. See [the batch mode concept](https://openflange.dev/concepts/batch/). ## What the CLI is not It runs pipelines. It does not manage databases, schedule jobs or keep a history of runs. Call it from the scheduler you already have. --- Source: https://openflange.dev/std/ # Standard pipes The 28 pipes of standard library v0.1, generated from their manifests. Each name links to a page with a worked example. `openflange inspect std:` prints the same contract. | Pipe | What it does | Inputs → outputs | Parameters | |---|---|---|---| | [`std:map`](https://openflange.dev/std/map/) | Emits the value of a Starlark expression for every item. | `in` → `out` | `expr` (string, required) | | [`std:select`](https://openflange.dev/std/select/) | Keeps only the listed members of each record. | `in` → `out` | `fields` (array, required) | | [`std:rename`](https://openflange.dev/std/rename/) | Renames members of each record. | `in` → `out` | `mapping` (object, required) | | [`std:cast`](https://openflange.dev/std/cast/) | Converts members of each record to a JSON type, exactly or not at all. | `in` → `out`, `rejected`? | `fields` (object, required), `onError` (string, default "fail", "fail" \| "reject") | | [`std:filter`](https://openflange.dev/std/filter/) | Keeps the items for which a Starlark expression is truthy. | `in` → `out`, `rejected`? | `expr` (string, required) | | [`std:limit`](https://openflange.dev/std/limit/) | Emits at most the first `count` items. | `in` → `out` | `count` (integer, required) | | [`std:skip`](https://openflange.dev/std/skip/) | Discards the first `count` items. | `in` → `out` | `count` (integer, required) | | [`std:distinct`](https://openflange.dev/std/distinct/) | Keeps the first item for every distinct key; bounded by maxKeys. | `in` → `out` | `fields` (array), `maxKeys` (integer, default 1000000) | | [`std:split`](https://openflange.dev/std/split/) | Routes each item to `matched` or `unmatched` by a boolean expression. | `in` → `matched`, `unmatched` | `expr` (string, required) | | [`std:partition`](https://openflange.dev/std/partition/) | Routes items to one of up to eight outputs by key. | `in` → `p0`?, `p1`?, `p2`?, `p3`?, `p4`?, `p5`?, `p6`?, `p7`? | `key` (string, required), `partitions` (integer, required) | | [`std:merge`](https://openflange.dev/std/merge/) | Merges several streams into one, interleaved or concatenated. | `in` (variadic) → `out` | `mode` (string, default "interleave", "interleave" \| "concat") | | [`std:batch`](https://openflange.dev/std/batch/) | Groups consecutive items into JSON arrays of `size` items. | `in` → `out` | `size` (integer, required) | | [`std:unbatch`](https://openflange.dev/std/unbatch/) | Flattens array items into their elements. | `in` → `out` | — | | [`std:window`](https://openflange.dev/std/window/) | Record-count tumbling, sliding and partitioned windows. | `in` → `out` (windows) | `size` (integer, required), `step` (integer), `partitionBy` (string), `emitPartial` (boolean, default true), `maxPartitions` (integer, default 10000) | | [`std:window-processing-time`](https://openflange.dev/std/window-processing-time/) | Draft. Groups items by arrival time. Non-deterministic. | `in` → `out` (windows) | `durationMs` (integer, required), `maxItems` (integer, default 100000) | | [`std:json-parse`](https://openflange.dev/std/json-parse/) | Parses NDJSON text into items. | `in` (text) → `out` | — | | [`std:json-format`](https://openflange.dev/std/json-format/) | Serialises items as NDJSON text. | `in` → `out` (text) | — | | [`std:csv-decode`](https://openflange.dev/std/csv-decode/) | Parses CSV text into records of strings. | `in` (text) → `out` | `header` (boolean, default true), `delimiter` (string, default ","), `fields` (array) | | [`std:csv-encode`](https://openflange.dev/std/csv-encode/) | Serialises records as CSV text. | `in` → `out` (text) | `header` (boolean, default true), `delimiter` (string, default ","), `fields` (array) | | [`std:ndjson-to-arrow`](https://openflange.dev/std/ndjson-to-arrow/) | Converts records to Arrow record batches, refusing lossy values. | `in` → `out` (batches) | `schema` (object, required), `batchSize` (integer, default 1024) | | [`std:arrow-to-ndjson`](https://openflange.dev/std/arrow-to-ndjson/) | Converts Arrow record batches to records, refusing lossy values. | `in` (batches) → `out` | — | | [`std:validate-schema`](https://openflange.dev/std/validate-schema/) | Routes items by validity against a JSON Schema. | `in` → `valid`, `rejected`? | `schema` (object, required) | | [`std:stdin`](https://openflange.dev/std/stdin/) | Source: the runner's standard input as NDJSON. | — → `out` | — | | [`std:stdout`](https://openflange.dev/std/stdout/) | Sink: the runner's standard output as NDJSON. | `in` → — | — | | [`std:file-source`](https://openflange.dev/std/file-source/) | Source: an NDJSON file. Needs a filesystem.read grant covering `path`. | — → `out` | `path` (string, required) | | [`std:file-sink`](https://openflange.dev/std/file-sink/) | Sink: an NDJSON file. Needs a filesystem.write grant covering `path`. | `in` → — | `path` (string, required), `append` (boolean, default false) | | [`std:http-source`](https://openflange.dev/std/http-source/) | Source: NDJSON fetched with one HTTP GET. Needs a network grant for the URL's host:port. | — → `out` | `url` (string, required), `timeoutMs` (integer, default 30000) | | [`std:discard`](https://openflange.dev/std/discard/) | Sink: consumes and discards its input. | `in` → — | — | Ports are of kind `records` unless a kind is given in parentheses; `?` marks an optional port. A parameter marked `required` has no default. - Unless the table says otherwise a standard pipe has one input `in` and one output `out`. Exceptions to remember: `std:validate-schema` writes to `valid` and `rejected`; `std:split` to `matched` and `unmatched` (both required); `std:partition` to `p0` ... `p7`. - Records keep the order of their members from input to output (CSV columns stay in header order). - `std:filter` drops records for which the expression is false unless its `rejected` output is connected. `std:validate-schema` fails the run on an invalid record unless `rejected` is connected; rejected records look like `{"item": , "errors": [{"path": "/age", "message": "..."}]}`. - The `schema` of `std:validate-schema` is JSON Schema 2020-12: `type`, `required`, `properties`, `enum`, `const`, `minimum`, `exclusiveMinimum`, `minLength`, `pattern`, `if` and `then` all work. `pattern` uses RE2 syntax: no look-ahead, no back-references. `format` is not enforced (`format: email` accepts any string). To write the original record instead of the `{"item", "errors"}` wrapper, put `std:map` with `expr: 'item["item"]'` after `rejected`. - `std:cast` takes `fields: {name: string|integer|number|boolean}`: `"19.99"` cast to `number` becomes `19.99`, `"42"` cast to `integer` becomes `42`. A value that cannot be converted exactly fails the run, or with `onError: reject` goes to `rejected` as `{"item": , "errors": [{"field": "age", "message": "..."}]}`. For numeric rules on CSV data, validate the text, cast, then use `std:filter` with an expression such as `item["amount"] > 0`. - `std:distinct` keeps the first record per key; `fields: [email]` makes `email` the key, and without `fields` the whole record is the key. A missing member and a `null` member are two different keys. It remembers every key (up to `maxKeys`). - `std:file-source`, `std:file-sink` and `std:http-source` read and write NDJSON only and need grants (`filesystem.read`, `filesystem.write`, `network`). For most jobs binding files with `--input` and `--output` is simpler and needs no grant. - CSV is read by declaring a `text` input in the manifest and decoding it with `std:csv-decode`; it is written with `std:csv-encode` into a `text` output. Every decoded value is a string, and an empty cell is the empty string `""`, never `null` or a missing member. `std:csv-encode` writes the columns named in `fields`, in that order (without `fields`: the members of the first record, in their order), and quotes values that need it. - There is no standard pipe for sorting, joining, grouping, aggregating or counting, and none for Parquet, Excel, XML or databases. --- Source: https://openflange.dev/etl/ # A platform for your ETL Clean the rows, check them, add them up: the same three steps get rewritten for every tool that has to run them. Here you write them once, as pipes, and run the whole job with one command. About ten minutes, start to finish. ## The problem An ETL job is mostly three kinds of step: clean the rows, check them, add them up. None of them is hard. But the cleaning rule lives in a scheduler task, the same check is written again as a SQL model, and the notebook that reports the totals keeps its own copy. Change the rule and you change it three times — if you remember all three. OpenFlange makes each step a *pipe*. A pipe is a data-processing step with declared inputs and outputs. One short file connects the pipes and one command runs them. The same files run on your laptop, from cron, in CI, or inside any tool that speaks the standard. What you build here: a CSV of orders goes in; customer names are cleaned, bad rows are set aside together with the reason, paid orders are totalled per customer; a CSV comes out. Seven of the eight steps are [standard pipes](https://openflange.dev/std/) that ship with the runner. The eighth is fifteen lines of Starlark that you write. > **What ran, and where** > > Every command in steps 1 to 4 was run with `openflange 0.0.1 (go1.27.1 linux/amd64)` and its output is pasted as it came out; only the durations change from run to run. Steps 5 to 7 say plainly what was not run. ## 1. The files You need the `openflange` command, release v0.0.1, which needs Go ([details in the quickstart](https://openflange.dev/quickstart/#install)): ```bash go install github.com/openflange/openflange-go/cmd/openflange@v0.0.1 ``` The example is [`examples/etl-csv`](https://github.com/openflange/openflange-go/tree/v0.0.1/examples/etl-csv) in the openflange-go repository: clone it and run the commands from that directory, or create the files from this page. Lay out an empty directory like this: ```text orders-etl/ ├── orders.csv ├── OPENFLANGE.md ├── pipeline.yaml ├── openflange.yaml ├── pipes/ │ └── total-per-group/ │ ├── OPENFLANGE.md │ ├── total.star │ └── tests/ │ └── total-per-group.test.yaml └── tests/ └── orders-etl.test.yaml ``` The input has the usual problems: a name with spaces and capitals, an amount that is not a whole number, a missing customer, a date in another format, and a refunded order that must not be counted. `orders.csv`: ```text order_id,customer,day,amount_cents,status 1001, Ada ,2026-11-30,1000,paid 1002,bob,2026-11-30,550,paid 1003,ADA,2026-12-01,3200,paid 1004,bob,2026-12-01,12.5,paid 1005,cy,2026-12-01,900,refunded 1006,,2026-12-02,700,paid 1007,bob,2026-12-02,2000,paid 1008,cy,02/12/2026,1500,paid 1009,cy,2026-12-02,450,paid ``` The pipeline. Each node names a pipe and says which output it reads from. Nothing else connects them. Eight nodes. Seven are standard pipes; total-per-group is the one you write. Rows that fail validation leave on their own output. `pipeline.yaml`: ```yaml spec: openflange.org/pipeline/v0.1 nodes: decode: pipe: std:csv-decode inputs: in: {from: inputs.csv} clean: pipe: std:map inputs: in: {from: decode.outputs.out} parameters: expr: 'dict(item, customer=item["customer"].strip().lower())' check: pipe: std:validate-schema inputs: in: {from: clean.outputs.out} parameters: schema: type: object required: [order_id, customer, day, amount_cents, status] properties: customer: {type: string, minLength: 1} day: {type: string, pattern: "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"} amount_cents: {type: string, pattern: "^[0-9]+$"} status: {enum: [paid, refunded]} typed: pipe: std:cast inputs: in: {from: check.outputs.valid} parameters: fields: {order_id: integer, amount_cents: integer} paid: pipe: std:filter inputs: in: {from: typed.outputs.out} parameters: expr: 'item["status"] == "paid"' group: pipe: std:window inputs: in: {from: paid.outputs.out} parameters: size: 1000000 partitionBy: 'item["customer"]' total: pipe: ./pipes/total-per-group inputs: groups: {from: group.outputs.out} encode: pipe: std:csv-encode inputs: in: {from: total.outputs.totals} outputs: totals: {from: encode.outputs.out} rejected: {from: check.outputs.rejected} ``` The nodes of pipeline.yaml | Node | Pipe | What it does | |---|---|---| | `decode` | [`std:csv-decode`](https://openflange.dev/std/csv-decode/) | Reads CSV text into records. Every value stays a string: nothing is guessed. | | `clean` | [`std:map`](https://openflange.dev/std/map/) | Trims the customer name and puts it in lower case. | | `check` | [`std:validate-schema`](https://openflange.dev/std/validate-schema/) | Checks each row against a schema. A row that fails goes to `rejected` with the reason. | | `typed` | [`std:cast`](https://openflange.dev/std/cast/) | Turns `order_id` and `amount_cents` into integers, exactly. | | `paid` | [`std:filter`](https://openflange.dev/std/filter/) | Keeps the paid orders. | | `group` | [`std:window`](https://openflange.dev/std/window/) | Groups the orders by customer: one frame per customer when the input ends. | | `total` | `./pipes/total-per-group` yours | Your step: the number of orders and the sum of cents in each frame. | | `encode` | [`std:csv-encode`](https://openflange.dev/std/csv-encode/) | Writes the records as CSV text. | The job gets a contract of its own, so it can be tested, locked and reused as one pipe. `kind: text` says that `csv` and `totals` carry CSV text rather than records. `OPENFLANGE.md`: ````markdown --- spec: openflange.org/pipe/v0.1 id: orders-etl version: 0.1.0 title: Orders ETL description: Reads an orders CSV, cleans and validates every row, and writes the number of paid orders and the paid total per customer as CSV; rows that fail validation are routed to `rejected`. license: Apache-2.0 keywords: [etl, csv, validate, aggregate, example] maturity: experimental scope: dataset requires: [windows] inputs: csv: kind: text mediaTypes: [text/csv] description: 'Orders with a header row: order_id,customer,day,amount_cents,status.' outputs: totals: kind: text mediaTypes: [text/csv] description: 'CSV with a header row: customer,orders,total_cents — one row per customer, in order of first appearance.' rejected: required: false description: 'Rows that fail validation, as {"item", "errors"}. If not connected, the first invalid row fails the run.' implementation: type: pipeline path: pipeline.yaml --- # Orders ETL Implements the [OpenFlange](https://openflange.org/) specification. CSV in, CSV out: decode, clean, validate, cast, keep paid orders, total per customer. See [README.md](README.md) for the commands and their output. ``` csv ─▶ decode ─▶ clean ─▶ check ─┬─▶ typed ─▶ paid ─▶ group ─▶ total ─▶ encode ─▶ totals └─▶ rejected (optional) ``` - **The whole input is held in memory by `group`.** `std:window` with `partitionBy` and a size of 1,000,000 keeps every paid order until the end of the input, then emits one frame per customer. A customer with more than 1,000,000 paid orders would be split into several rows. For large inputs replace `group` + `total` with a database pipe (see the README). - Money is integer cents; sums are exact. - Permissions: none. Every node runs in-process. ```` The one step that is yours, with its contract. `std:window` hands it one frame per customer and it returns one record per frame. Money is kept in whole cents, so the sum is exact. `pipes/total-per-group/total.star`: ```python # SPDX-License-Identifier: Apache-2.0 # total-per-group: one record per window frame. Money is integer cents. def process(frame, params): total = 0 for order in frame["items"]: cents = order["amount_cents"] if type(cents) != "int": fail("amount_cents must be an integer, got %r" % cents) total += cents return { "customer": frame["window"]["partition"], "orders": len(frame["items"]), "total_cents": total, } ``` `pipes/total-per-group/OPENFLANGE.md`: ```markdown --- spec: openflange.org/pipe/v0.1 id: total-per-group version: 0.1.0 title: Total per group description: Turns each window frame of orders into one record with the group key, the number of orders and the sum of `amount_cents`. license: Apache-2.0 keywords: [aggregate, sum, window, starlark, example] maturity: experimental scope: window requires: [windows] cardinality: one-to-one deterministic: true inputs: groups: kind: windows description: 'Window frames whose items are orders with an integer `amount_cents`; the partition value is the group key.' outputs: totals: kind: records description: 'One record per frame: {"customer", "orders", "total_cents"}.' implementation: type: script language: starlark path: total.star --- # Total per group Implements the [OpenFlange](https://openflange.org/) specification. A Starlark script pipe, run in-process with no permissions. Put it after `std:window` with `partitionBy`: every frame becomes one record. Amounts are integer cents, so the sum is exact. An item whose `amount_cents` is not an integer fails the run with `E_RUNTIME`. ``` A short index marks this directory as the project root. That is where the lockfile will be written. `openflange.yaml`: ```yaml # Package index of the orders ETL example. spec: openflange.org/package/v0.1 default: . pipes: - . - pipes/total-per-group ``` ## 2. Run it Check the whole graph before anything runs: ```bash openflange validate . ``` ```text valid: . (8 nodes, 10 edges) ``` Now run it. The input is bound to a file and each output to a file of its own: ```bash openflange run . --input csv=orders.csv --output totals=totals.csv --output rejected=rejected.ndjson ``` ```text completed in 625µs — totals: 1 chunk, rejected: 3 records ``` The totals, in `totals.csv`: `totals.csv`: ```text customer,orders,total_cents ada,2,4200 bob,2,2550 cy,1,450 ``` And in `rejected.ndjson`, the three rows that did not pass, each with the reason. Nothing was dropped silently. `rejected.ndjson`: ```json {"item":{"order_id":"1004","customer":"bob","day":"2026-12-01","amount_cents":"12.5","status":"paid"},"errors":[{"path":"/amount_cents","message":"'12.5' does not match pattern '^[0-9]+$'"}]} {"item":{"order_id":"1006","customer":"","day":"2026-12-02","amount_cents":"700","status":"paid"},"errors":[{"path":"/customer","message":"minLength: got 0, want 1"}]} {"item":{"order_id":"1008","customer":"cy","day":"02/12/2026","amount_cents":"1500","status":"paid"},"errors":[{"path":"/day","message":"'02/12/2026' does not match pattern '^[0-9]{4}-[0-9]{2}-[0-9]{2}$'"}]} ``` Leave `rejected` unconnected and the first bad row stops the run with exit status 1. A bad row is either data you receive or an error you see: ```bash openflange run . --input csv=orders.csv ``` ```text E_RUNTIME: item 4 does not match the schema: /amount_cents: '12.5' does not match pattern '^[0-9]+$' (node check) hint: connect the output `rejected` to receive invalid items as data instead of failing failed in 4ms — totals: 0 chunks ``` ## 3. Lock it Record exactly what the pipeline resolved to: every standard pipe and your own step, each with a hash. ```bash openflange resolve ``` ```text ok: 9 references locked in openflange.lock.yaml (9 added, 0 changed) ``` **Show openflange.lock.yaml** `openflange.lock.yaml`: ```yaml # Generated by openflange resolve. Commit this file. spec: openflange.org/lock/v0.1 dependencies: "./": resolved: "." version: "0.1.0" revision: null integrity: "sha256-986f72ab909d3d8572acc20f97d4509847b4f7cbb6624c657ed2b95a7e7353a7" dependencies: - "./pipes/total-per-group" - "std:cast" - "std:csv-decode" - "std:csv-encode" - "std:filter" - "std:map" - "std:validate-schema" - "std:window" "./pipes/total-per-group": resolved: "pipes/total-per-group" version: "0.1.0" revision: null integrity: "sha256-bbbd35fdcece9a55ca0aa8e0ffcc184b061e714bdbeacac52a36e41b5ff7f6bd" "std:cast": resolved: "std:cast@0.1.0" version: "0.1.0" revision: null integrity: "sha256-97e37d1ac53ce0707419412ccf3580d74b55a510a821ffcb27e7d266712c410e" "std:csv-decode": resolved: "std:csv-decode@0.1.0" version: "0.1.0" revision: null integrity: "sha256-1353928181578da854dbc4a56987db084a0defea91ab5da8311edd82a8a41e75" "std:csv-encode": resolved: "std:csv-encode@0.1.0" version: "0.1.0" revision: null integrity: "sha256-44a6130259913e1eb9deace1b7c9168dfec6a9a64fa8bdb2bc410391c7a48a2a" "std:filter": resolved: "std:filter@0.1.0" version: "0.1.0" revision: null integrity: "sha256-1cdf1024f705cc88d3cbfc588efcea274af5b8dd6e7691f45853ae9d0f06e716" "std:map": resolved: "std:map@0.1.0" version: "0.1.0" revision: null integrity: "sha256-52f5564ae491cbeec79cdd4182fe7c64fadc2e7d87f981f4888be3a0971dea2d" "std:validate-schema": resolved: "std:validate-schema@0.1.0" version: "0.1.0" revision: null integrity: "sha256-e24f74f04235b3855bcff81a3a671bc212fa65e555b1b0cb97cc51a708f521f6" "std:window": resolved: "std:window@0.1.0" version: "0.1.0" revision: null integrity: "sha256-4b9a1df43868f4957c5ca40dda9f1516e4087e80571e2bd63de7628b64dce5d8" ``` Commit `openflange.lock.yaml`. With `--locked` the runner refuses anything that differs from it. Here `totals=-` sends the CSV to stdout: ```bash openflange run . --locked --input csv=orders.csv --output totals=- --output rejected=rejected.ndjson ``` ```text customer,orders,total_cents ada,2,4200 bob,2,2550 cy,1,450 completed in 2ms — totals: 1 chunk, rejected: 3 records ``` Now change one byte of your step and run the same command again: ```bash printf '# edited\n' >> pipes/total-per-group/total.star openflange run . --locked --input csv=orders.csv --output totals=- --output rejected=rejected.ndjson ``` ```text E_LOCK: reference "./pipes/total-per-group" does not match openflange.lock.yaml: ./pipes/total-per-group/OPENFLANGE.md now hashes to sha256-6cee713922d0…, the lockfile has sha256-bbbd35fdcece… (pipeline.yaml, at nodes.total.pipe) hint: run `openflange update ./pipes/total-per-group` if the change is intended ``` Exit status 2: nothing ran. Undo the edit before you go on. When a change is intended, `openflange update` moves the lock entry. More in [Lockfiles](https://openflange.dev/concepts/lockfiles/). ## 4. Test it A portable test is a YAML file next to the pipe: what goes in and what must come out. It travels with the pipeline, so whoever runs it next can check it first. This one feeds the job a small CSV and checks both outputs, an empty file, sums too large for a float, and the two ways the job must fail. `tests/orders-etl.test.yaml`: ```yaml spec: openflange.org/test/v0.1 pipe: .. tests: - name: cleans names, routes bad rows, totals paid orders per customer inputs: csv: text: | order_id,customer,day,amount_cents,status 1, Ada ,2026-12-01,1000,paid 2,bob,2026-12-01,550,paid 3,ADA,2026-12-02,3200,paid 4,bob,2026-12-02,12.5,paid 5,bob,2026-12-02,900,refunded expect: outputs: totals: {text: "customer,orders,total_cents\nada,2,4200\nbob,1,550\n"} rejected: count: 1 schema: type: object required: [item, errors] properties: item: {type: object, properties: {order_id: {const: "4"}}} errors: {type: array, minItems: 1, items: {type: object, required: [path, message]}} - name: a header row alone gives empty output inputs: csv: {text: "order_id,customer,day,amount_cents,status\n"} expect: outputs: totals: {text: ""} rejected: {count: 0} - name: large totals stay exact inputs: csv: text: | order_id,customer,day,amount_cents,status 1,ada,2026-12-01,9007199254740993,paid 2,ada,2026-12-02,9007199254740993,paid expect: outputs: totals: {text: "customer,orders,total_cents\nada,2,18014398509481986\n"} - name: without a rejected consumer a bad row fails the run inputs: csv: {text: "order_id,customer,day,amount_cents,status\n1,ada,yesterday,1000,paid\n"} expect: status: failed error: {code: E_RUNTIME} outputs: rejected: {disabled: true} - name: a ragged CSV row is a format error inputs: csv: {text: "order_id,customer,day,amount_cents,status\n1,ada\n"} expect: status: failed error: {code: E_FORMAT} ``` Your own step has a test of its own, so it can be reused without the rest of the job. `pipes/total-per-group/tests/total-per-group.test.yaml`: ```yaml spec: openflange.org/test/v0.1 tests: - name: one record per frame inputs: groups: values: - window: {index: 0, partition: ada, start: 0, end: 1, final: true, partial: true} items: [{amount_cents: 1000}, {amount_cents: 3200}] - window: {index: 0, partition: bob, start: 0, end: 0, final: true, partial: true} items: [{amount_cents: 550}] expect: outputs: totals: values: - {customer: ada, orders: 2, total_cents: 4200} - {customer: bob, orders: 1, total_cents: 550} - name: an amount that is not an integer fails the run inputs: groups: values: - window: {index: 0, partition: ada, start: 0, end: 0, final: true, partial: true} items: [{amount_cents: "1000"}] expect: status: failed error: {code: E_RUNTIME} ``` Run both: ```bash openflange test . ./pipes/total-per-group ``` ```text tests/orders-etl.test.yaml ok cleans names, routes bad rows, totals paid orders per customer ok a header row alone gives empty output ok large totals stay exact ok without a rejected consumer a bad row fails the run ok a ragged CSV row is a format error pipes/total-per-group/tests/total-per-group.test.yaml ok one record per frame ok an amount that is not an integer fails the run ok 7 tests passed in 2 files (40ms) ``` ## 5. Swap a step, keep the rest The aggregate above keeps the paid orders in memory until the input ends: `std:window` grouped by customer, with at most 1,000,000 orders per customer and 10,000 customers. That is right for a file of this kind and wrong for a hundred million rows. For real volumes the aggregate belongs in a database or in R, and that is a change to two nodes, not to the job. Replace `group` and `total` with one node that runs a `GROUP BY`. The repository has such pipes: [a DuckDB SQL query as a pipe](https://openflange.dev/examples/duckdb-sql/) and [an R script as a pipe](https://openflange.dev/examples/r-summary/). Cleaning, validation, the lockfile and the tests keep their shape. > **Not run for this page** > > The DuckDB and R variants of the aggregate were not run for this example, and no output is shown for them. The aggregate in steps 1 to 4 is the one that ran. ## 6. Batch the expensive steps Every step of this pipeline runs inside the runner, so there is nothing to batch. That changes when a step lives in another process — an R or Python script, a database command-line tool, a call to a paid API — and a round trip per record becomes the cost. Such a pipe declares [batch mode](https://openflange.dev/concepts/batch/) in its manifest. The runner then hands it many records at a time, as one line or one file per batch, and the pipeline around it does not change: ```yaml batch: maxItems: 50000 maxWaitMs: 1000 delivery: file ``` From `examples/batch-file-duckdb/OPENFLANGE.md` in the repository. It needs the `duckdb` command, so it was not run for this page. Batch boundaries carry no meaning: batches are cut by size and time. A step that works row by row is safe to batch. An aggregate is not, because it would return one partial total per batch. The design and its reasons are in [RFC 0003](https://github.com/openflange/spec/blob/main/rfcs/0003-batch-mode.md). ## 7. Schedule it yourself **OpenFlange is not a scheduler.** It has no clock, no queue and no retry policy. A run starts when something calls the command and ends with an exit status: 0 completed, 1 failed, 2 nothing ran. Run it from cron, CI or your orchestrator. Two illustrations of calling the CLI follow. They are not part of the example and were not run for this page; the paths and names are placeholders. `cron (illustration)`: ```text # crontab -e: every night at 02:15. A crontab entry is one line. PATH=/usr/local/bin:/usr/bin:/bin:/home/etl/go/bin ETL=/srv/orders-etl OUT=/data/out 15 2 * * * cd $ETL && openflange run . --locked --input csv=/data/in/orders.csv --output totals=$OUT/totals.csv --output rejected=$OUT/rejected.ndjson >> /var/log/orders-etl.log 2>&1 ``` The same in GitHub Actions, pinned to release v0.0.1: `.github/workflows/orders-etl.yml (illustration)`: ```text name: orders-etl on: schedule: [{cron: "15 2 * * *"}] workflow_dispatch: jobs: run: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: {go-version: stable} - run: go install github.com/openflange/openflange-go/cmd/openflange@v0.0.1 - run: openflange test . ./pipes/total-per-group - run: openflange run . --locked --input csv=orders.csv --output totals=totals.csv --output rejected=rejected.ndjson - uses: actions/upload-artifact@v4 with: name: orders-etl path: | totals.csv rejected.ndjson ``` ## What OpenFlange is not - **Not a scheduler.** Something else decides when a run starts and what happens when it fails. OpenFlange gives that something one command and an honest exit status. - **Not a warehouse.** It moves and transforms records and stores nothing. The file, database or warehouse at either end is yours. - **Not a catalogue of hundreds of connectors.** The [standard library](https://openflange.dev/std/) is small on purpose: files, CSV, JSON, filtering, casting, validation, windows. A source or sink that is missing is a pipe you write, in the language you already use. What it does solve is one problem: an ETL step locked inside one tool. For the standard behind this page see [ETL on openflange.org](https://openflange.org/etl/); for finding and publishing pipes see [ETL on openflange.com](https://openflange.com/etl/). Verified with `openflange 0.0.1 (go1.27.1 linux/amd64)` built from openflange-go commit `11cf8cc5378d70858724b16aa937d7f3b98c085d`. The site’s tests compare every file and output on this page with the example byte for byte. One problem, four entry points ## ETL across OpenFlange - openflange.org[The standard](https://openflange.org/etl/)An open standard for your own ETL blocks: each step is a pipe with a declared contract. - openflange.com[The blocks](https://openflange.com/etl/)Building blocks for your ETL: extract, transform and load steps you can read before you run. - openflange.devThe platformA platform for your ETL: build, test and lock a pipeline from the command line.You are here - datatug.app[DataTug](https://datatug.app/)Visual builder and out-of-the-box runner for ETL. Pipelines in DataTug are in development.In development