All documents

Grind

spicegrinder-icon

© 2026 Obsvra. This document describes SpiceGrinder and is provided to help you evaluate and use it. It is not a license to reproduce, adapt, or use this material to build a competing product or service. Full terms: the SpiceGrinder EULA.

NAME

Grind — load a SpiceGrinder model and emit observations

SYNOPSIS

java -cp spicegrinder.jar com.obsvra.spicegrinder.tools.Grind [options] model.xml|model.json

On a jpackage install, the same tool ships as a native launcher in the command-line package, next to experiment, validate, analyze, format, compare, list, mcp and (Pro) normalize, tabulate and service:

grind [options] model.xml|model.json

The graphical model editor is a separate desktop app, installed on its own from the same download page.

DESCRIPTION

Grind is the headless runtime: it loads a model file, drives its root node (or a named node inside it, see --node) for a fixed or unbounded number of observations, and writes the result as CSV, TSV, or plain text — to stdout by default, or to a file.

Exactly one model file must be given as the final positional argument. Pass - instead of a path to read the model from stdin — the same sentinel curl, tar, and grep -f already use, not a file literally named -. Content is sniffed as XML or JSON the same way a model submitted to the Service API is (JSON if it starts with {, XML otherwise); Compact (.sgm) format has no such signature, so a Compact model still needs a real file. Relative <Import>/<FlatFile> paths inside a piped model resolve as if the model were saved in the current working directory, since there is no file to anchor them at; --model-dir DIR names another folder to treat as the model’s own. A data file not found there is looked for in the model’s local root (--local-root, else project.root, else a .spicegrinder-root marker or the Git top above that folder), then the working directory.

OPTIONS

OptionMeaning
--count NNumber of observations to emit. Omit to run until interrupted (Ctrl+C). A model that is finite by nature (a ProcessFlow with until or closes) can end the run sooner: Grind keeps the rows produced, exits 0, and says on stderr that the model ended.
--declare NAME=VALUERun with the model’s <declare name="NAME"> set to VALUE instead of its default (repeatable). The same meaning as an <Import> override attribute; an unknown name is an error that lists the declared names, and a value cannot refer to another declare. Pro, as declare is. Example: grind --count 1440 --declare lanes=6 --declare rateScale=1.2 model.xml runs the same model with six lanes and 20% more arrivals, with no copy of the file.
--out PATHWrite output to a file instead of stdout. - also means stdout.
--format FMTcsv | tsv | plain | raw | jsonl | parquet (default csv).
--headerWrite a header row — csv/tsv only: the model’s column names if it names them (columns on the dataset), otherwise the names the node gives its own columns (a Summarize node’s measure names, also with --node), otherwise dim0,dim1,....

jsonl writes JSON Lines: one JSON object per row, keyed by the same names --header would write (the model’s columns, else the node’s own names, else dim0, dim1, …), so it needs no header row. A double or integer column is a JSON number, the same number the CSV holds (1.0E-5 is valid JSON); a double that is not a finite number (NaN, infinity) is null; every other value is a JSON string; a missing value is null. --format jsonl is not yet available with --remote.

parquet writes an Apache Parquet file that Arrow, pandas, Polars, DuckDB and Spark read, with its columns named as for jsonl. Give it --out FILE.parquet (it is binary; it can also go to stdout for a pipe). A column’s type is set by its first value: a decimal column is DOUBLE, a whole-number column INT32, anything else a UTF-8 string; a later whole number in a decimal column is widened, and a later number in a string column is written as its text. A decimal or text arriving in a whole-number column, or text in a decimal column, cannot keep the column’s type, so Grind stops with an error that names the column and the row; write csv or jsonl for such a model. Missing values are nulls; NaN and infinity are kept. The file is uncompressed, in row groups of 65,536 rows, and the same seed gives the same bytes. The footer is written when the run ends, also at Ctrl+C or when the model ends. Not yet available with --remote.

grind --count 1000000 --format parquet --out rows.parquet model.xml
python -c "import pandas as pd; print(pd.read_parquet('rows.parquet').describe())"
grind --count 2 --format jsonl model.xml      # a model with columns="x, n"
{"x":0.53569976880972,"n":1.0}
{"x":0.13950875528204942,"n":2.0}

raw writes each observation’s DataPoints back to back with nothing between them — no dim= prefix, no quoting, no separator — followed by a newline. It exists for format-conformance work: a filter renders a record (or an entire file, newlines and all) into a string, and raw puts it on disk byte for byte. Use it rather than leaning on tsv, which happens to look identical for a single unquoted column but is still applying TSV’s escaping rules. Multi-dimension observations are concatenated, which is what fixed-width assembly wants since each field arrives already padded to its column width. | --node NAME | Generate from a named registry node instead of the model root. | | --local-root DIR | Use DIR as the model’s local root for this run, ahead of project.root, a .spicegrinder-root marker and the Git work-tree top. A relative data file (a FlatFile file, an Email wordListFile) not beside the model is looked for there before the working directory, and a relative <Import> after the model’s folder; each must stay inside the folder it was found in. The desktop app passes its Local root setting this way. See FlatFile and the Model File Format Reference. | | --model-dir DIR | With - (stdin): resolve the model’s relative paths (<Import> files and data files) as if it were saved in DIR. The desktop app passes an edited model’s own folder this way. | | --seed N | Force the RNG seed for this process (highest precedence — see SEED PRECEDENCE). N must be 0 or greater (a negative seed is an error). A seed of 0 means no seed: Grind draws a fresh one, ignoring any seed in the model, and prints the one it used, so a --seed 0 run is as varied as --no-seed; see Determinism. Each node of a model draws from its own random stream derived from this seed and the node’s name (the streams attribute, default per-node); see Determinism. | | --no-seed | Ignore the model’s own embedded seed and force a fresh random one (see SEED PRECEDENCE). No effect if --seed is also given — --seed always wins, and a note is printed to stderr saying so. | | --remote HOST:PORT | Pro. Run on a SpiceGrinder Service instead of in this process (see REMOTE RUNS). A full http:// or https:// URL also works. | | --model-id ID | With --remote: run a model that is already registered on the Service; give no model file. | | --token TOKEN | With --remote: the Service’s bearer token (auth.token). Default: the SPICEGRINDER_SERVICE_TOKEN environment variable. Prefer the variable, since an argument shows in the process list. | | --keep-model | With --remote: leave the model registered afterwards and print its id (for --model-id). Default: delete it. | | --audit | Enable the audit/heartbeat instrumentation stream for this run. | | --performance | Enable the performance instrumentation stream for this run. | | --diagnostic | Enable the diagnostic instrumentation stream for this run. | | --seat | Tag this run’s instance.kind as a human-driven seat, overriding the default. | | --runtime | Tag this run’s instance.kind as an unattended/automated instance. | | --quiet | Suppress the progress banner lines normally written to stderr. | | -h, --help | Print usage and exit. | | --version | Print the version (e.g. 1.0.0 (Build 1)) and exit. |

REMOTE RUNS

--remote does what a wrapper script around grind and the Service API would otherwise do. It is Pro: a Free grind refuses it (exit 2), because the edition is decided where a model runs and a Free client running models on a licensed Service would have Pro. Given a model file, it applies --declare, flattens the model’s <Import>s so the Service needs none of your files (the same flattening as normalize), registers it (POST /v1/models), streams the rows (POST /v1/models/{id}/stream) to stdout or --out, and deletes the model again. Given --model-id, it skips registration and runs that model.

grind --remote rack:8085 --count 100000 --seed 42 --out draws.csv model.xml
grind --remote rack:8085 --model-id m-3f2c... --count 1000

--count, --seed, --no-seed, --format, --out, --node and --header mean what they do locally, and give the same rows for the same seed; with --seed or --no-seed omitted, the Service picks the seed (shown on stderr unless --quiet). The stream is used even for a bounded run, so a large --count does not have to fit in the Service’s memory; an unbounded run stops at Ctrl+C or the Service’s max.stream.observations.

--node and --header need a Service of 1.1 or later; against an older one, which would ignore them and stream the root with no header, grind stops with an error (exit 1) before writing a row. A node of an <Import name="L"> is named L.NAME, as it is locally.

Not supported with --remote: --audit, --performance, --diagnostic (exit 2). With --model-id, also no model file, --declare or --keep-model, because those apply when a model is registered.

Things to know:

  • A FlatFile or Database path in the model is resolved by the Service, not on your machine, and is subject to its allowlists. See File paths in submitted models.
  • A stream that fails partway still ends with HTTP 200 (see the Service API Reference), so Grind exits 0; compare the rows received with --count if that matters.
  • The Service needs at least one live process slot (max.processes) like any other client; this client adds no license.

SEED PRECEDENCE

Highest to lowest: --seed on this invocation > --no-seed (forces a fresh random seed, skipping the model’s own embedded seed if it has one) > the model spec’s own embedded seed attribute > a freshly generated seed. Whichever one actually ran is always applied to the process RNG and always logged — to stderr (unless --quiet) and to the run-summary instrumentation event if --audit/--performance is active. “No seed given” never means “not reproducible” — check the logged value.

Whichever seed applies, it is the root of the run’s random streams: by default (streams="per-node" on <dataset>) each node draws from its own stream derived from the seed and the node’s name, so adding or removing a node doesn’t change what the others draw; streams="shared" gives the one-stream-in-pull-order layout of the Beta releases. To replay a run, pass the logged seed back with --seed and keep the node names. See Determinism.

--no-seed exists for the case where a model has its own embedded seed but you want a genuinely fresh, non-reproducing run without having to generate and pass your own --seed value. It mirrors the Service API’s noSeed request field (Service-API-Reference.md), same precedence shape.

INSTRUMENTATION

--audit/--performance/--diagnostic are additive opt-ins layered on top of whatever ~/.spicegrinder/instrumentation.properties (or -Dspicegrinder.instrumentation.*) already enabled — they turn a stream on for this run; they never turn one off. Nothing is ever sent over the network; all instrumentation is local-only NDJSON under: ~/.spicegrinder/logs/{audit,performance,diagnostic}.ndjson

instance.kind buckets each logged event as seat (a modeler/developer at a terminal) or runtime (an unattended/automated invocation), for filtering in a log pipeline. Default: whether stdin/stdout is an interactive terminal (System.console() != null → seat, otherwise runtime). --seat/--runtime override that default and also override anything already set via the properties file, same precedence shape as --seed.

The audit log’s first event of each run, instance.start, records which build wrote the log: spicegrinder.edition (FREE or PRO) and spicegrinder.version (the same text --version prints, for example 1.0.0 (Build 1)). Every event of that run carries the same instance.id, so a log collected from many machines can be grouped by run and told apart by edition and version.

SIGNALS

Ctrl+C during an unbounded run (--count omitted) or a long bounded run finishes flushing already-generated output — and the run-summary/instance-stop instrumentation events — before the process actually exits. No abrupt kill mid-write.

EXIT STATUS

CodeMeaning
0Ran to completion (or was cleanly interrupted with Ctrl+C) and wrote output.
1Model file not found, --node name not found in the registry, or an error during load/generation.
2Bad arguments — missing required value, unrecognized option, or not exactly one model file given (--remote: also an option it does not support).

If generation fails partway (a Switch with no branch for a value, a Truncate out of attempts), grind keeps the rows it wrote before the failing one, prints ERROR: and the exception on stderr, and exits with status 1. A failed run can’t be resumed; start a new one. See How a model runs.

EXAMPLES

Generate 100 observations from a model’s root, as CSV, to stdout:

java -cp spicegrinder.jar com.obsvra.spicegrinder.tools.Grind --count 100 model.xml

Run unbounded (until Ctrl+C), TSV, with a header row, to a file:

grind --format tsv --header --out draws.tsv model.xml

Reproduce a prior run exactly:

grind --count 1000 --seed 42 model.xml

Get a genuinely fresh run from a model that has its own embedded seed baked in:

grind --count 1000 --no-seed model.xml

Generate from a specific internal node rather than the model’s root, with an audit trail:

grind --node ClaimSeverity --audit --count 500 model.xml

SEE ALSO

ModelValidatorApp(1), ModelAnalyzerApp(1), Model-File-Format-Reference.md