CLI

Internals of the zvtools terminal CLI. This page is argparse plumbing; for the actual command reference — subcommands, flags, and worked invocations — see The zvtools command line.

Entry point

zvtools — flag-based terminal CLI for zarr-vectors-tools.

Subcommands:

convert Ingest a file into a new zarr-vectors store (+ optional pyramid). merge Add a file’s or another store’s objects to an existing store. split Cut a store into one store per group, label or merged source. pyramid Build a sparsity pyramid on an existing store. validate Run core conformance validation on a store. info Print a store’s geometry, resolution levels, and metadata. attach Stage a table’s columns (or CIFTI maps) onto a store’s vertices. shard Repack per-chunk cells into shards, or undo it. bundles Summarise each group of a streamline store. synapses Join a synapse table to an EM skeleton store by segment id. run Run a recipe: several of the above in order, resumable.

Also runnable as python -m zarr_vectors_tools.

zarr_vectors_tools.cli.build_parser()[source]
Return type:

ArgumentParser

zarr_vectors_tools.cli.main(argv=None)[source]
Parameters:

argv (list[str] | None)

Return type:

int

Argument helpers

Shared argument helpers and the format registry for the zvtools CLI.

class zarr_vectors_tools.cli._args.ExportFmt(name, exts, module, func, extra, geometry, accepts)[source]

Bases: object

One format a store can be written back out to.

accepts names the exporter’s own optional parameters, so the CLI can pass only what a given exporter takes and refuse the rest by name rather than dropping it silently.

Parameters:
__init__(name, exts, module, func, extra, geometry, accepts)
Parameters:
Return type:

None

accepts: frozenset[str]
extra: str | None
exts: tuple[str, ...]
func: str
geometry: str
module: str
name: str
class zarr_vectors_tools.cli._args.Fmt(name, exts, module, func, extra, geometry, inline_pyramid=False)[source]

Bases: object

One convertible file format.

Parameters:
__init__(name, exts, module, func, extra, geometry, inline_pyramid=False)
Parameters:
Return type:

None

extra: str | None
exts: tuple[str, ...]
func: str
geometry: str
inline_pyramid: bool = False
module: str
name: str
zarr_vectors_tools.cli._args.build_factors(coarsen, sparsity)[source]

Zip --coarsen/--sparsity into per-level (coarsen, sparsity) tuples.

Returns None when neither is given (no pyramid requested). Raises when only one is given or their lengths differ.

Parameters:
Return type:

list[tuple[float, float]] | None

zarr_vectors_tools.cli._args.check_rdp_tolerances(tolerances, factors, coarsen_mode)[source]

Check --rdp-tolerance against the pyramid it is meant to shape.

Everything that can be decided without the store: a pyramid to apply to, one tolerance per --coarsen entry, positive finite distances, and rdp mode. Run before any ingest, so a bad list does not cost a conversion. Whether the store’s geometry has a tolerance is checked by the caller, which knows the format or has the store.

Parameters:
Return type:

list[float] | None

zarr_vectors_tools.cli._args.executor_ctx(workers, backend='process')[source]

Yield a parallel executor when workers > 1, else None.

backend="process" (default) uses the stdlib process pool — no extra dependency. backend="dask" uses a local Dask cluster and needs the parallel extra (it adds scatter broadcast of the shared payload, which helps dense levels with a large shared object).

Parameters:
  • workers (int | None)

  • backend (str)

zarr_vectors_tools.cli._args.load_export_func(fmt)[source]

Import the export entry function for fmt (lazy, with an install hint).

Parameters:

fmt (ExportFmt)

zarr_vectors_tools.cli._args.load_ingest_func(fmt)[source]

Import the ingest entry function for fmt (lazy, with an install hint).

Parameters:

fmt (Fmt)

zarr_vectors_tools.cli._args.looks_like_store(path)[source]

Is this a zarr-vectors store rather than a file to ingest?

What decides the DIRECTION of zvtools convert: a store on the input side means the user is exporting out of it. The test is the same one --overwrite uses to decide whether a directory is safe to replace – a directory carrying Zarr’s own metadata file – so the two cannot disagree about what a store is.

Parameters:

path (str | Path)

Return type:

bool

zarr_vectors_tools.cli._args.parse_float_list(s)[source]

"8,2,2" -> [8.0, 2.0, 2.0].

Parameters:

s (str)

Return type:

list[float]

zarr_vectors_tools.cli._args.parse_int_list(s)[source]

"2,2,2" -> [2, 2, 2].

Parameters:

s (str)

Return type:

list[int]

zarr_vectors_tools.cli._args.parse_num_chunks(s)[source]

"5000" -> 5000 (total) or "5,13,8" -> (5, 13, 8) (per-axis).

Parameters:

s (str)

Return type:

int | tuple[int, …]

zarr_vectors_tools.cli._args.parse_shape(s)[source]

"100,100,100" -> (100.0, 100.0, 100.0) (spatial chunk/bin size).

Parameters:

s (str)

Return type:

tuple[float, …]

zarr_vectors_tools.cli._args.parse_str_list(s)[source]

"x,y,z" -> ["x", "y", "z"] (column names).

Parameters:

s (str)

Return type:

list[str]

zarr_vectors_tools.cli._args.resolve_export_format(output_path, explicit)[source]

Return the ExportFmt for --format, or the OUTPUT extension.

The output names the format when exporting, which is the mirror of the ingest rule where the input does.

Parameters:
Return type:

ExportFmt

zarr_vectors_tools.cli._args.resolve_format(input_path, explicit)[source]

Return the Fmt for --format (if given) or the input extension.

A directory input is resolved by what is in it, since the cortical surface formats describe one subject as many files and a precomputed layer is a directory. A URL can only be a precomputed layer: every other ingester reads a local file.

Parameters:
Return type:

Fmt

convert

zvtools convert — move data between a file and a zarr-vectors store.

Both directions, chosen by what INPUT is:

  • a FILE in, a store out — ingest, optionally building a pyramid (a precomputed layer, a directory or URL rather than a file, counts as one);

  • a STORE in, a file out — export.

One command rather than two because it is one operation with a direction, and because a pipeline that ends in an export otherwise has to drop out of the CLI to a Python script for its last step.

zarr_vectors_tools.cli.convert.run(args)[source]
Return type:

int

zarr_vectors_tools.cli.convert.run_export(args)[source]

zvtools convert STORE OUT.ext — write a store back out to a file.

Return type:

int

zarr_vectors_tools.cli.convert.run_shard(args)[source]

zvtools shard — (re)shard or unshard an existing store.

Return type:

int

zarr_vectors_tools.cli.convert.run_synapses(args)[source]

zvtools synapses TABLE SKELETONS OUTPUT.

Return type:

int

pyramid

zvtools pyramid / validate / info subcommands.

zarr_vectors_tools.cli.pyramid.run_bundles(args)[source]

zvtools bundles STORE.

Return type:

int

zarr_vectors_tools.cli.pyramid.run_info(args)[source]
Return type:

int

zarr_vectors_tools.cli.pyramid.run_pyramid(args)[source]
Return type:

int

zarr_vectors_tools.cli.pyramid.run_validate(args)[source]
Return type:

int