Orchestration (Prefect)¶
varagity.pipeline
¶
Prefect orchestration layer: thin @flow/@task adapters (spec §9–10).
Business logic lives in the plain modules (ingest.loader, retrieval,
generation); this package wraps their stage functions as tracked,
retryable Prefect task runs and exposes the two flows the CLI invokes
directly — no worker or deployment needed (spec §21 #8).
Importing this package exports settings.PREFECT_API_URL into the process
environment before prefect is imported: Prefect captures its
environment at import time, so a later export would be silently ignored and
runs would never reach the compose prefect service. In-container the
variable is already set (env_file) and the export is a no-op; on the
host it carries the .env value into Prefect. With no server reachable,
Prefect 3 falls back to an ephemeral in-process API, so flows still run
without the stack (untracked once the process exits).
GraphBatches
¶
Opaque carrier keeping a parsed archive out of the flow-run record.
Prefect serializes every flow-call parameter into the flow run it
creates (Flow.serialize_parameters), and the server rejects records
over 512 KB — a decade-scale archive of parsed messages serializes to
megabytes, so passing the batches bare fails the build at flow-run
creation, before the engine sees a single document. This box is
deliberately not JSON-encodable (__slots__, no mapping or
iteration protocol), which lands it on the same "<GraphBatches>"
placeholder path the live GraphService handle already rides; the
real objects still reach the flow in-process, untouched.
Attributes:
| Name | Type | Description |
|---|---|---|
batches |
Sequence[MessageBatch]
|
The parsed source files, exactly as given. |
Source code in varagity/pipeline/graph_flow.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
__init__(batches)
¶
Box the batches.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batches
|
Sequence[MessageBatch]
|
Parsed source files bound for the build. |
required |
Source code in varagity/pipeline/graph_flow.py
76 77 78 79 80 81 82 | |
chat_eval_flow(verbose=None)
¶
Run the multi-turn chat-engine eval as a tracked flow run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
verbose
|
int | None
|
Console verbosity (0–2); defaults to
|
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The results document (see |
dict[str, Any]
|
func: |
Source code in varagity/pipeline/eval_flow.py
46 47 48 49 50 51 52 53 54 55 56 57 58 | |
graph_build_flow(service, batches, *, prune_removed=True, verbose=0)
¶
Upsert a parsed message corpus into the graph as a tracked flow run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
service
|
GraphService
|
The process's graph service (holds the session and the single-flight write lock). |
required |
batches
|
GraphBatches
|
The boxed parsed source files (bare sequences would serialize into the flow-run record, which the server caps at 512 KB), guid-merged by the session before rendering. |
required |
prune_removed
|
bool
|
Whether |
True
|
verbose
|
int
|
Validated console verbosity (0–2). |
0
|
Returns:
| Type | Description |
|---|---|
BuildReport
|
What the build did (messages seen, wall clock, caught failures). |
Source code in varagity/pipeline/graph_flow.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
graph_eval_flow(profile='smoke', engines=None, mode=None, skip_build=False, message_target=None, verbose=None)
¶
Run the graph bake-off as a tracked flow run (spec_graphrag §12).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profile
|
str
|
Fixture corpus profile ( |
'smoke'
|
engines
|
Sequence[str] | None
|
Engine names to run; |
None
|
mode
|
str | None
|
Engine query mode override for every question. |
None
|
skip_build
|
bool
|
Reuse the existing corpus and working directories instead of re-indexing. |
False
|
message_target
|
int | None
|
Cap the corpus at this many messages instead of the
profile's own size (a capped run gets its own corpus and working
directories); |
None
|
verbose
|
int | None
|
Console verbosity (0–2); defaults to
|
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The results document (see |
dict[str, Any]
|
func: |
Source code in varagity/pipeline/eval_flow.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |
graph_export_flow(dest, *, on_progress=None, service=None, stale=None)
¶
Export the message graph's working directory into a new bundle as a tracked flow run.
The copy runs under the graph service's write lock, so no build can change a file mid-copy while graph chat keeps answering. Needs no model service and opens no session — only postgres, for the stale flag.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dest
|
Path
|
The exports folder ( |
required |
on_progress
|
GraphExportProgressCallback | None
|
Called with |
None
|
service
|
GraphService | None
|
The graph service whose workdir to copy; the process's own (the graph's single writer) when omitted. |
None
|
stale
|
bool | None
|
The graph-stale flag to record; when omitted, it is read from
|
None
|
Returns:
| Type | Description |
|---|---|
GraphExportReport
|
The published bundle and how long the export took. |
Source code in varagity/pipeline/backup_flow.py
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 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 | |
graph_query_stream_flow(query, service, *, history=(), engine=None, llm=None, mode=None, verbose=None, on_retrieved=None, on_delta, should_abort=None, on_stats=None)
¶
Answer one question from the graph, streaming generation deltas.
:func:varagity.pipeline.query_flow.query_stream_flow's graph twin,
backing POST /api/chat with corpus="graph": condense (the same
task, so a follow-up is rewritten into a standalone search query exactly
as it is for chunk RAG) → graph retrieve → on_retrieved (the SSE
retrieval event: evidence before prose) → the same streaming
generate task over a graph-shaped context.
Generation is deliberately the repo's own, not the engine's (ADR-017's
retrieval-only decision): the answer is grounded in the transcript days
the graph cited, cites them by [SOURCE], and streams.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
The user's question. |
required |
service
|
GraphService
|
The process's graph service. |
required |
history
|
Sequence[Turn]
|
Prior conversation turns, oldest first; the chat engine reads them when preparing the search query. |
()
|
engine
|
ChatEngine | None
|
Chat engine preparing the search query; resolved from
|
None
|
llm
|
LLMClient | None
|
Chat client; resolved via the model registry when omitted. |
None
|
mode
|
str | None
|
Engine query mode; defaults to |
None
|
verbose
|
int | None
|
Console verbosity (0–2); defaults to
|
None
|
on_retrieved
|
Callable[[GraphRetrieval], None] | None
|
Optional hook called with the graph retrieval before generation starts. |
None
|
on_delta
|
Callable[[Kind, str], None]
|
Called with each classified |
required |
should_abort
|
Callable[[], bool] | None
|
Polled between deltas; |
None
|
on_stats
|
Callable[[GenerationTimings], None] | None
|
Called with llama.cpp's cumulative decode counters as they arrive. |
None
|
Returns:
| Type | Description |
|---|---|
StreamedGraphState
|
The completed :class: |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
KeyError
|
If |
GraphUnavailable
|
If the engine's session cannot be opened (the route resolves this before streaming, so reaching it here means the session died mid-turn). |
Source code in varagity/pipeline/graph_flow.py
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 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 | |
graph_restore_flow(bundle, *, run_id, on_progress=None, service=None, settings_store=None)
¶
Restore the message graph from a bundle as a tracked flow run.
Extracts the bundle's workdir beside the live one and swaps it in under the graph service's write and open locks — the previous graph comes back if the restored one won't open — then, and only once all of that succeeded, writes the graph-stale flag the bundle recorded. Needs no model service: only postgres, for the flag.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bundle
|
Path
|
The bundle file (inside |
required |
run_id
|
str
|
The restore run's id (names the staging and previous folders beside the workdir). |
required |
on_progress
|
GraphRestoreProgressCallback | None
|
Called with |
None
|
service
|
GraphService | None
|
The graph service whose workdir to replace; the process's own (the graph's single writer) when omitted. |
None
|
settings_store
|
AppSettingsStore | None
|
Where the stale flag is written; a connection of its own is opened (and closed) when omitted. |
None
|
Returns:
| Type | Description |
|---|---|
GraphRestore
|
What was restored, with the stale flag it left. |
Source code in varagity/pipeline/backup_flow.py
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 | |
ocr_benchmark_flow(verbose=None)
¶
Run the OCR engine benchmark as a tracked flow run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
verbose
|
int | None
|
Console verbosity (0–2); defaults to
|
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The results document (see |
dict[str, Any]
|
func: |
Source code in varagity/pipeline/eval_flow.py
98 99 100 101 102 103 104 105 106 107 108 109 110 | |
query_stream_flow(query, *, history=(), engine=None, retriever=None, llm=None, k=None, verbose=None, on_retrieved=None, on_delta, should_abort=None, on_stats=None)
¶
Answer one question with tracked stages, streaming generation deltas.
:func:query_flow's streaming twin, backing POST /api/chat
(spec_v2 §4.3): identical condense/embed/retrieve staging
(on_retrieved still fires before generation — the SSE retrieval
event), then the streaming generate task hands each classified delta to
on_delta while it runs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
The user's question. |
required |
history
|
Sequence[Turn]
|
Prior conversation turns, oldest first; the chat engine reads them when preparing the search query (empty by default — a first turn, or a history-less caller). |
()
|
engine
|
ChatEngine | None
|
Chat engine preparing the search query; resolved from
|
None
|
retriever
|
Retriever | None
|
Retrieval method; resolved from
|
None
|
llm
|
LLMClient | None
|
Chat client; resolved via the model registry when omitted. |
None
|
k
|
int | None
|
Chunks to retrieve; defaults to |
None
|
verbose
|
int | None
|
Console verbosity (0–2); defaults to
|
None
|
on_retrieved
|
Callable[[list[RetrievedChunk]], None] | None
|
Optional hook called with the retrieved chunks before generation. |
None
|
on_delta
|
Callable[[Kind, str], None]
|
Called with each classified |
required |
should_abort
|
Callable[[], bool] | None
|
Polled between deltas; returning |
None
|
on_stats
|
Callable[[GenerationTimings], None] | None
|
Called with llama.cpp's cumulative decode counters as
they arrive (once per chunk — throttle before rendering);
never fires on a server that reports no |
None
|
Returns:
| Type | Description |
|---|---|
StreamedQueryState
|
The completed :class: |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
KeyError
|
If |
Source code in varagity/pipeline/query_flow.py
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 | |
rag_export_flow(dest, *, ingest_settings, on_progress=None, store=None, stale=None)
¶
Export the chunk corpus into a new bundle as a tracked flow run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dest
|
Path
|
The exports folder ( |
required |
ingest_settings
|
dict[str, str]
|
The reingest-affecting settings at export, in env-string form (the runner reads them before the stale flag, so a settings change racing the export can only make the bundle more conservative about staleness, never less). |
required |
on_progress
|
ProgressCallback | None
|
Called with |
None
|
store
|
ContextualVectorDB | None
|
The vector store to snapshot; a connection of its own is opened (and closed) when omitted. |
None
|
stale
|
bool | None
|
The corpus-stale flag at export; read from |
None
|
Returns:
| Type | Description |
|---|---|
RagExport
|
The published bundle and how long the export took. |
Source code in varagity/pipeline/backup_flow.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
rag_restore_flow(bundle, *, ingest_settings, on_progress=None, store=None, bm25=None, settings_store=None)
¶
Restore the chunk corpus from a bundle as a tracked flow run.
Replaces both stores' corpus with the bundle's rows (re-rooted onto this
stack's DOCS_PATH) and rebuilds the BM25 index from them, then
writes the corpus-stale flag the bundle implies: stale if it was stale
at export, or if its rows were made under other reingest-affecting
settings than this stack's. The flag follows the rows: it is written
once they committed — after a complete restore, and also when only the
BM25 rebuild failed (the rows are the bundle's by then, so the previous
corpus's flag would misdescribe them) — and never after a restore that
rolled back.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bundle
|
Path
|
The bundle file (inside |
required |
ingest_settings
|
Callable[[], Mapping[str, str]]
|
Provider of this stack's reingest-affecting settings, in env-string form — called when the stale flag is written, so a settings change made during the restore is judged against the restored rows too. |
required |
on_progress
|
RestoreProgressCallback | None
|
Called with |
None
|
store
|
ContextualVectorDB | None
|
The vector store to replace; a connection of its own is opened (and closed) when omitted. |
None
|
bm25
|
ElasticsearchBM25 | None
|
The BM25 store to rebuild; one is constructed (and closed) when omitted. |
None
|
settings_store
|
AppSettingsStore | None
|
Where the stale flag is written; a connection of its own is opened (and closed) when omitted. |
None
|
Returns:
| Type | Description |
|---|---|
RagRestore
|
What was restored, with the stale flag it left. |
Source code in varagity/pipeline/backup_flow.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | |
varagity.pipeline.ingest_flow
¶
Prefect ingestion flow: the spec §9 pipeline as tracked task runs.
The flow delegates to :func:varagity.ingest.loader.ingest_corpus — the
single orchestration loop — passing an
:class:~varagity.ingest.loader.IngestStages bundle whose entries are
@task-wrapped equivalents of the loader's stage functions, so every
stage of every file becomes a task run visible at the Prefect UI (:4200)
with state, duration, and logs.
Model/store tasks (contextualize, embed, store) carry retries=2 with
exponential backoff. This is a second retry layer on purpose: the
tenacity retries inside the clients cover transient HTTP failures
within one call, while task retries re-run the whole stage after the client
has given up — e.g. an Elasticsearch restart mid-ingest (both store writes
are idempotent, so a re-run is safe). Discovery/parse/chunk are local and
deterministic; retrying them cannot help, so they carry none.
Result caching is disabled on every task (NO_CACHE): the stages are
side-effecting calls against live services, and their inputs include
unhashable handles (store/client objects, the rich progress display)
that make Prefect's default input-hash cache policy log an error per run —
a cache hit could never be correct here anyway.
The contextualize and store tasks are Prometheus probe points (spec_v2 §6.2): blurb latency per document, plus document/chunk counters at the moment a document actually lands in both stores.
chunk_document_task(raw, *, verbose)
¶
Task wrapper over chunking (spec §9.3).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw
|
RawDocument
|
The parsed document. |
required |
verbose
|
int
|
Validated console verbosity. |
required |
Returns:
| Type | Description |
|---|---|
list[Document]
|
The chunks, provenance seeded into each chunk's metadata. |
Source code in varagity/pipeline/ingest_flow.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | |
contextualize_chunks_task(*, document_text, chunk_texts, llm, file_name, progress, verbose)
¶
Task wrapper over situating-blurb generation (spec §9.4).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
document_text
|
str
|
The parent document's full extracted text. |
required |
chunk_texts
|
list[str]
|
The document's chunk texts, in order. |
required |
llm
|
LLMClient | None
|
Chat client, or |
required |
file_name
|
str
|
Source file name (labels the sub-progress bar). |
required |
progress
|
Progress
|
The run's progress display. |
required |
verbose
|
int
|
Validated console verbosity. |
required |
Returns:
| Type | Description |
|---|---|
list[str | None]
|
One context blurb per chunk (all |
Source code in varagity/pipeline/ingest_flow.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |
discover_documents_task(docs_path, verbose=None)
¶
Task wrapper over corpus discovery (spec §9.1).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
docs_path
|
str
|
Directory to scan. |
required |
verbose
|
int | None
|
Console verbosity (0–2); defaults to
|
None
|
Returns:
| Type | Description |
|---|---|
Buckets
|
The bucketed file paths. |
Source code in varagity/pipeline/ingest_flow.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
embed_chunks_task(texts, *, embeddings, verbose)
¶
Task wrapper over passage embedding (spec §9.5).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
texts
|
list[str]
|
The |
required |
embeddings
|
EmbeddingsClient
|
The embeddings client. |
required |
verbose
|
int
|
Validated console verbosity. |
required |
Returns:
| Type | Description |
|---|---|
list[list[float]]
|
One embedding vector per text, in order. |
Source code in varagity/pipeline/ingest_flow.py
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | |
ingest_flow(docs_path=None, *, store=None, bm25=None, embeddings=None, llm=None, reingest=False, verbose=None, stages=None, on_file=None)
¶
Ingest the corpus with every stage tracked as a Prefect task run.
A thin @flow shell over :func:varagity.ingest.loader.ingest_corpus
(same parameters, same behavior — one file failing is counted, logged,
and visible as a failed task run, never aborting the corpus).
Parameter validation is off because callers (tests, the eval harness) inject duck-typed store/client fakes that pydantic would reject; the flow's inputs are already-validated internals.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
docs_path
|
str | None
|
Corpus directory; defaults to |
None
|
store
|
ContextualVectorDB | None
|
Vector store to write to; constructed from settings (and closed on return) when omitted. |
None
|
bm25
|
ElasticsearchBM25 | None
|
BM25 store to write to; constructed from settings (and closed on return) when omitted. |
None
|
embeddings
|
EmbeddingsClient | None
|
Embeddings client; resolved via the model registry when omitted. |
None
|
llm
|
LLMClient | None
|
Chat client for contextualization; resolved via the model
registry when omitted. Unused when |
None
|
reingest
|
bool
|
Delete each discovered document's previous ingest (from both stores) and re-process it. |
False
|
verbose
|
int | None
|
Console verbosity (0–2); defaults to
|
None
|
stages
|
IngestStages | None
|
Per-stage call seam; this flow's Prefect |
None
|
on_file
|
Callable[[Path, str, int], None] | None
|
Per-file outcome observer, passed through to the loader. |
None
|
Returns:
| Type | Description |
|---|---|
IngestSummary
|
The run's counters. |
Source code in varagity/pipeline/ingest_flow.py
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 | |
parse_document_task(parser, path, *, verbose)
¶
Task wrapper over text extraction (spec §9.2).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parser
|
Parser
|
Parser for the file's discovery bucket. |
required |
path
|
Path
|
The file to parse. |
required |
verbose
|
int
|
Validated console verbosity. |
required |
Returns:
| Type | Description |
|---|---|
RawDocument
|
The extracted document. |
Source code in varagity/pipeline/ingest_flow.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
store_chunks_task(records, vectors, *, store, bm25)
¶
Task wrapper over the dual-store write (spec §9.6).
Both writes share this one task boundary: a partial failure fails the
task loudly and the retry re-runs both writes (idempotent — see
:func:varagity.ingest.loader.store_chunks for the ordering rationale).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
records
|
list[ChunkRecord]
|
The document's chunk records (non-empty). |
required |
vectors
|
list[list[float]]
|
One embedding per record, in order. |
required |
store
|
ContextualVectorDB
|
The vector store. |
required |
bm25
|
ElasticsearchBM25
|
The BM25 store. |
required |
Source code in varagity/pipeline/ingest_flow.py
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |
varagity.pipeline.query_flow
¶
Prefect query flow: the spec §10.1 pipeline as tracked task runs.
Condense → embed → retrieve → generate, each a task run, returning the
spec §10.1 state dict. The condense stage (spec_v3 §4.2) runs the
configured chat engine over the turn and its history to decide the search
query; retrieval sees prepared.search_query while the answer prompt
always gets prepared.original_query — the user's words are never
rewritten for generation. The stage is always in the graph (plan decision
14): under the simple engine it is a no-LLM pass-through, so a¶
tracked run is its only cost. Query embedding — encapsulated inside the
retrievers on the plain path
(:func:varagity.generation.answer.answer_query) — is hoisted into its
own tracked stage here via the retrievers'
:meth:~varagity.retrieval.base.Retriever.encode_query seam, which also
fills the state's query_vector (None for bm25: nothing to
encode).
:func:query_stream_flow is the flow's streaming twin (spec_v2 §4.3): the
same embed/retrieve stages, with generation swapped for a tracked task that
hands deltas to a callback while it runs — the task boundary (and its run
log) is preserved while tokens flow out to the HTTP API's SSE stream.
Unlike the ingestion flow's model/store tasks, these tasks carry no
Prefect-level retries: the query path is interactive, the clients already
retry transient HTTP failures internally (tenacity), and stacking task
retries on top would multiply the wait before a hard failure surfaces at
the prompt. Result caching is disabled (NO_CACHE) for the same reasons
as the ingestion tasks: live-service calls with unhashable client/retriever
inputs.
Both flows are Prometheus probe points (spec_v2 §6.2): they time each stage around its task call, record the retrieved chunks' scores (+ rerank movement), and count the flow's outcome — the streaming flow additionally counts the server-reported token usage it already returns.
StreamedQueryState
¶
Bases: QueryState
The spec §10.1 state dict, extended with streaming outcomes.
Attributes:
| Name | Type | Description |
|---|---|---|
reasoning |
str
|
The captured |
aborted |
bool
|
|
usage |
dict[str, int] | None
|
Server-reported token counts, or |
tokens_per_second |
float | None
|
Final decode throughput reported by llama.cpp,
or |
Source code in varagity/pipeline/query_flow.py
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | |
condense_query_task(engine, query, *, history, llm, verbose)
¶
Task wrapper over the chat engine's query preparation (spec_v3 §4.2).
Always in the graph, whatever the engine (plan decision #14): simple
returns the identity split with no LLM call, so the tracked stage is
~free — and the registry stays a seam rather than a special case.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
engine
|
ChatEngine
|
The chat engine (owns the condense decision). |
required |
query
|
str
|
The user's question, verbatim. |
required |
history
|
Sequence[Turn]
|
Prior conversation turns, oldest first (empty on a first turn, and from history-less callers like the CLI). |
required |
llm
|
LLMClient | None
|
Chat client for engines that condense; |
required |
verbose
|
int
|
Validated console verbosity. |
required |
Returns:
| Type | Description |
|---|---|
PreparedQuery
|
The two-string split downstream stages retrieve and answer with. |
Source code in varagity/pipeline/query_flow.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
embed_query_task(retriever, query, *, verbose)
¶
Task wrapper over query encoding (spec §10.1 step 2).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
retriever
|
Retriever
|
The retrieval method (owns its query encoding). |
required |
query
|
str
|
The user's question, unformatted. |
required |
verbose
|
int
|
Validated console verbosity. |
required |
Returns:
| Type | Description |
|---|---|
list[float] | None
|
The query embedding, or |
list[float] | None
|
queries ( |
Source code in varagity/pipeline/query_flow.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | |
generate_answer_stream_task(query, chunks, *, llm, formatted_context, on_delta, should_abort, on_stats, verbose)
¶
Task wrapper over streamed answer generation (spec_v2 §4.3).
The task boundary is preserved while deltas flow out through
on_delta — the run log records the outcome exactly like the
non-streaming twin. A client-side abort is a deliberate stop, not a
failure: the task completes normally with aborted=True.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
The user's question. |
required |
chunks
|
list[RetrievedChunk]
|
The retrieved chunks grounding the answer. |
required |
llm
|
LLMClient | None
|
Chat client; resolved via the model registry when |
required |
formatted_context
|
str
|
The pre-built context block (spec §10.2). |
required |
on_delta
|
Callable[[Kind, str], None]
|
Called with each classified |
required |
should_abort
|
Callable[[], bool] | None
|
Polled between deltas; |
required |
on_stats
|
Callable[[GenerationTimings], None] | None
|
Called with llama.cpp's decode counters as they arrive. |
required |
verbose
|
int
|
Validated console verbosity. |
required |
Returns:
| Type | Description |
|---|---|
StreamedAnswer
|
The completed :class: |
Source code in varagity/pipeline/query_flow.py
204 205 206 207 208 209 210 211 212 213 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 | |
generate_answer_task(query, chunks, *, llm, formatted_context, verbose)
¶
Task wrapper over grounded answer generation (spec §10.1 steps 5–6).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
The user's question. |
required |
chunks
|
list[RetrievedChunk]
|
The retrieved chunks grounding the answer. |
required |
llm
|
LLMClient | None
|
Chat client; resolved via the model registry when |
required |
formatted_context
|
str
|
The pre-built context block (spec §10.2). |
required |
verbose
|
int
|
Validated console verbosity. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The generated, |
Source code in varagity/pipeline/query_flow.py
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | |
query_flow(query, *, history=(), engine=None, retriever=None, llm=None, k=None, verbose=None, on_retrieved=None)
¶
Answer one question with every stage tracked as a Prefect task run.
The tracked twin of :func:varagity.generation.answer.answer_query
(same state dict); the composition differs in query embedding and chat
engine preparation each running as their own stage. Parameter
validation is off because callers inject duck-typed retriever/client
fakes that pydantic would reject; the flow's inputs are
already-validated internals.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
The user's question. |
required |
history
|
Sequence[Turn]
|
Prior conversation turns, oldest first; the chat engine reads them when preparing the search query (empty by default — a first turn, or a history-less caller). |
()
|
engine
|
ChatEngine | None
|
Chat engine preparing the search query; resolved from
|
None
|
retriever
|
Retriever | None
|
Retrieval method; resolved from
|
None
|
llm
|
LLMClient | None
|
Chat client; resolved via the model registry when omitted. |
None
|
k
|
int | None
|
Chunks to retrieve; defaults to |
None
|
verbose
|
int | None
|
Console verbosity (0–2); defaults to
|
None
|
on_retrieved
|
Callable[[list[RetrievedChunk]], None] | None
|
Optional hook called with the retrieved chunks before generation (the CLI's matches table — spec §10.1 step 4). |
None
|
Returns:
| Type | Description |
|---|---|
QueryState
|
The completed :class: |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
KeyError
|
If |
Source code in varagity/pipeline/query_flow.py
486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 | |
query_stream_flow(query, *, history=(), engine=None, retriever=None, llm=None, k=None, verbose=None, on_retrieved=None, on_delta, should_abort=None, on_stats=None)
¶
Answer one question with tracked stages, streaming generation deltas.
:func:query_flow's streaming twin, backing POST /api/chat
(spec_v2 §4.3): identical condense/embed/retrieve staging
(on_retrieved still fires before generation — the SSE retrieval
event), then the streaming generate task hands each classified delta to
on_delta while it runs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
The user's question. |
required |
history
|
Sequence[Turn]
|
Prior conversation turns, oldest first; the chat engine reads them when preparing the search query (empty by default — a first turn, or a history-less caller). |
()
|
engine
|
ChatEngine | None
|
Chat engine preparing the search query; resolved from
|
None
|
retriever
|
Retriever | None
|
Retrieval method; resolved from
|
None
|
llm
|
LLMClient | None
|
Chat client; resolved via the model registry when omitted. |
None
|
k
|
int | None
|
Chunks to retrieve; defaults to |
None
|
verbose
|
int | None
|
Console verbosity (0–2); defaults to
|
None
|
on_retrieved
|
Callable[[list[RetrievedChunk]], None] | None
|
Optional hook called with the retrieved chunks before generation. |
None
|
on_delta
|
Callable[[Kind, str], None]
|
Called with each classified |
required |
should_abort
|
Callable[[], bool] | None
|
Polled between deltas; returning |
None
|
on_stats
|
Callable[[GenerationTimings], None] | None
|
Called with llama.cpp's cumulative decode counters as
they arrive (once per chunk — throttle before rendering);
never fires on a server that reports no |
None
|
Returns:
| Type | Description |
|---|---|
StreamedQueryState
|
The completed :class: |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
KeyError
|
If |
Source code in varagity/pipeline/query_flow.py
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 | |
retrieve_task(retriever, query, *, k, query_vector, verbose)
¶
Task wrapper over retrieval (spec §10.1 steps 3–4).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
retriever
|
Retriever
|
The retrieval method. |
required |
query
|
str
|
The user's question. |
required |
k
|
int
|
Number of chunks to return. |
required |
query_vector
|
list[float] | None
|
The embed stage's output (reused instead of
re-encoding; ignored by |
required |
verbose
|
int
|
Validated console verbosity. |
required |
Returns:
| Type | Description |
|---|---|
list[RetrievedChunk]
|
The top-k chunks, best first. |
Source code in varagity/pipeline/query_flow.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | |
varagity.pipeline.graph_flow
¶
Prefect graph flows: the build and the query path (spec_graphrag §5.2, §4.3).
The build is a thin @flow shell over
:meth:varagity.graph.service.GraphService.build, for the same reason
:mod:varagity.pipeline.eval_flow is one: the work itself belongs to the
service (which owns the session, the write lock, and the manifest diff),
while Prefect owns the record that a build ran, how long it took, and
whether it failed. A multi-day backfill with no run in the UI would be an
invisible job. Deliberately one flow run per build attempt, not per
document: the engine enqueues documents into its own durable status store
and processes them in batches inside a single call, so per-document task
runs would have to reach inside the engine's pipeline. Per-document progress
is reported instead by the runner's status sampler
(:mod:varagity.api.graph_runner), which reads the engine's own document
counts — tracking and streaming compose, as they do for ingest.
The query path is :func:varagity.pipeline.query_flow.query_stream_flow
with one stage swapped: condense → graph retrieve → stream the answer. The
condense and generation stages are the same tasks the chunk path runs, so
a graph turn inherits the search/answer query split (the original words
always drive the prompt — spec_v3 §4.2), the [SOURCE] citation contract,
<think> splitting, client-abort handling, and token accounting without a
second implementation of any of them. Only the middle stage differs, because
only the middle stage is actually different.
Parameter validation is off (the service is a live handle, not a
serializable payload — and the batches ride in :class:GraphBatches, so the
flow-run record stores a placeholder rather than megabytes of messages) and
there are no Prefect-level retries: an engine that
fails mid-backfill must surface, not silently re-run hours of extraction —
and a re-called build resumes from the durable statuses anyway. The query
path carries none for the query-path reason instead: it is interactive, and
the clients already retry transient HTTP failures themselves.
GraphBatches
¶
Opaque carrier keeping a parsed archive out of the flow-run record.
Prefect serializes every flow-call parameter into the flow run it
creates (Flow.serialize_parameters), and the server rejects records
over 512 KB — a decade-scale archive of parsed messages serializes to
megabytes, so passing the batches bare fails the build at flow-run
creation, before the engine sees a single document. This box is
deliberately not JSON-encodable (__slots__, no mapping or
iteration protocol), which lands it on the same "<GraphBatches>"
placeholder path the live GraphService handle already rides; the
real objects still reach the flow in-process, untouched.
Attributes:
| Name | Type | Description |
|---|---|---|
batches |
Sequence[MessageBatch]
|
The parsed source files, exactly as given. |
Source code in varagity/pipeline/graph_flow.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
__init__(batches)
¶
Box the batches.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batches
|
Sequence[MessageBatch]
|
Parsed source files bound for the build. |
required |
Source code in varagity/pipeline/graph_flow.py
76 77 78 79 80 81 82 | |
StreamedGraphState
¶
Bases: TypedDict
Outcome of one streamed graph turn (the chunk path's state, graph-shaped).
Attributes:
| Name | Type | Description |
|---|---|---|
query |
str
|
The user's question. |
prepared |
PreparedQuery
|
The chat engine's search/answer query split (spec_v3 §4.2) — the same split the chunk path makes. |
retrieval |
GraphRetrieval
|
What the graph returned (the SSE event's payload and the turn's persisted evidence both come from here). |
formatted_context |
str
|
The grounding context the answer was written from. |
answer |
str
|
The generated, |
reasoning |
str
|
The captured |
aborted |
bool
|
|
usage |
dict[str, int] | None
|
Server-reported token counts, or |
tokens_per_second |
float | None
|
Final decode throughput, or |
Source code in varagity/pipeline/graph_flow.py
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | |
graph_build_flow(service, batches, *, prune_removed=True, verbose=0)
¶
Upsert a parsed message corpus into the graph as a tracked flow run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
service
|
GraphService
|
The process's graph service (holds the session and the single-flight write lock). |
required |
batches
|
GraphBatches
|
The boxed parsed source files (bare sequences would serialize into the flow-run record, which the server caps at 512 KB), guid-merged by the session before rendering. |
required |
prune_removed
|
bool
|
Whether |
True
|
verbose
|
int
|
Validated console verbosity (0–2). |
0
|
Returns:
| Type | Description |
|---|---|
BuildReport
|
What the build did (messages seen, wall clock, caught failures). |
Source code in varagity/pipeline/graph_flow.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
graph_query_stream_flow(query, service, *, history=(), engine=None, llm=None, mode=None, verbose=None, on_retrieved=None, on_delta, should_abort=None, on_stats=None)
¶
Answer one question from the graph, streaming generation deltas.
:func:varagity.pipeline.query_flow.query_stream_flow's graph twin,
backing POST /api/chat with corpus="graph": condense (the same
task, so a follow-up is rewritten into a standalone search query exactly
as it is for chunk RAG) → graph retrieve → on_retrieved (the SSE
retrieval event: evidence before prose) → the same streaming
generate task over a graph-shaped context.
Generation is deliberately the repo's own, not the engine's (ADR-017's
retrieval-only decision): the answer is grounded in the transcript days
the graph cited, cites them by [SOURCE], and streams.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
The user's question. |
required |
service
|
GraphService
|
The process's graph service. |
required |
history
|
Sequence[Turn]
|
Prior conversation turns, oldest first; the chat engine reads them when preparing the search query. |
()
|
engine
|
ChatEngine | None
|
Chat engine preparing the search query; resolved from
|
None
|
llm
|
LLMClient | None
|
Chat client; resolved via the model registry when omitted. |
None
|
mode
|
str | None
|
Engine query mode; defaults to |
None
|
verbose
|
int | None
|
Console verbosity (0–2); defaults to
|
None
|
on_retrieved
|
Callable[[GraphRetrieval], None] | None
|
Optional hook called with the graph retrieval before generation starts. |
None
|
on_delta
|
Callable[[Kind, str], None]
|
Called with each classified |
required |
should_abort
|
Callable[[], bool] | None
|
Polled between deltas; |
None
|
on_stats
|
Callable[[GenerationTimings], None] | None
|
Called with llama.cpp's cumulative decode counters as they arrive. |
None
|
Returns:
| Type | Description |
|---|---|
StreamedGraphState
|
The completed :class: |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
KeyError
|
If |
GraphUnavailable
|
If the engine's session cannot be opened (the route resolves this before streaming, so reaching it here means the session died mid-turn). |
Source code in varagity/pipeline/graph_flow.py
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 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 | |
graph_retrieve_task(service, query, *, mode, verbose)
¶
Task wrapper over one graph retrieval (spec_graphrag §4.3).
The chunk path's embed+retrieve stages collapse into this one: the engine owns its own keyword extraction, embedding, and fusion inside a single call, and splitting the wrapper would only invent task boundaries the engine does not actually have.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
service
|
GraphService
|
The process's graph service (reads take no build lock, so this is answered during a backfill). |
required |
query
|
str
|
The search query — the chat engine's |
required |
mode
|
str
|
The engine query mode ( |
required |
verbose
|
int
|
Validated console verbosity. |
required |
Returns:
| Type | Description |
|---|---|
GraphRetrieval
|
The evidence and transcript passages the answer will be grounded in. |
Source code in varagity/pipeline/graph_flow.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | |
varagity.pipeline.backup_flow
¶
Prefect backup flows: export and restore, for both corpora (ADR-019).
Thin @flow shells over :func:varagity.backup.rag.export_rag,
:func:varagity.backup.rag.restore_rag,
:func:varagity.backup.graph.export_graph and
:func:varagity.backup.graph.restore_graph, for the reason the graph build
is one: the work belongs to the backup package (one corpus snapshot and one
all-or-nothing bundle write; one replacing transaction and one index
rebuild; one copy of the graph's workdir under its write lock; one extract
and one swap of it), while Prefect owns the record that a backup ran, how
long it took, and whether it failed. One flow run per operation — not a task
per member or per stage: an export is a single consistent read and a restore
a single transaction (or a single swap), and slicing either into task runs
would invent boundaries they do not have. Per-stage progress travels as the
API runner's progress events instead (tracking and streaming compose, as
they do for ingest and the graph build).
No Prefect-level retries: a failed export leaves no bundle behind (the partial is removed) and a failed restore leaves the previous corpus (its transaction rolled back, or its previous workdir put back) — or, failing in the BM25 rebuild after the commit, says so — so the honest response is to surface the failure and let the user press the button again, not to repeat the work silently. Parameter validation is off because the stores (and the graph service) are live handles, not serializable payloads.
graph_export_flow(dest, *, on_progress=None, service=None, stale=None)
¶
Export the message graph's working directory into a new bundle as a tracked flow run.
The copy runs under the graph service's write lock, so no build can change a file mid-copy while graph chat keeps answering. Needs no model service and opens no session — only postgres, for the stale flag.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dest
|
Path
|
The exports folder ( |
required |
on_progress
|
GraphExportProgressCallback | None
|
Called with |
None
|
service
|
GraphService | None
|
The graph service whose workdir to copy; the process's own (the graph's single writer) when omitted. |
None
|
stale
|
bool | None
|
The graph-stale flag to record; when omitted, it is read from
|
None
|
Returns:
| Type | Description |
|---|---|
GraphExportReport
|
The published bundle and how long the export took. |
Source code in varagity/pipeline/backup_flow.py
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 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 | |
graph_restore_flow(bundle, *, run_id, on_progress=None, service=None, settings_store=None)
¶
Restore the message graph from a bundle as a tracked flow run.
Extracts the bundle's workdir beside the live one and swaps it in under the graph service's write and open locks — the previous graph comes back if the restored one won't open — then, and only once all of that succeeded, writes the graph-stale flag the bundle recorded. Needs no model service: only postgres, for the flag.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bundle
|
Path
|
The bundle file (inside |
required |
run_id
|
str
|
The restore run's id (names the staging and previous folders beside the workdir). |
required |
on_progress
|
GraphRestoreProgressCallback | None
|
Called with |
None
|
service
|
GraphService | None
|
The graph service whose workdir to replace; the process's own (the graph's single writer) when omitted. |
None
|
settings_store
|
AppSettingsStore | None
|
Where the stale flag is written; a connection of its own is opened (and closed) when omitted. |
None
|
Returns:
| Type | Description |
|---|---|
GraphRestore
|
What was restored, with the stale flag it left. |
Source code in varagity/pipeline/backup_flow.py
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 | |
rag_export_flow(dest, *, ingest_settings, on_progress=None, store=None, stale=None)
¶
Export the chunk corpus into a new bundle as a tracked flow run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dest
|
Path
|
The exports folder ( |
required |
ingest_settings
|
dict[str, str]
|
The reingest-affecting settings at export, in env-string form (the runner reads them before the stale flag, so a settings change racing the export can only make the bundle more conservative about staleness, never less). |
required |
on_progress
|
ProgressCallback | None
|
Called with |
None
|
store
|
ContextualVectorDB | None
|
The vector store to snapshot; a connection of its own is opened (and closed) when omitted. |
None
|
stale
|
bool | None
|
The corpus-stale flag at export; read from |
None
|
Returns:
| Type | Description |
|---|---|
RagExport
|
The published bundle and how long the export took. |
Source code in varagity/pipeline/backup_flow.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
rag_restore_flow(bundle, *, ingest_settings, on_progress=None, store=None, bm25=None, settings_store=None)
¶
Restore the chunk corpus from a bundle as a tracked flow run.
Replaces both stores' corpus with the bundle's rows (re-rooted onto this
stack's DOCS_PATH) and rebuilds the BM25 index from them, then
writes the corpus-stale flag the bundle implies: stale if it was stale
at export, or if its rows were made under other reingest-affecting
settings than this stack's. The flag follows the rows: it is written
once they committed — after a complete restore, and also when only the
BM25 rebuild failed (the rows are the bundle's by then, so the previous
corpus's flag would misdescribe them) — and never after a restore that
rolled back.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bundle
|
Path
|
The bundle file (inside |
required |
ingest_settings
|
Callable[[], Mapping[str, str]]
|
Provider of this stack's reingest-affecting settings, in env-string form — called when the stale flag is written, so a settings change made during the restore is judged against the restored rows too. |
required |
on_progress
|
RestoreProgressCallback | None
|
Called with |
None
|
store
|
ContextualVectorDB | None
|
The vector store to replace; a connection of its own is opened (and closed) when omitted. |
None
|
bm25
|
ElasticsearchBM25 | None
|
The BM25 store to rebuild; one is constructed (and closed) when omitted. |
None
|
settings_store
|
AppSettingsStore | None
|
Where the stale flag is written; a connection of its own is opened (and closed) when omitted. |
None
|
Returns:
| Type | Description |
|---|---|
RagRestore
|
What was restored, with the stale flag it left. |
Source code in varagity/pipeline/backup_flow.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | |
varagity.pipeline.eval_flow
¶
Prefect evaluation flows: tracked runs of the spec §16 harness.
Thin @flow shells over :func:varagity.eval.evaluate.run_matrix,
:func:varagity.eval.evaluate.run_chat_eval,
:func:varagity.eval.ocr_benchmark.run_ocr_benchmark and
:func:varagity.eval.graph_eval.run_graph_eval, passing the tracked
:func:~varagity.pipeline.ingest_flow.ingest_flow through the harness's
ingest seam — every eval ingest (two for the matrix, one each for the
chat eval and per OCR engine) is a subflow with per-stage task runs at
the Prefect UI, and the eval run itself is one flow run. The graph
bake-off has no ingest seam to thread: graph engines self-store, so its
flow is a pure tracking shell.
Like the other flows, parameter validation is off (duck-typed internals) and the measurement work carries no Prefect-level retries: an unreachable GPU service or Docker daemon should fail the run loudly, not back off — the clients already retry transient HTTP failures internally.
chat_eval_flow(verbose=None)
¶
Run the multi-turn chat-engine eval as a tracked flow run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
verbose
|
int | None
|
Console verbosity (0–2); defaults to
|
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The results document (see |
dict[str, Any]
|
func: |
Source code in varagity/pipeline/eval_flow.py
46 47 48 49 50 51 52 53 54 55 56 57 58 | |
eval_flow(verbose=None)
¶
Run the 7-configuration retrieval matrix as a tracked flow run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
verbose
|
int | None
|
Console verbosity (0–2); defaults to
|
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The results document (see |
dict[str, Any]
|
func: |
Source code in varagity/pipeline/eval_flow.py
31 32 33 34 35 36 37 38 39 40 41 42 43 | |
graph_eval_flow(profile='smoke', engines=None, mode=None, skip_build=False, message_target=None, verbose=None)
¶
Run the graph bake-off as a tracked flow run (spec_graphrag §12).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profile
|
str
|
Fixture corpus profile ( |
'smoke'
|
engines
|
Sequence[str] | None
|
Engine names to run; |
None
|
mode
|
str | None
|
Engine query mode override for every question. |
None
|
skip_build
|
bool
|
Reuse the existing corpus and working directories instead of re-indexing. |
False
|
message_target
|
int | None
|
Cap the corpus at this many messages instead of the
profile's own size (a capped run gets its own corpus and working
directories); |
None
|
verbose
|
int | None
|
Console verbosity (0–2); defaults to
|
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The results document (see |
dict[str, Any]
|
func: |
Source code in varagity/pipeline/eval_flow.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |
ocr_benchmark_flow(verbose=None)
¶
Run the OCR engine benchmark as a tracked flow run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
verbose
|
int | None
|
Console verbosity (0–2); defaults to
|
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The results document (see |
dict[str, Any]
|
func: |
Source code in varagity/pipeline/eval_flow.py
98 99 100 101 102 103 104 105 106 107 108 109 110 | |