bayesmithDocumentation0.10.0 source

Results, provenance and reuse

Store statistical products as typed data. Keep live graphs, callables and compiled executables outside the serialized envelope.

Each question has one kind of answer

Each of the five Task classes is answered by the Result class of the same name. compile_task and execute_task can each return a Refusal instead, naming the failed premise and the measurements behind it, so check both boundaries before consuming the result. Faults in the model and failed convergence are raised as exceptions. Core concepts defines each object; Five questions, one model runs all five.

Three identities to keep distinct

A task describes the question. A plan records how it will be answered. A Result holds the answer and a run record. Their identities and parent references provide a trace through the workflow, while fingerprints describe which model, data, configuration and policies they depend on.

model_ref_from_callable uses recoverable source to derive model identity. A REPL definition or dynamically generated function may need an explicit source digest. A memory-address-bearing repr is not a durable substitute.

Serialize with the public codec

from bayesmith.artifacts import dump_artifact, load_artifact

dump_artifact(posterior, "posterior.json")
restored = load_artifact("posterior.json")
assert restored.meta.artifact_id == posterior.meta.artifact_id

The five questions tutorial includes this operation in a temporary directory. Keep the JSON envelope and associated array payloads together. Do not replace the codec with pickle for live objects. Unsupported schema or codec versions are explicit errors.

Reuse requires compatible inputs

Renaming a human label does not change the statistical question. Changing observations, masks, model semantics, parameterization or a relevant task policy can invalidate reuse. A predictive execution checks the source posterior identity and its model/graph/data fingerprints.

Artifact validity and numerical quality are separate: the right posterior file can contain an unconverged run, while an excellent old run can refer to the wrong data. Keep both lifecycle state and evaluation reports.

Inspect the run record

The record carries backend/version, seed, device, dtype, JAX configuration, requested budget, actual termination, timing, approximation class and warnings. These fields make a result auditable without treating wall-clock time or a seed as proof of statistical correctness.

Reference: ArtifactRef, RunRecord, dump_artifact, load_artifact.

Type a concept or API name.