Package: results#
What a run leaves on disk and how it is read back. A run directory holds Zarr 3 arrays and Parquet 2.6 tables, sealed by the manifest.json that the run writes last. The DuckDB index .hmp/index.duckdb is derived from the run and session directories, so disk is the truth and hmp catalog reindex rebuilds the index at no cost.
The package is a layer because the solvers write into it and the readers read from it, and neither side has to know the other. A seal weighs 24 to 36 kB, of which 14 to 19 kB are value digests. The product store under <project>/.hmp/products/ keeps one folder per sha256 key, and [workspace] products_cap_mb caps it at 5000 MB.
A run has a level, read from its lineage. A kept calibration trial is a research run and keeps no figure, no export, no solver file and no face flow. Every other run is a result run and keeps what [simulation.results] asks. Project.gc() and hmp catalog gc remove what the policy allows and report the bytes before and after.
The plan of a project is plan.json, cases.csv and one TOML per case under plan/<hash>/, written once by plan_store.py.
results reads core, schema, catchment, mesh, model and itself, never data, solver, config or display. solver, calibration, display, config, workflow, project and cli read it. tests/unit/architecture/layer_matrix.yaml holds the edges and tests/unit/results/test_run_layout_contract.py the names of a run directory.
The one README of a port in this package is exporters/README.md. The page docs/source/contribute/architecture/packages/results.rst lists the modules and tells how the folders work together.
Modules#
top level
Module |
What it does |
Lines |
|---|---|---|
annotations.py |
Run annotations: the tags and notes a human adds after the seal. |
163 |
calibration_trials.py |
Read the trials and the phases of the session a run was promoted from. |
190 |
errors.py |
Typed exceptions for the results / reader layer. |
50 |
field_registry.py |
Canonical field registry for HydroModPy simulation outputs. |
1 472 |
grid.py |
Scalar metadata of the DEM raster a simulation was built from: pixel size, shape, extent. |
101 |
heartbeat.py |
The pulse of a running attempt: |
165 |
identity.py |
The |
364 |
ledger.py |
The ledger of a |
197 |
method.py |
The method text and the label sentence of a sealed run, in English or in French. |
322 |
metric_rule.py |
The metric of a run is a complete rule: a station, a window, a version. |
246 |
outcome.py |
The issue of an attempt: |
230 |
plan_store.py |
The immutable plan of a project: |
246 |
publication.py |
What a published copy records, and what the source remembers of it. |
498 |
readme.py |
The |
639 |
rel_dir.py |
One check for every |
26 |
retention.py |
What |
894 |
score.py |
The one pairing of a simulated series with its observations, and the score of a run. |
669 |
score_table.py |
Score the stored series of a run on any window, month mask and metric, after the fact. |
200 |
source_runs.py |
The earlier run a configuration reads, named by its |
83 |
spatial_index.py |
Point-in-cell lookup on unstructured meshes, cached per mesh geometry. |
286 |
trash.py |
Project trash: deleting a run or a session moves its directory, it never flips a flag. |
440 |
validity_rules.py |
The label of a run is a function of reading, not a value of the seal. |
331 |
catalog/adapters/
Module |
What it does |
Lines |
|---|---|---|
duckdb.py |
DuckDB backend of the catalog. |
259 |
catalog/
Module |
What it does |
Lines |
|---|---|---|
constants.py |
Catalog constants and small solver helpers. |
149 |
dataset_loader.py |
Catalog-wide dataset for model training. |
134 |
discovery.py |
Reference resolution and Run/Group discovery. |
948 |
facade.py |
|
394 |
federation.py |
Read the sealed runs of several projects without any index. |
164 |
index_file.py |
The file |
205 |
index_schema.py |
The schema of |
586 |
indexer.py |
Build and refresh |
1 344 |
listing.py |
List, show, query, point, diff and rank the runs of a project from its index. |
574 |
liveness.py |
Read the liveness of the runs and sessions of a project from its directories. |
123 |
parquet_views.py |
Parquet-backed DuckDB view helpers for per-run tabular outputs. |
154 |
privacy.py |
Purge a run for good and check the certificate it leaves behind. |
155 |
reads.py |
Read-side queries against the index. |
469 |
registration.py |
Names of the result directories of a project. |
464 |
schema.py |
Self-documenting schema accessors for |
118 |
storage_paths.py |
Filesystem path resolution for run artifacts. |
109 |
views.py |
The summary views of the index, written by the indexer next to its tables. |
298 |
derive/
Module |
What it does |
Lines |
|---|---|---|
accumulation.py |
Accumulation fluxes rebuilt on read, by range, on the descent D of the run. |
222 |
catchment_aggregation.py |
The |
381 |
config_flags.py |
What a run kept of the per-cell budget, and what to tell a reader who misses a field. |
234 |
derived.py |
Pure-function derivations of secondary fields from primary outputs. |
94 |
downsample.py |
LTTB downsampling for dense time series stored in the catalog. |
125 |
main_stem.py |
The main stem of an SFR network: the longest path of reaches that ends at an outlet. |
45 |
mesh_quality.py |
Quality of the stored mesh, one value per cell, rebuilt on read and never stored. |
251 |
porosity.py |
Effective porosity of a run, the water its pores hold and the turnover time it gives. |
89 |
reading.py |
Variable read dispatch shared by |
208 |
recession.py |
Recession rate against discharge, on the Brutsaert-Nieber log-log plane. |
128 |
root_bracket.py |
The final bracket of a root search: the closest pair of values around a sign change. |
42 |
run_memo.py |
Per-run memo for the heavy rebuilds several figures of one gallery share. |
42 |
time_alignment.py |
Time alignment helpers for observed and simulated series. |
290 |
views.py |
Lazy views of a run computed on demand, over the catchment or the active domain. |
1 070 |
virtual_fields.py |
On-the-fly derived fields computed from stored primary variables. |
926 |
derive/stream_network/
Module |
What it does |
Lines |
|---|---|---|
cell_fields.py |
Cell fields rebuilt from a run at read time: the network, its agreement, two distances. |
300 |
comparison.py |
Rebuild the simulated-versus-mapped stream comparison from a finished run. |
464 |
criterion_inputs.py |
The inputs of the stream criterion that a trial and a redrawn figure both read. |
318 |
criterion_score.py |
Turn the simulated network of one run into the distances of the network criterion. |
223 |
criterion_settings.py |
The network criterion settings a run was scored with, read back from its sealed config. |
496 |
depressions.py |
The two priority floods of a routing surface, and what separates them. |
133 |
heads_view.py |
What the heads figure needs, rebuilt from a finished run. |
154 |
routing_surface.py |
The model top the routing diagnostics explain, built once from a run’s mesh. |
312 |
run_extent.py |
Rebuild the flow extents of a finished transient run, as the criterion reads them. |
597 |
run_score.py |
Score the network criterion of a stored run again, as its calibration trial scored it. |
512 |
export/
Module |
What it does |
Lines |
|---|---|---|
campaign_summary.py |
Write the page, the README and the RO-Crate of a campaign summary under |
263 |
context.py |
Shared context object the FAIR views of a run or a job are rendered from. |
149 |
directory.py |
FAIR views of a sealed run or job directory, read from the directory alone. |
554 |
project_package.py |
Export a whole project with its data: |
365 |
prov.py |
W3C PROV-O lineage for HydroModPy simulations, embedded in the RO-Crate. |
223 |
publish.py |
Publish a run or a summary out of the project: one function, a directory or a tar. |
1 025 |
rocrate.py |
RO-Crate v1.1 metadata generator (https://www.researchobject.org/ro-crate/1.1/). |
322 |
summary_tables.py |
Write a table of runs as Parquet, CSV and GeoPackage, the same cells in each. |
179 |
zenodo.py |
The |
123 |
exporters/: The export port turns a finished run into a file that other tools read. Every format is one writer class declared the same way, in the wheel or out of tree, so a view that lives in the annex is named and refused like any other. port.py holds the ExportWriter Protocol and registry.py holds export_formats.
Module |
What it does |
Lines |
|---|---|---|
_tables.py |
Read the Parquet tables of one run from its directory, never from the index. |
63 |
csv.py |
Export the series and the budget of a run to CSV files. |
226 |
destination.py |
Where an export block sends its files once the run is sealed. |
148 |
export_spec.py |
One export request: what to export, when, in which format, where. |
821 |
fields.py |
What every field exporter reads the same way: one step, one layer, the CRS. |
83 |
formats.py |
The six file formats the wheel writes an export with. |
169 |
geopackage.py |
Export cell geometries with field values to a GeoPackage (OGC, single-file). |
51 |
geotiff.py |
Export fields and geographic rasters of a run to GeoTIFF. |
390 |
job.py |
What an export writer reads of a run: its target and its job. |
471 |
mesh_layers.py |
Export the cell mesh of a run as vector layers: its cells, their seeds, the faces of its lines. |
293 |
netcdf.py |
Export simulation fields from Zarr to NetCDF-4 with UGRID topology. |
457 |
port.py |
The export port: one writer per format, declared by the format itself. |
96 |
registry.py |
The export registry: every format a document can ask an export to write. |
205 |
request.py |
Write one export request of a run: expand it, plan its files, write each by kind. |
433 |
shapefile.py |
Export cell geometries with field values to a Shapefile. |
160 |
vector_layer.py |
Export a vector layer of a run to a GIS file: a stored layer, or its pathlines. |
111 |
vocabulary.py |
The names a user can export, and the kind of each. |
251 |
vtu.py |
Export simulation fields from Zarr to VTU (ParaView / PyVista). |
146 |
importers/
Module |
What it does |
Lines |
|---|---|---|
csv_timeseries.py |
Read a CSV time series file produced by |
108 |
netcdf_fields.py |
Read fields from a NetCDF-UGRID file produced by |
78 |
zarr_field.py |
Read a single field array from a simulation Zarr store. |
76 |
products/
Module |
What it does |
Lines |
|---|---|---|
cited.py |
|
72 |
key.py |
The key of a product: the digest of what the step reads and of the code. |
71 |
store.py |
The product store under |
246 |
record/
Module |
What it does |
Lines |
|---|---|---|
checks.py |
The |
270 |
forms.py |
The forms of a pre-release, converted in memory when a reader meets them. |
61 |
label.py |
The identity block a derived file of a run carries, and the label of the day. |
151 |
manifest.py |
The run manifest: the schema of the seal and its reader. |
702 |
record.py |
The run record: the seal of a run, built in memory and written without the index. |
497 |
replay_class.py |
The class of a replay: whether it reproduced the sealed values, and by how much. |
228 |
request_identity.py |
The two fingerprints of a run: what it asks, and what computes it. |
421 |
values.py |
The value digests of a run, taken at the seal or recomputed from the disk. |
277 |
run/
Module |
What it does |
Lines |
|---|---|---|
array.py |
Array / xarray provider bound to a single |
341 |
contracts.py |
Strong-typed return contracts for |
236 |
descent.py |
The descent D of a run and what the stream criterion reads beside it. |
394 |
environment.py |
Capture host environment metadata for the |
304 |
field_envelope.py |
Read the fields of earlier runs that the refinement zones of |
174 |
geographic.py |
Geographic and mesh accessors for |
550 |
group.py |
Multi-simulation view on the results catalog. |
708 |
hydrographic.py |
Hydrographic-network accessors for |
155 |
lake_abacus_view.py |
Read the persisted lake abacus comparison for a run. |
51 |
mesh_families.py |
The line families of the mesh of a run: the cells of its rivers, the faces of its lines. |
123 |
observation_points.py |
Sample the observation points a run declared, and keep them on disk. |
148 |
particles.py |
Particle pathlines a run tracked, read from its |
247 |
periods.py |
The stress periods of a run, placed on the calendar. |
93 |
point.py |
Point interrogation of a finished run: one cell, one variable, one series. |
552 |
ranking.py |
Rank the rows of sealed runs by one metric, and say why a group has no ranked row. |
113 |
sealed.py |
What a completed run says about itself, read from its own directory. |
337 |
sealed_facts.py |
The facts of one sealed run, read from its |
153 |
sfr.py |
The resolved SFR reaches of a run: who drains into whom, and how long they are. |
36 |
tables.py |
The Parquet tables of one run, read from its directory. |
67 |
timeseries.py |
Tabular and time-aligned accessors for |
514 |
view.py |
Single-simulation view on one run directory. |
1 038 |
session/
Module |
What it does |
Lines |
|---|---|---|
acceptance.py |
The trial a session returned and the cost under which a trial is acceptable, per phase. |
40 |
descriptor.py |
The descriptor of a calibration session: |
515 |
journal.py |
The trial journal of a session: |
384 |
phase.py |
The descriptor of one phase of a staged search: |
155 |
summary.py |
The summary of one calibration session, written once. |
256 |
trial_series.py |
The scored series of one trial: |
109 |
view.py |
Read-only view of one calibration session directory, |
413 |
storage/
Module |
What it does |
Lines |
|---|---|---|
array_fingerprint.py |
Input provenance fingerprinting for simulation reproducibility. |
44 |
arrow_tables.py |
Build the Arrow tables of the Parquet payloads of a run. |
168 |
attempt.py |
The attempt protocol: who may work in a run directory, and how it ends. |
925 |
contract.py |
Result-storage layout contract: what one run and one session directory hold. |
444 |
declared.py |
What a backend may write into the store of a run, and what is refused. |
125 |
diagnostics.py |
Diagnostics for the project result-storage layout. |
269 |
digests.py |
Digests and sizes of the files a run reads or writes. |
48 |
final_state.py |
The last state of a run, in double precision, for the run that starts from it. |
161 |
geo_metadata.py |
Geographic facts a run states about itself, and how they are typed. |
198 |
json_io.py |
Atomic JSON documents of a run, a session, a plan or a publication. |
309 |
kept.py |
What a run keeps of its solver outputs, and the witness of a purged trial. |
212 |
licence.py |
The licence a run may state, derived from the inputs it read. |
36 |
parquet_io.py |
Atomic pyarrow Parquet writer with canonical V1 options forced. |
182 |
parquet_schemas.py |
PyArrow schemas for every per-simulation Parquet file. |
1 589 |
prior_state.py |
Read an earlier run as the state a new run starts from. |
298 |
run_facts.py |
The facts a run accumulates about itself before its seal. |
359 |
run_log.py |
The logs of one attempt: |
217 |
run_profile.py |
|
251 |
run_store.py |
The store of one run: its Zarr arrays, its Parquet tables and its facts. |
1 216 |
scratch.py |
The solver scratch of an attempt: what leaves it at the end of a run, and how. |
105 |
sealing.py |
The seal of a completed run, built from its store and written by it. |
615 |
soil_tables.py |
What a soil-reservoir run writes about its columns. |
224 |
udunits.py |
The one spelling of a unit in a stored table: udunits, as the field registry writes it. |
101 |
zarr_store/
Module |
What it does |
Lines |
|---|---|---|
acdd.py |
ACDD-1.3 root-attribute composition for Zarr stores. |
235 |
cf_validation.py |
CF v85 standard-name validation against the bundled curated list. |
36 |
chunks.py |
Balanced chunk and sharding heuristics for Zarr v3 stores. |
119 |
constants.py |
Public Zarr-store constants. Kept tiny on purpose. |
52 |
geometry_writer.py |
Write-side of the geometry of a simulation store: mesh, descent, topography, time, CRS and the geographic raster. |
935 |
mesh_layout.py |
What a run store keeps of its cell mesh, beyond vertices and connectivity. |
289 |
simulation_zarr.py |
SimulationZarr: per-simulation Zarr v3 store (CF-1.11 + ACDD-1.3 + UGRID-1.0). |
195 |
zarr_finalizer.py |
The write-lock address and the metadata consolidation of a run store. |
67 |
zarr_reader.py |
Read-side concerns for |
425 |
zarr_schema.py |
Schema concerns for |
193 |
zarr_writer.py |
Write-side concerns for |
894 |
Inside the package#
The package answers how a run is stored, sealed, found and read back. The stored arrays are at Outputs of a run and the contract is Storage layout.
Storage and the seal#
storage/contract.py is the place to look for a name. CERTIFIED_RUN_ENTRIES lists what
the seal inventories and UNSEALED_RUN_ENTRIES what it never does. A new file enters
contract.py first, then tests/unit/results/test_run_layout_contract.py.
The seal is written in one order. First come the CRS in WKT2, the attributes of fields.zarr,
the value digests, the copy of the sealed mesh, the class of a replay and the record of the run.
Then README.md follows, and its section “What this run does not give” is read from the keys
of the digests. profile.json sits outside the seal, because it describes one machine, and
figures/, exports/ and report/ are written after it and never inventoried.
record/ writes manifest.json on the model of hydromodpy/schema/seal.py, with one
digest per array. A field rounded for storage is hashed in double precision before the rounding, so bit covers the values as computed. A replay
compares its digests with the seal of its source and writes bit or deviation.
The catalog#
The index .hmp/index.duckdb is derived from the run and session directories. Catalog (facade.py) reads it and the indexer is the only writer.
The indexer takes the lock .hmp/index.duckdb.lock, reads every run, session and kept trial
into a staging file, checks that it still holds the lock, and publishes the file in one rename.
rebuild_index does the whole tree and index_new_runs does a diff. A change of
index_schema.py is a full rebuild. discovery.py turns a reference (a name, an id,
@last, @best:METRIC) into a run. liveness.py and privacy.py never open the index, so hmp doctor answers while it is rebuilt. SIMULATIONS_FROM in constants.py is the one join of a run row to the codes of
its solver, status, flow regime and mesh topology.
To add an index column, change index_schema.py, its read-back in indexer.py and the schema version.
The run view#
Run is one run directory and RunSet a view over several. The rows of a run come from
its own Parquet files and its arrays from its own Zarr store, so the index only finds the run.
Run (view.py) loads its row on first use. Tabular reads go to tables.py, and the
mixins geographic.py, timeseries.py and hydrographic.py add the rest. Providers hang
on the run (run.array, run.probe, run.periods, run.descent), and sealed.py
reads what the seal says. To add an accessor, write a provider in this folder and bind it in
view.py. test_run_surface.py caps Run at 50 public attributes.
The session#
A calibration session leaves files in sessions/<case>/, and Session reads that directory
alone and never the index, so a session copied out of its project reads the same. The search
writes session.json (descriptor.py) and appends each trial to trials.jsonl
(journal.py) as the events proposed, finished and linked. A reader keeps one
line per trial, the event of the highest rank, so a trial with a proposed line only, from a
killed session, reads as running with no cost. A field of a trial line goes in TrialLine of journal.py, and a format change needs a version change.
The Zarr store#
SimulationZarr is the door to fields.zarr/. A writer takes the store first and writes
one thing, with geometry in geometry_writer.py and fields and forcing in zarr_writer.py.
SimulationZarr binds each function of the writers and of zarr_reader.py as its methods,
so a signature is written once, in the module. To add a stored
field, add an entry in results/field_registry.py, then its write in zarr_writer.py,
bound in simulation_zarr.py.
What is derived at read time#
derive/ computes from a stored run what needs no storage, and nothing here writes to the
index or to the run directory. Run.read and Catalog.read go through one dispatch,
reading.py. A virtual field is computed from the stored ones by virtual_fields.py,
views.py reduces a field over the catchment to a series, and time_alignment.py puts
observed and simulated series on one axis. To add a computed
field, write a function in virtual_fields.py.
The stream criterion on a run#
Calibration scores the stream criterion per trial with the kernels of
catchment/stream_network. derive/stream_network/ reads the same inputs from a stored
run, so a figure draws the partition behind the number it illustrates. criterion_inputs.py
holds the one function for each input that the trial and the figure both read, and
workflow/steps/run_outputs.py calls it to keep the outline cells, the open water and the
mean recharge beside the run. A change to what counts as a stream goes in
catchment/stream_network/. A new input goes in criterion_inputs.py, and a new default in
core/scoring/stream_defaults.py, never as a literal in a caller.
tests/unit/architecture/test_the_stream_criterion_reads_once.py holds that each input has one
writer.
Leaving the project#
export/ builds the RO-Crate view of a sealed directory, copies a run or a summary out of
the tree, and packs a whole project. directory.py reads the seal and builds one
FairExportContext, so every view describes the same seal. A view is one format of the export
port (results/exporters/), and the STAC and standalone PROV views live in hydromodpy_annex/export/.
publish.py refuses a replay not classed bit, redacts the host, the user and the absolute paths, and drops the deliver_to key of
every [[export]] block.
Logs#
core/logging.py keeps one router on the package logger, and the router sends each record to
the files in the context variable RUN_SINKS. So two runs in two threads fill two
run.log files and no line crosses.