Different pipes. One standard.

Type to search this site.

Search runs in your browser against a static index built with this site (Pagefind). Nothing you type is sent to a server.

Do I have to rewrite my script?

Available — v0.0.1 (experimental)r

Use the tool you already have

An R script that reads stdin and writes stdout is already a valid pipe. Values 10, 20, 30 in; count, mean, median and sd out.

Available in v0.0.1: the files, README and tests are in examples/r-summary of the openflange-go repository. Commands run from the repository root.

Needs: Rscript with the jsonlite package.

A pipe is a data-processing step with declared inputs and outputs.

What goes in, what comes out

Input (stdin)
{"value":10}
{"value":20}
{"value":30}
Command — an ordinary Unix pipe
printf '%s\n' '{"value":10}' '{"value":20}' '{"value":30}' | Rscript --vanilla examples/r-summary/summary.R
Output (stdout)
{"count":3,"mean":20,"median":20,"sd":10}

Files and further commands

The same script through the runner
printf '%s\n' '{"value":10}' '{"value":20}' '{"value":30}' | openflange run ./examples/r-summary --grant subprocess
A bad record, skipped on request
printf '%s\n' '{"value":10}' '{"value":"n/a"}' '{"value":30}' | openflange run ./examples/r-summary --grant subprocess --param onInvalid=skip
# {"count":2,"mean":20,"median":20,"sd":14.142135623731,"skipped":1}

What to notice

  • The first command involves no OpenFlange software: one input on stdin, one output on stdout, diagnostics on stderr, exit code 0 for success. That is the whole CLI protocol for a simple pipe.
  • Through the runner the output is the same, and the runner also checks the contract, the parameters and the subprocess permission. Without --grant subprocess it refuses with E_PERMISSION (exit status 2).
  • A value that is missing or not a number fails the run and names the record. --param onInvalid=skip leaves such records out and counts them in skipped.
  • This script reads the whole input before answering (scope: dataset), so memory grows with the input. That is declared, not hidden; the bounded variant is the moving-window example.
  • The repository verified it with R 4.5.3 and jsonlite 2.0.0. It was not re-run for this page.