Entry points¶
The executable entry points of a checked module, and one invocation the command line, the REPL, and Python share.
entries
¶
Entry points of a checked module and one way to invoke them.
A checked module has two kinds of executable entry point: a named
computation declared with define, run by
run_named under a runtime
configuration, and a program, elaborated to a computation over the
module's canonical random and score instances and run by
sample_program with its
data and any conditioned sites. The command line, the REPL, and a Python
caller invoke either through invoke_entry,
so an entry validates its arguments, selects its providers, traces, and
fails with the same codes however it is reached.
EntryKind
¶
How an entry point is declared: with define or with program.
HostValue
¶
HostValue = bool | int | float | str | Tensor | tuple['HostValue', ...] | Mapping[str, 'HostValue']
A value the reference machine takes or returns: a scalar, a tensor, a tuple, or a record of such values.
EntryParameter
didactic-model
¶
Bases: Model
One value parameter of an entry point.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The parameter's name.
TYPE:
|
type
|
Its type, rendered in the surface spelling.
TYPE:
|
role
|
How a program parameter is supplied (its data, an observation, a
fibration, a scalar, or the program's domain);
TYPE:
|
EntryPoint
didactic-model
¶
EntryPoint(*, name: str, kind: EntryKind, parameters: tuple[EntryParameter, ...], statics: tuple[str, ...], effects: tuple[str, ...], result: str, sites: tuple[str, ...])
Bases: Model
An executable entry point of a checked module.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The entry's source name.
TYPE:
|
kind
|
Whether it is a
TYPE:
|
parameters
|
Its value parameters, in order.
TYPE:
|
statics
|
The names of the static binders its telescope takes, in order.
TYPE:
|
effects
|
The effect instances its body performs, rendered as
TYPE:
|
result
|
Its result type, rendered.
TYPE:
|
sites
|
The labels of a program's sample sites, which a run may condition on; empty for a computation.
TYPE:
|
EntryRun
dataclass
¶
EntryRun(entry: EntryPoint, value: HostValue, log_joint: float | None, result: ExecutionResult)
What invoking an entry point produced.
| PARAMETER | DESCRIPTION |
|---|---|
entry
|
The entry invoked.
TYPE:
|
value
|
The validated host value the entry returned.
TYPE:
|
log_joint
|
The log joint density a program run accumulated, or
TYPE:
|
result
|
The underlying execution result, with its trace.
TYPE:
|
to_data
¶
Render the run as JSON-compatible data.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, object]
|
The execution result's data, with the entry's kind and, for a program, the log joint. |
Source code in src/quivers/qiec/entries.py
entry_points
¶
entry_points(module: QiecModule) -> tuple[EntryPoint, ...]
Every executable entry point of a module.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The checked module.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[EntryPoint, ...]
|
The programs and the computations, in declaration order; a computation a program elaborated to appears once, as the program, and a marginalization helper not at all. |
Source code in src/quivers/qiec/entries.py
entry_point
¶
entry_point(module: QiecModule, name: str) -> EntryPoint
One entry point of a module, by name.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The checked module.
TYPE:
|
name
|
The entry's source name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
EntryPoint
|
The entry. |
| RAISES | DESCRIPTION |
|---|---|
ExecutionFailure
|
With code |
Source code in src/quivers/qiec/entries.py
invoke_entry
¶
invoke_entry(module: QiecModule, name: str, arguments: Sequence[HostValue] = (), *, data: Mapping[str, HostValue] | None = None, sites: Mapping[str, HostValue] | None = None, static_arguments: Sequence[str] = (), runtime: RuntimeConfiguration | None = None, fuel: int | None = None, seed: int | None = None, observer: TraceObserver | None = None) -> EntryRun
Invoke an entry point.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The checked module.
TYPE:
|
name
|
The entry's source name.
TYPE:
|
arguments
|
Host values for the entry's value parameters, in order. A
program's parameters may instead, or additionally, be given by
name through
TYPE:
|
data
|
A program's parameters by name: its data, observations, fibrations, and scalars. A name given both positionally and here is an error.
TYPE:
|
sites
|
The values a program run conditions its sample sites on, by label; every other site is drawn. Not accepted for a computation.
TYPE:
|
static_arguments
|
Closed terms instantiating a computation's telescope, as
TYPE:
|
runtime
|
The providers a computation runs under; the core provider alone by default. A program's handlers are fixed by the run, so only the default configuration is accepted for a program.
TYPE:
|
fuel
|
A step budget for the run.
TYPE:
|
seed
|
A seed for the reference generator every draw of the run uses;
two runs seeded alike draw alike.
TYPE:
|
observer
|
A callback receiving every trace event as it is emitted.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
EntryRun
|
The value, the log joint for a program, and the execution result. |
| RAISES | DESCRIPTION |
|---|---|
ExecutionFailure
|
With code |
Source code in src/quivers/qiec/entries.py
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 | |
parse_bindings
¶
parse_bindings(items: Sequence[str]) -> dict[str, HostValue]
Read NAME=JSON bindings, as the command line and REPL take them.
| PARAMETER | DESCRIPTION |
|---|---|
items
|
The bindings as typed.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, HostValue]
|
Name to the parsed value, lists read as tuples. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If an item has no |
Source code in src/quivers/qiec/entries.py
json_value
¶
Read a parsed JSON value as a host value.
| PARAMETER | DESCRIPTION |
|---|---|
value
|
The parsed JSON.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
HostValue
|
The value with every list read as a tuple, which is how the runtime carries a tensor. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the value is |
Source code in src/quivers/qiec/entries.py
render_entry
¶
render_entry(entry: EntryPoint) -> str
Render an entry point as one signature line.
| PARAMETER | DESCRIPTION |
|---|---|
entry
|
The entry.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
|