MiniApp API¶
The reference for wfMiniAPI.api and the report MiniApp returns, generated from the
code. For how to use these in a script, see Use MiniApp; for the report's
fields, see Telemetry.
Async context manager that records a workflow run and verifies its telemetry.
On entry it checks that telemetry is the manager flow emits into and can be
verified, and records the run. On exit (normal, exception, cancel or signal) it
only records how the run ended; it awaits nothing and shuts nothing down. After
the script has shut the engine down and stopped telemetry, verify() checks the
checkpoint and sets report.
composition is what the run is made of beyond this engine's tasks: its
configuration, the other engines it hands out as parts, its components and its
checks. The methods below declare it; telemetry records and verifies it.
report
property
¶
The verified telemetry report, set by verify().
part(name)
¶
Hand another engine of this run a reference to report into it.
Pass the reference to that engine's MiniApp(flow, telemetry, part_of=ref), in
this process or another. This run's verify() then requires that part's report:
a part handed out that never reports makes the run's telemetry incomplete. Call it
inside async with app.
component(name, files, *, verify)
¶
Register a component's files and its verifier.
verify is "module:function" or a callable taking the files' path and
returning a ComponentReport or a bool. It runs in verify(); named by
import path, it also runs when the run is verified again offline.
check(name, *, verify=None, ok=None, detail=None)
¶
Register a check on the run's results.
Either verify, "module:function" or a callable taking a Run and
returning a bool or (bool, detail), run in verify() after the parts and
components; or ok (and detail), a result computed in the run. Failed
checks set report.checks_pass to False; they never make telemetry incomplete.
parameters(values)
¶
Record the run's configuration: in the composition, in the checkpoint (a
wfminiapi.Parameters event, once telemetry runs) and in the report. Also
MiniApp(..., parameters=values). A later call replaces the values.
verify()
¶
Verify the telemetry checkpoint and set report; never raises.
Call it after flow.shutdown() and telemetry.stop(). It also writes
<checkpoint>/<session>.wfminiapi.report.json. Calling it again recomputes it.
session_id
instance-attribute
¶
checkpoint
instance-attribute
¶
telemetry_complete
instance-attribute
¶
ended_by = ''
class-attribute
instance-attribute
¶
tasks = field(default_factory=TaskCounts)
class-attribute
instance-attribute
¶
events = field(default_factory=dict)
class-attribute
instance-attribute
¶
reasons = ()
class-attribute
instance-attribute
¶
notes = ()
class-attribute
instance-attribute
¶
run_id = ''
class-attribute
instance-attribute
¶
part = ''
class-attribute
instance-attribute
¶
parameters = field(default_factory=dict)
class-attribute
instance-attribute
¶
completed_by_executable = field(default_factory=dict)
class-attribute
instance-attribute
¶
parts = field(default_factory=dict)
class-attribute
instance-attribute
¶
components = field(default_factory=dict)
class-attribute
instance-attribute
¶
checks = ()
class-attribute
instance-attribute
¶
checks_pass = True
class-attribute
instance-attribute
¶
exit_hint
property
¶
0 if telemetry is complete and the checks pass, 3 if telemetry is incomplete, 4 if it is complete but a check failed. wfMiniAPI never exits by itself.
__init__(session_id, checkpoint, telemetry_complete, ended_by='', tasks=TaskCounts(), events=dict(), reasons=(), notes=(), run_id='', part='', parameters=dict(), completed_by_executable=dict(), parts=dict(), components=dict(), checks=(), checks_pass=True)
¶
to_dict()
¶
created = 0
class-attribute
instance-attribute
¶
completed = 0
class-attribute
instance-attribute
¶
failed = 0
class-attribute
instance-attribute
¶
canceled = 0
class-attribute
instance-attribute
¶
abandoned = 0
class-attribute
instance-attribute
¶
not_submitted = 0
class-attribute
instance-attribute
¶
__init__(created=0, completed=0, failed=0, canceled=0, abandoned=0, not_submitted=0)
¶
What a run is made of: its configuration, its parts, its components, its checks.
Its MiniApp fills it, refusing at the call what the run could not verify. A run of
one engine with none of these declares nothing (declared is False) and sees no change.
declared
property
¶
True once the run declares more than its one engine's tasks.
What another engine of the run needs to report into it. Picklable: pass it to a process or a task that builds that engine. Give each engine its own part.
A component of the run that is not an engine: where its records are, and the verifier that judges them.
Verify a run again from its files: the manifest in directory (the run engine's
checkpoint directory), its checkpoint, its parts' reports, its components' files.
session picks the run when the directory holds more than one.