Results store¶
This page specifies the results store: the zarr-vectors point cloud in which
the tiled pipeline writes one row per search point. It lists every attribute,
the root metadata, the three-phase write protocol, how an interrupted run
resumes, what zvdvc finalize does, and the .disp/.stat exports, with an
example of reading results. It is for users analysing results and for anyone
writing tools that read the store. Source:
io/results.py,
pipeline/coordinator.py.
Terms¶
- Results store
The zarr-vectors point cloud named by
outputin the run configuration, conventionallyresults.zarrvectors. Written byzvdvc seed(wavefront mode) andzvdvc run; completed byzvdvc finalize. The in-memoryzvdvc solvewrites a.npzinstead.- Vertex attribute
A per-point array stored alongside the vertices, one row per point, with a fixed dtype and number of columns.
- Written cell
A cell that every required result array holds. Only written cells count as done.
- Presence
zarr-vectors’ record of which cells hold data. The pipeline defers it while workers write and rebuilds it at the end.
- Template digest
Template.digest(), a 16-character hash of the sample offsets (Correlation method).- Run fingerprint
What a store’s values depend on: the result-affecting settings, the identity of both volumes and a digest of the points (
zvdvc.pipeline.coordinator.fingerprint()). Recorded when the store is allocated.
Introduction¶
The results store mirrors the search-point store cell for cell and fragment for fragment: row \(r\) of cell \(c\) in the input is row \(r\) of cell \(c\) here. No index table is needed, and a tile’s writes touch only that tile’s cells, so workers write in parallel without locks.
A run creates the store in zvdvc plan, before any point is solved, with
every array allocated and presence deferred. Workers then write whole cells,
with the status array last. A cell counts as written only when every
required array holds it, so a worker killed in the middle of a cell leaves
nothing that looks finished, and a resubmitted zvdvc run solves exactly the
tiles still missing. zvdvc finalize rebuilds presence and the metadata, and
writes the summaries.
Technical reference¶
Layout¶
results.zarrvectors/
zarr.json root: zarr_vectors metadata, multiscales, ome,
and zvDVC's zvdvc_results
0/ resolution level 0 (same grid as the points)
vertices/ (x, y, z) float32: the search point positions
vertex_fragments/
vertex_attributes/
point_id/ status/ objmin/ displacement/ params/ n_iter/ seed/
displacement_sd/ optional, see below
1/ 2/ only after `zvdvc finalize --pyramid`
Bounds, chunk_shape and bin_shape are copied from the search-point store
(Search-point store).
Vertex attributes¶
Required attributes (RESULT_ATTRIBUTES):
name |
dtype |
columns |
meaning |
|---|---|---|---|
|
int64 |
1 |
CCPi label, from the search-point store |
|
int8 |
1 |
|
|
float32 |
1 |
Objective at the solution (CCPi |
|
float32 |
3 |
\((u, v, w)\) in voxels: the first three entries of |
|
float32 |
|
Full parameter vector in CCPi order: |
|
uint8 |
1 |
Gauss–Newton steps taken |
|
float32 |
3 |
Starting displacement \((u, v, w)\), for audit |
Values are stored as solved, whatever the status: a RANGE_FAIL point keeps
the parameters it had when it failed. Filter on status == 0 before using
displacements.
Optional attributes (OPTIONAL_ATTRIBUTES), written when present in a
tile’s results and filled with NaN otherwise:
name |
dtype |
columns |
meaning |
|---|---|---|---|
|
float32 |
3 |
Per-axis standard deviation of the displacement over repeat solves with other template seeds ( |
Stores created before an optional attribute existed simply lack it; a cell
counts as written without optional attributes. Strain is not stored here;
zvdvc strain writes CSV and .npz files (Correlation method, “Strain”).
Root attribute zvdvc_results¶
The run’s layout, written by ResultStore.allocate into the root group’s
attributes:
field |
type |
meaning |
|---|---|---|
|
int |
3, 6 or 12: the number of |
|
3 floats |
cell size, \((x, y, z)\) voxels (from the point store) |
|
3 floats |
bin size, \((x, y, z)\) voxels (from the point store) |
|
string |
absolute path of the search-point store the rows come from |
|
int |
points in that store |
|
string or null |
digest of the sample template the results were computed with |
|
float |
|
|
list of strings |
optional attributes this store has (e.g. |
|
mapping or null |
the run fingerprint (below); null or absent in stores written before it was recorded |
A store written before the project was renamed from pyDVC carries the same
object under the key pydvc_results; ResultStore still reads it. A store
with neither key is refused (ValueError: not a zvDVC results store). The
root also holds zarr-vectors’ own zarr_vectors, multiscales and ome
metadata, which zarr-vectors manages.
Consistency checks on resume¶
zvdvc plan on an existing output store refuses to continue (ValueError)
when:
the store’s
doforchunk_shapediffers from the run’s;the store’s
template_digestdiffers from the run’s template (the subvolume settings, or zvDVC’s template construction, changed); a store with no digest only gives a warning, since the check cannot be made;the store’s
prefilter_sigmadiffers fromvolumes.prefilter_sigma;the store’s run fingerprint differs from the run’s (below). A store with no fingerprint only gives a warning.
Each worker repeats the template and prefilter checks when it opens the
store. plan.json also records the fingerprint, the template digest, the
config and the package versions (including zarr-vectors). zvdvc seed and
zvdvc run compare the config with the one in plan.json and refuse
(ValueError, naming the differing keys) when a result-affecting setting,
the points or output path, or a volume’s identity differs, or when the
point file changed after plan imported it. A plan.json with no
fingerprint only gives a warning.
Run fingerprint¶
fingerprint holds three parts:
part |
contents |
|---|---|
|
every setting that changes results: all of |
|
per volume: the resolved path, shape and dtype; for a raw, |
|
the point count and a digest of the ids and positions, in id order |
Because the resolved path is part of it, moving or copying the volumes, or
running from another working directory with relative paths, changes the
fingerprint; so does rewriting or touching a raw file (its size or
modification time). plan and run then refuse to resume into the old
store. Remove the store, or choose a new output (and workdir), to start
afresh.
Three-phase write¶
Writes follow zarr-vectors’ HPC pattern:
Allocate (
ResultStore.allocate, coordinator, once, inzvdvc plan):create_store,create_resolution_level,create_vertices_array, onecreate_attribute_arrayper required and optional attribute, thendefer_presence, then thezvdvc_resultsattribute. Workers never create arrays: re-creating one inside a write session would drop cells other workers have already written.Write (
ResultStore.write_tile, workers, in parallel): for each of the tile’s cells,write_chunk_verticesand onewrite_chunk_attributesper attribute, withrecord_presence=Falseand the rows split into the same fragments as the input. Attributes are written in the orderpoint_id,objmin,displacement,params,n_iter,seed, the optional attributes, andstatuslast.write_tilerefuses results that lack a required attribute. Cells written on a deferred level are visible to readers straight away.Finalise (
ResultStore.finalize, coordinator, once, inzvdvc finalize):rebuild_presence,refresh_arrays_present,update_level_metadata(vertex_count=N),write_multiscale_metadata, and with--pyramid,build_pyramid. Never run it while workers are writing.
Written cells and resume¶
ResultStore.written_cells() lists the chunk keys of vertices and of every
required attribute array and returns their intersection. Because status is
written last, a cell interrupted mid-write is missing from at least the
status array and does not count.
A worker skips a tile whose cells are all written.
A tile that raises is requeued once, then recorded as failed.
After
zvdvc run, tiles of this node still not written are listed in<workdir>/failed_tiles.json(with the errors) and in<workdir>/run_stats.json(missing_tiles), andzvdvc runexits with status 3; resubmittingzvdvc runsolves only those. On a multi-node run the file names carry a.node<rank>suffix.A crash loses at most the tiles a worker had taken: the one being solved and up to
prefetch_depthprefetched. In a test, akill -9of one of two workers left 4 of 8 tiles for the resubmitted job, which then wrote a bit-identical store (Architecture §9).
zvdvc finalize¶
zvdvc finalize CONFIG [--disp] [--pyramid] [--allow-partial]
finalize refuses (exit 2) while any cell of the point store is unwritten:
run zvdvc run again first. With --allow-partial it goes ahead and counts
and exports the points of unwritten cells as NOT_SEARCHED, with a warning.
A later zvdvc run reopens a partially finalised store for writing, so the
missing tiles can still be solved and finalize run again.
Reads every written cell (
read_all) and finalises the store (above).Writes
<workdir>/results.stat.With
--disp, writes<workdir>/results.disp, rows sorted bypoint_id.With
--pyramid, builds coarser levels1and2for viewers with zarr-vectors’Dataset.build_pyramid(factors=[(2.0, 1.0), (2.0, 1.0)], chunk_scale_factors=[2, 2]).
Exports¶
.disp (zvdvc.io.ccpi.write_disp): tab-separated, header
n x y z status objmin u v w, one row per point, numbers in %.9g. Status
codes below −3 (zvDVC-only) are written as −3, NOT_SEARCHED
(Status codes). Every .disp writer follows one policy, CCPi’s for
failed points: a point that is not GOOD gets u v w = 0, and a non-finite
objmin is written as 0. The raw values stay in the results store (and the
zvdvc solve .npz). iDVC and CCPi’s strain program read this
format. The zvdvc-dvc drop-in writes a stricter, byte-for-byte CCPi layout
(CCPi and iDVC file compatibility).
.stat (zvdvc.io.ccpi.write_stat): a zvDVC run summary, not CCPi’s
layout:
zvdvc run summary
points 125
seconds 0.114
points_per_second 1096.523
status GOOD 125
number successful = 125 (100.000%)
number range fail = 0 (0.000%)
number convg fail = 0 (0.000%)
number not searched = 0 (0.000%)
### config
volumes:
reference: ...
One status <NAME>\t<count> line per status present, with zvDVC’s names
(GOOD, RANGE_FAIL, CONVG_FAIL, NOT_SEARCHED, THRESH_FAIL,
SINGULAR); then CCPi-style number ... = n (p%) counts of CCPi’s four
codes, mapped as the .disp maps them (THRESH_FAIL and SINGULAR count as
not searched); then the full configuration as YAML. This is still not the
layout iDVC parses; the zvdvc-dvc drop-in writes that one. seconds comes from
<workdir>/run_stats.json.
Reading results¶
With zvDVC, zvdvc.io.results.ResultStore returns every written
point as numpy arrays, in cell order:
import numpy as np
from zvdvc.io.results import ResultStore
store = ResultStore("results.zarrvectors") # read-only by default
print(store.dof, store.chunk_shape, store.meta["template_digest"])
r = store.read_all() # xyz, point_id, status, objmin, displacement, params, n_iter, seed
# (+ displacement_sd when the store has it)
good = r["status"] == 0
u_good = r["displacement"][good]
order = np.argsort(r["point_id"]) # CCPi order, if you need it
With zarr-vectors alone, read the cells directly:
import numpy as np
import zarr
from zarr_vectors import building as zb
root = zb.open_store("results.zarrvectors", mode="r")
level = zb.get_resolution_level(root, 0)
cells = np.asarray(sorted(tuple(int(v) for v in c) for c in zb.list_chunk_keys(level)), dtype=np.int64)
batch = zb.read_cells(level, cells, ["vertices", "vertex_attributes/point_id",
"vertex_attributes/status", "vertex_attributes/displacement"])
xyz = np.asarray(batch["vertices"].data).reshape(-1, 3)
status = np.asarray(batch["vertex_attributes/status"].data).reshape(-1)
disp = np.asarray(batch["vertex_attributes/displacement"].data).reshape(-1, 3)
offsets = np.asarray(batch["vertices"].offsets) # rows of cell i: offsets[i]:offsets[i + 1]
dof = zarr.open_group("results.zarrvectors", mode="r").attrs["zvdvc_results"]["dof"]
Both snippets were run on a 96³ synthetic case (27 points, 8 cells) and
return the same values. Before zvdvc finalize, prefer
ResultStore.read_all(): it reads only cells that are completely written.
zvdvc compare and zvdvc strain accept a results store path directly.