Skip to content

barracuda.io

Atomic, checksummed persistence for inference data and Bayes-factor scans. Existing files are not overwritten unless explicitly requested.

Reproducible persistence helpers for inference and validation outputs.

Attributes

SCAN_SCHEMA_VERSION module-attribute

SCAN_SCHEMA_VERSION: Final[int] = 1

__all__ module-attribute

__all__ = ['SCAN_SCHEMA_VERSION', 'ScanBundle', 'build_scan_archive', 'canonical_json', 'configuration_fingerprint', 'dataframe_checksum', 'load_inference_data', 'load_scan_bundle', 'save_inference_data', 'save_scan_bundle']

Classes

ScanBundle dataclass

ScanBundle(table: DataFrame, manifest: dict[str, Any], directory: Path)

A validated scan table and the manifest that describes it.

Functions:

_json_default

_json_default(value: Any) -> Any

canonical_json

canonical_json(payload: Any) -> str

Serialize configuration data deterministically for hashing.

configuration_fingerprint

configuration_fingerprint(payload: Any) -> str

Return a SHA-256 fingerprint for JSON-compatible configuration data.

dataframe_checksum

dataframe_checksum(frame: DataFrame, *, columns: Sequence[str] | None = None) -> str

Hash a table's schema, row order, values, and index-independent CSV.

A selected column order may be supplied when only the scientific input fields (rather than incidental report columns) should be covered.

_atomic_bytes

_atomic_bytes(path: Path, content: bytes, *, overwrite: bool) -> Path

save_inference_data

save_inference_data(idata: Any, path: str | Path, *, overwrite: bool = False) -> Path

Atomically save an ArviZ InferenceData object as NetCDF.

load_inference_data

load_inference_data(path: str | Path)

Load an ArviZ InferenceData NetCDF written by BARRACUDA.

save_scan_bundle

save_scan_bundle(table: DataFrame, directory: str | Path, *, configuration: Mapping[str, Any], overwrite: bool = False) -> ScanBundle

Persist a scan CSV and fingerprinted manifest with atomic file writes.

Existing files are never silently reused. Load them with :func:load_scan_bundle and an expected_configuration to verify a resume request before deciding whether additional inference is required.

load_scan_bundle

load_scan_bundle(directory: str | Path, *, expected_configuration: Mapping[str, Any] | None = None, verify: bool = True) -> ScanBundle

Load and optionally verify a saved scan bundle.

_zip_write

_zip_write(archive: ZipFile, name: str, content: bytes) -> None

build_scan_archive

build_scan_archive(table: DataFrame, *, configuration: Mapping[str, Any], recovery: DataFrame | None = None, artifacts: Mapping[str, bytes] | None = None) -> bytes

Build a deterministic portable ZIP for a Bayes-factor scan.