Skip to main content

Command-line interface

The excel-grapher command-line tool validates series-binding sidecars against workbooks, audits resolution for codegen, prints an internals coverage worklist, optionally smoke-tests generated compute_* functions, and can write export modules to disk. It complements the Python APIs documented in Series bindings and the authoring loop in Authoring series bindings.

Run it from the project environment:

uv run excel-grapher --help
uv run excel-grapher bindings --help
uv run excel-grapher bindings validate --help
uv run excel-grapher bindings audit --help
uv run excel-grapher bindings burndown --help
uv run excel-grapher bindings upsert --help
uv run excel-grapher bindings viz --help
uv run excel-grapher bindings undomained --help
uv run excel-grapher bindings candidates --help

When the package is installed, excel-grapher is also available as a console script.

Command overview

Command Purpose
bindings validate Load a sidecar, build the dependency graph, and validate bindings against the workbook
bindings audit Resolve bindings the way codegen does and fail if resolution is not ok=True
bindings burndown Print unbound formula cells in the current bound graph closure as a coverage worklist (not a full workbook walk; not candidate bindings)
bindings upsert Insert or replace one series after fail-closed schema, occupancy, and resolution checks
bindings viz Write a statement-graph HTML visualization from series bindings
bindings undomained Print graph leaves that have no bindings domain
bindings candidates Print dynamic-ref leaves that still need a domain, before extract

More subcommands may be added over time; excel-grapher --help lists what is available in your installed version.

bindings validate

Validate a workbook and its binding sidecar before export or CI.

Synopsis

excel-grapher bindings validate WORKBOOK [--bindings PATH] [--json] [-v]
  [--smoke-test] [--emit-dir DIR] [--package-name NAME]
  [--use-cached-dynamic-refs] [--blank-ranges PATH]

Arguments

Argument Description
WORKBOOK Path to the .xlsx workbook (required).
--bindings PATH Binding sidecar file or shard directory. When omitted, the CLI looks for a colocated sidecar (see below).
--json Print the full validation report object as JSON (includes every issue).
-v, --verbose Print warnings in human-readable output. Errors are always printed when validation fails.
--smoke-test After a successful validation, generate binding modules and run compute_* smoke checks with workbook-default inputs.
--emit-dir DIR Write generated module files under DIR (see --package-name). Implied when combined with --smoke-test and an emit directory.
--package-name NAME Package directory name for smoke tests and emitted files (default: bindings_module).
--use-cached-dynamic-refs Resolve those dynamic refs from the workbook’s cached values instead of series domain.
--blank-ranges PATH Optional Python module exposing BLANK_RANGES: Sequence[str] (sheet-qualified rectangles omitted from the graph).

Validation-only is the default: no code is generated unless you pass --smoke-test or --emit-dir.

Resolving the sidecar

When --bindings is omitted, bindings validate tries, in order:

  1. {workbook_stem}.bindings.yaml next to the workbook
  2. {workbook_stem}.bindings/ (directory of *.bindings.yaml shards)

Pass --bindings explicitly when the sidecar lives elsewhere—for example a shared fixture:

uv run excel-grapher bindings validate examples/micro_workbooks/ffv2.xlsx \
  --bindings tests/fixtures/series_bindings/ffv2.yaml

Example: ffv2 game log

The ffv2 micro-workbook uses datetime column headers as TIME_PERIOD keys. It is a bindings validation demo: the published output rows are typed-in values, not formulas, so do not pass --smoke-test or --emit-dir (those need a formula output series; see tiny-DSA below). With a valid sidecar:

uv run excel-grapher bindings validate examples/micro_workbooks/ffv2.xlsx \
  --bindings tests/fixtures/series_bindings/ffv2.yaml

Successful validation prints a short summary on stdout:

ok=True errors=0 warnings=0
canonical_sha256=…
inputs=['puka_longest_reception', 'puka_receptions', …]
computes=['compute_puka_avg_yards_per_reception', …]

Add -v to include warnings (for example dtype_read_mismatch when a bind read mode disagrees with a concept dtype):

uv run excel-grapher bindings validate examples/micro_workbooks/ffv2.xlsx \
  --bindings tests/fixtures/series_bindings/ffv2.yaml -v

Use --json for machine-readable output (the same structure returned by validate_series_bindings()):

uv run excel-grapher bindings validate examples/micro_workbooks/ffv2.xlsx \
  --bindings tests/fixtures/series_bindings/ffv2.yaml --json

Each issue in the JSON report has level, code, message, and optional series_id and address fields.

Smoke test and code generation

After validation succeeds, --smoke-test generates an inverted-tree package, calls each compute_* with the workbook-default tensors and scalars from data.py, and checks the declared output coordinates and value contract. Export requires at least one formula output series.

uv run excel-grapher bindings validate lic_inputs.xlsx --smoke-test
uv run excel-grapher bindings validate lic_inputs.xlsx \
  --smoke-test --emit-dir ./generated

Workbooks that contain OFFSET / INDEX / INDIRECT with non-literal arguments need an explicit resolution strategy. The sidecar’s series domain (and constant pins) is that strategy:

uv run excel-grapher bindings validate \
  tests/fixtures/inverted_tree/tiny_dsa/tiny-dsa.xlsx \
  --bindings tests/fixtures/inverted_tree/tiny_dsa/bindings \
  --smoke-test

Without a bindings domain covering the OFFSET / INDEX / INDIRECT leaves, and without --use-cached-dynamic-refs, graph building fails with a message that names the cell and the flag to pass.

To persist generated files:

uv run excel-grapher bindings validate lic_inputs.xlsx \
  --smoke-test --emit-dir ./generated --package-name lic_bindings

Without --smoke-test, --emit-dir alone writes modules after validation:

uv run excel-grapher bindings validate lic_inputs.xlsx --emit-dir ./generated

When smoke checks pass, the CLI prints:

All compute functions passed smoke checks.

Error output

Failures fall into two layers:

Sidecar schema errors — the YAML/JSON manifest does not satisfy the JSON Schema (missing required fields, unknown properties, and so on). These are reported on stderr before workbook validation runs:

Binding sidecar schema error:
  series[8] "puka_week_1_fantasy_score": missing required field `key` — Add a key list naming the dimension ids that identify each record.

Locations use the series index and id from the sidecar so you can jump straight to the offending entry.

Workbook validation errors — the sidecar parses, but coordinate resolution or binding rules fail against the live workbook. These appear as human-readable lines on stdout (or inside issues[] with --json):

error [bind_resolution_failed] puka_targets:Sheet1!A4: could not convert string to float: 'Tgts'

When the same root cause affects many cells (for example a read: float bind over a row that includes a text label), identical messages are aggregated into one issue with a cell count and range rather than one line per cell.

Warnings such as dtype_read_mismatch do not fail validation by themselves; use -v to see them in text mode.

Exit codes

Code Meaning
0 Validation succeeded (and smoke tests passed, if requested).
1 Workbook or sidecar not found, schema error, validation failure, or smoke-test failure.
2 Unknown subcommand or invalid CLI usage.

bindings audit

Resolve input, output, internal, and constant series the same way codegen does. bindings validate does not require resolution ok=True; this command does.

excel-grapher bindings audit WORKBOOK [--bindings PATH] [--json]
  [--direction DIRECTION] [--strict]
  [--use-cached-dynamic-refs] [--blank-ranges PATH]

Exit 1 on error findings. --strict also fails on warnings such as empty_public_series. Repeat --direction to limit the scan (input / output / internal / constant).

bindings burndown

Print formula nodes in the current bound graph closure (the graph built from bound data_range targets) that are not covered by input, output, or internal bindings as a coverage worklist. This is not a full workbook walk; empty shards yield an empty graph. Collapsed A1 rectangles include a weak layout hint (scalar, series, or matrix). Do not treat each printed range as a series to emit.

excel-grapher bindings burndown WORKBOOK [--bindings PATH] [--json]
  [--per-sheet SHEET] [--max-rows N] [--exempt FILE] [--strict]
  [--use-cached-dynamic-refs] [--blank-ranges PATH]

--exempt is a text file of reviewed addresses (one per line; # comments allowed). --strict exits 1 when unbound cells remain. --max-rows limits row detail and prints ... (truncated) when it cuts off.

bindings upsert

Insert or replace one series after schema, occupancy, shard, and resolution checks against a temporary copy. The destination is written only when those checks succeed. There is no catalog → four-file bulk emitter.

excel-grapher bindings upsert WORKBOOK --series SERIES.yaml
  [--bindings PATH] [--replace]
  [--use-cached-dynamic-refs] [--blank-ranges PATH]

SERIES.yaml is one series mapping, or a document with series: [one entry]. --replace updates an existing id. When --bindings is omitted and no colocated sidecar exists, a successful upsert creates {stem}.bindings/ with four-file shards. A failed upsert leaves the destination unchanged. --use-cached-dynamic-refs defaults to off on the CLI (same as validate); the Python helper upsert_series_binding defaults it to on.

bindings undomained

Print graph leaves that have no bindings domain / from_workbook coverage. This is a domain-completeness worklist, distinct from bindings burndown (unbound formula cells in the bound closure).

excel-grapher bindings undomained WORKBOOK [--bindings PATH] [--json]
  [--use-cached-dynamic-refs]

When every leaf is covered, the command prints ok: every graph leaf has a bindings domain.

bindings candidates

Print the pre-extract worklist: leaf addresses that feed OFFSET / INDEX / INDIRECT and have no bindings domain yet. This does not build the dependency graph and does not accept --use-cached-dynamic-refs.

excel-grapher bindings candidates WORKBOOK [--bindings PATH]
  [--target ADDR] [--json] [--strict] [--undomained-match]
Argument Description
WORKBOOK Path to the .xlsx workbook (required).
--bindings PATH Sidecar file or shard directory. When omitted, the CLI looks for a colocated sidecar.
--target ADDR Extraction root (sheet-qualified address, range, or defined name). Repeatable. Unioned with every series data_range.
--json Print the address list as JSON. With --undomained-match, print {"missing", "undomained_exact_match"}.
--strict Exit 1 while any must-bind candidate remains. Undomained MATCH cells do not fail --strict.
--undomained-match Also print lookup cells exact MATCH kept only because they have no domain. Not merged into the must-bind list.

Empty shards have no roots. Author an output series first, or pass --target before a sidecar exists. The command prints one A1 address per line, or ok: no dynamic-ref leaves are missing a bindings domain.

The list is incomplete until controlling domains are wide enough to reach the next dynamic ref. Re-run after every domain edit on a dynamic-ref argument. INDEX/MATCH over a static rectangle is often typed from range geometry and does not appear on the must-bind list. When exact MATCH keeps a lookup cell only because it has no domain, inference emits ExactMatchUndomainedCellWarning and still succeeds. The warning lists cells the scan classified before a certain hit. A scan with no certain hit prints a prefix and the total count. An unpinned needle is not scanned and does not warn. --undomained-match returns that same collection separately; it does not list proven misses or cells after the hit. Defined names are resolved to addresses. BLANK_RANGES is not applied; subtract those cells yourself. A blank cell pinned only with constant stays on the list. A greater_than / not_equal whose partner series is missing fails with SeriesRelationError before any list is printed.

Walked end to end (bindings domains only, no Python constraint table, no cached dynamic refs) in tests/integration/grapher/test_extract_time_domain_loop.py: a micro workbook whose OFFSET uses a defined name and whose row domain must be widened before the downstream INDIRECT appears, then tiny-DSA output roots, which need only Inputs!B22 (shock_type) before extract. Remaining leaves are an undomained / attach_domains pass, not a second extract. Q-CRAFT Macrofiscal!C3 (INDEX/MATCH on a static country column) and Discrete Risks!C2:BT13 return an empty candidate list for the same reason: those selectors do not need a leaf domain.