PipelineReport¶
PipelineReport
¶
Bases: BaseModel
Batch-level container with ordered batch steps and per-file reports.
Designed to be JSON-serializable (Pydantic v2) and UI-friendly. Maintains
a progress banner (stage, percent, message, updated_at),
an ordered list of batch-level
StepReport items, and a list of
FileReport records.
Attributes:
-
label(str) –Human-friendly batch label (e.g., project/run name).
-
kind({'validation', 'process', 'test'}) –Category of run for UI filtering and routing.
-
stage(str) –Short machine-friendly stage label for the progress banner.
-
percent(int) –Overall progress
0..100(informational; not enforced). -
message(str) –Human-readable progress note for dashboards.
-
updated_at(datetime) –Last update timestamp (UTC). Defaults to
nowon construction. -
report_version(str) –Schema version emitted to artifacts.
-
steps(list[StepReport]) –Ordered sequence of batch-level steps (rare compared to file steps, but useful for pre/post stages like discovery/validation).
-
files(list[FileReport]) –Per-file timelines collected in this batch.
-
output_path(Path or None) –Default output path for
save. -
status(Status) –Aggregated lifecycle status over all batch steps and file reports (computed). See [
Status][pipeline_watcher.core.Status] andPipelineReport.statusfor roll-up rules.
Notes
- The model is append-only for auditability.
- Use
set_progressto update the banner; it stampsupdated_at.
Methods:
-
add_completed_step–Construct, finalize, append, and return a batch-level step. Ensures id uniqueness.
-
append_file–Finalize and append a :class:
FileReport; updateupdated_at. -
append_step–Finalize and append a batch-level step; update
updated_at. -
file_processed–Whether a file has reached a terminal/finished state.
-
file_seen–Whether a file with the given key appears in the report at all.
-
files_for–Return all file reports matching an id/name/path/basename.
-
get_file–Return the first matching file report or
Noneif absent. -
iter_steps–Iterate over batch-level steps, optionally filtering by status.
-
last_step–Return the last batch-level step or
Noneif empty. -
recompute_overall_from_steps–Recalculate overall
percentfrom batch-level steps. -
save– -
set_progress–Update the progress banner and timestamp.
-
table_rows_for_files_map–Produce Django/Jinja-friendly summary rows for a files mapping.
-
unseen_expected–Return expected filenames/ids/paths that are not present.
kind
class-attribute
instance-attribute
¶
status
property
¶
Aggregated lifecycle status over all batch steps and file reports.
Rules (in priority order)
FAILED→ if any step or file has failed.RUNNING→ if none failed but at least one is running.SKIPPED→ if there is at least one unit and all are skipped.SUCCEEDED→ if all units are terminal, none failed, and at least one succeeded.PENDING→ otherwise (e.g., no units, or only pending units).
updated_at
class-attribute
instance-attribute
¶
add_completed_step
¶
add_completed_step(label: str, *, id: str | None = None) -> StepReport
Construct, finalize, append, and return a batch-level step. Ensures id uniqueness.
Parameters:
Returns:
-
StepReport–The created (and ended) step.
Source code in src/pipeline_watcher/core.py
append_file
¶
append_file(fr: FileReport) -> 'PipelineReport'
Finalize and append a :class:FileReport; update updated_at.
Parameters:
-
(fr¶FileReport) –File report to finalize via :meth:
FileReport.endand append.
Returns:
-
PipelineReport–Self (chainable).
Source code in src/pipeline_watcher/core.py
append_step
¶
append_step(step: StepReport) -> 'PipelineReport'
Finalize and append a batch-level step; update updated_at.
Parameters:
-
(step¶StepReport) –Step to finalize via :meth:
StepReport.endand append.
Returns:
-
PipelineReport–Self (chainable).
Source code in src/pipeline_watcher/core.py
file_processed
¶
file_processed(key, *, require_success: bool = False) -> bool
Whether a file has reached a terminal/finished state.
By default, any terminal status counts (SUCCESS, FAILED,
SKIPPED). When require_success=True, only SUCCESS counts.
Parameters:
-
(key¶Any) –File identifier/name/path/basename.
-
(require_success¶bool, default:False) –If
True, requireSUCCESSonly.
Returns:
-
bool–Trueif processed under the selected rule.
Notes
As a additional heuristic, a file is considered processed if it
has finished_at set or percent == 100.
Source code in src/pipeline_watcher/core.py
file_seen
¶
file_seen(key) -> bool
Whether a file with the given key appears in the report at all.
Parameters:
-
(key¶Any) –
Returns:
-
bool–
files_for
¶
files_for(key) -> list['FileReport']
Return all file reports matching an id/name/path/basename.
Matching is case- and whitespace-insensitive and accepts identifiers, filenames, full paths, and basenames.
Parameters:
-
(key¶Any) –A value convertible to a normalized comparison key.
Returns:
-
list[FileReport]–All matching file reports (may be empty).
Source code in src/pipeline_watcher/core.py
get_file
¶
get_file(key) -> 'FileReport | None'
Return the first matching file report or None if absent.
Parameters:
-
(key¶Any) –See :meth:
files_for.
Returns:
-
FileReport or None–
Source code in src/pipeline_watcher/core.py
iter_steps
¶
iter_steps(*, status: Status | None = None) -> Iterable[StepReport]
Iterate over batch-level steps, optionally filtering by status.
Parameters:
-
(status¶StepStatus or None, default:None) –If provided, only yield steps whose status equals
status.
Yields:
-
StepReport–Matching steps in append order.
Source code in src/pipeline_watcher/core.py
last_step
¶
last_step() -> StepReport | None
recompute_overall_from_steps
¶
Recalculate overall percent from batch-level steps.
Sets the banner percent to the arithmetic mean of child step
percents and preserves the current stage/message (or
uses defaults if unset). Does nothing if there are no steps.
Source code in src/pipeline_watcher/core.py
save
¶
save(path: Path | str | None = None, *, ensure_dir: bool = True, indent: int = 2, encoding: str = 'utf-8') -> None
Source code in src/pipeline_watcher/core.py
set_progress
¶
Update the progress banner and timestamp.
Parameters:
-
(stage¶str) –Short stage label (e.g.,
"discover"). -
(percent¶int) –Clamped to
0..100. -
(message¶str, default:"") –UI-visible note.
Examples:
Source code in src/pipeline_watcher/core.py
table_rows_for_files_map
¶
table_rows_for_files_map(expected: Mapping[str, Any]) -> list[dict]
Produce Django/Jinja-friendly summary rows for a files mapping.
Accepts a mapping of {filename_or_id_or_path: other_properties}
and returns table rows with normalized status fields for templating.
Parameters:
-
(expected¶Mapping[str, Any]) –Keys are identifiers/names/paths; values are attached as
other.
Returns:
-
list[dict]–Rows with fields: -
filename: str -seen: bool -status: str ("SUCCESS"|"FAILED"|"SKIPPED"|"RUNNING"|"PENDING"|"MISSING") -percent: int or None -flagged_human_review: bool -human_review_reason: str -file_id: str or None -path: str or None -other: Any (value fromexpected)
Source code in src/pipeline_watcher/core.py
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 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 | |
unseen_expected
¶
unseen_expected(expected_iterable) -> list[str]
Return expected filenames/ids/paths that are not present.
Parameters:
-
(expected_iterable¶Iterable[Any]) –Filenames/ids/paths expected to appear in :attr:
files.
Returns:
-
list[str]–Items from
expected_iterablethat were not matched.