Weaving and document checks¶
weave
¶
Weaving experiment results into literate documents, and checking them.
An {experiment} directive in a literate .qvr.md module names one of
the module's experiments. weave_document runs each named experiment (or
reads its stored records) and writes the directive's body: the experiment's
hash, the content hash of its program, the pinned digests of its data, and
the result. check_document checks a literate document the way its build
does: every prose reference must name a declaration, every directive must
name an experiment of the module, and every woven result must record the
experiment's current hash. A result woven before its program, data, or
configuration changed records an old hash and is refused as stale, so no
number in the document outlives the program that produced it.
ProblemCode
¶
What a document problem is about.
DocumentProblem
didactic-model
¶
DocumentProblem(*, file: str, line: int, column: int, code: ProblemCode, message: str)
Bases: Model
A problem with a literate document's prose or woven results.
| PARAMETER | DESCRIPTION |
|---|---|
file
|
The document.
TYPE:
|
line
|
The 1-based line.
TYPE:
|
column
|
The 0-based column.
TYPE:
|
code
|
What the problem is about.
TYPE:
|
message
|
What is wrong and what to do.
TYPE:
|
render
¶
The problem as one diagnostic line.
| RETURNS | DESCRIPTION |
|---|---|
str
|
|
WeaveResult
didactic-model
¶
Bases: Model
What weaving a document did.
| PARAMETER | DESCRIPTION |
|---|---|
text
|
The woven document.
TYPE:
|
woven
|
The experiments woven, in document order.
TYPE:
|
computed
|
How many runs were computed rather than read from the store.
TYPE:
|
render_result
¶
render_result(runs: tuple[PointRun, ...]) -> tuple[str, ...]
The woven lines of an experiment's results.
| PARAMETER | DESCRIPTION |
|---|---|
runs
|
Its runs.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[str, ...]
|
For a run, its value (and a program's log joint); for a fit, each site's posterior mean and standard deviation, to four significant digits. A point of a sweep is prefixed by its swept values. |
Source code in src/quivers/literate/weave.py
weave_document
¶
weave_document(path: str | Path, *, roots: tuple[str | Path, ...] | None = None, store: ArtifactStore | None = None, rerun: bool = False) -> WeaveResult
Weave every {experiment} directive of a literate document.
| PARAMETER | DESCRIPTION |
|---|---|
path
|
A
TYPE:
|
roots
|
The directories module paths are relative to.
TYPE:
|
store
|
Where experiment records are kept; the project's store when None.
TYPE:
|
rerun
|
Compute every run even when its record is stored.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
WeaveResult
|
The woven text; the file is not written. |
| RAISES | DESCRIPTION |
|---|---|
ExperimentError
|
If a directive names no experiment of the module, or an experiment cannot be planned or run. |
Source code in src/quivers/literate/weave.py
check_document
¶
check_document(path: str | Path, *, roots: tuple[str | Path, ...] | None = None) -> tuple[DocumentProblem, ...]
Check a literate document's prose references and woven results.
| PARAMETER | DESCRIPTION |
|---|---|
path
|
A
TYPE:
|
roots
|
The directories module paths are relative to.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[DocumentProblem, ...]
|
Every prose reference that names no declaration, every directive that names no experiment, and every woven result that is missing or stale, in document order; empty when the document checks. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the document is not a |
ModuleError
|
If its module graph does not load or resolve. |
CompileError
|
If its module does not compile. |
Source code in src/quivers/literate/weave.py
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 | |