hydromodpy.data.data_freeze#

Lockfile helpers for reproducible runs (hydromodpy.lock).

A lockfile freezes the build environment plus every input artefact that fed a HydroModPy run. It records:

  • [hydromodpy]: package + git commit + python + schema versions.

  • [binaries]: solver names + binary SHA-256 + --version text.

  • [schema]: catalog / zarr / parquet schema versions (and config sha256).

  • [inputs]: every catalog entry keyed by workspace-relative path with sha256, bytes and fetched_at.

  • [[artefact]] rows: legacy per-artefact detail (variable, source, station_id) used by frozen-mode replay.

Writes are atomic: payload lands in a sibling <dest>.tmp.<uuid> file which is fsync’d before os.replace swaps it into place. A crash mid-write leaves the previous lockfile untouched.

Verification has two modes:

  • verify_frozen (used by hmp lock verify and the frozen-mode catalog) walks every entry and reports LockMismatch records (one per kind: "missing", "sha256").

  • verify_inputs_strict returns the same kind of report but is consumed by hmp lock verify --strict to map sha256 mismatches to a non-zero exit.

Functions

archive_lockfile(catalog, dest, *[, ...])

Produce an archive containing the lockfile and every artefact.

is_frozen_mode()

Return whether frozen mode is currently active.

read_lockfile(path)

Load every legacy [[artefact]] block of the lockfile.

read_lockfile_binaries(path)

Return [binaries] payload (<solver>_sha256 etc.) as a flat dict.

read_lockfile_inputs(path)

Return the [inputs] table from the lockfile (rel_path -> payload).

read_lockfile_meta(path)

Return the [hydromodpy] header section as a plain dict.

read_lockfile_schema_sha256(path)

Return the schema.config_sha256 recorded in the lockfile, when present.

restore_archive(archive, dest_dir)

Extract archive into dest_dir and verify SHA-256.

set_frozen_mode(enabled)

Toggle process-wide frozen mode (used by hmp run --frozen).

sha256_of(path, *[, chunk])

Compute the SHA-256 digest of a file on disk.

verify_frozen(catalog, lockfile)

Return every mismatch between lockfile artefacts and the catalog.

verify_inputs_strict(catalog, lockfile)

Return only sha256 mismatches found in the [inputs] section.

write_lockfile(catalog, dest, *[, ...])

Freeze the current run environment + catalog inputs into dest.

Classes

LockMismatch(kind, variable, source, ...[, path])

Discrepancy between lockfile and on-disk catalog state.

LockedArtifact(variable, source, station_id, ...)

One locked artefact recorded in the lockfile.