Skip to content

InspectionResult

Base classes

Name Children Inherits
BaseModel
pydantic.main
!!! abstract "Usage Documentation"

⋔ Inheritance diagram

graph TD
  1032484972["models.InspectionResult"]
  3879467795["main.BaseModel"]
  2751680898["builtins.object"]
  3879467795 --> 1032484972
  2751680898 --> 3879467795

🛈 DocStrings

Bases: BaseModel

Everything framesheet found out about one input.

Source code in src/framesheet/models.py
class InspectionResult(BaseModel):
    """Everything framesheet found out about one input."""

    source: str
    kind: SourceKind
    viewport: tuple[int, int]
    device_scale_factor: float
    canvas: Rect
    """Drawing area in CSS px (the viewBox for SVG documents, the viewport for HTML)."""
    duration: DurationInfo
    times: list[float]
    """Sample times of the contact-sheet tiles in seconds."""
    full_at: float
    images: Images
    findings: list[Finding]
    frames: list[FrameMetrics]
    elements: list[ElementTrack]
    loop: LoopInfo
    console_errors: list[str] = Field(default_factory=list)
    video: VideoInfo | None = None
    """Media facts and per-tile metrics (video inputs only)."""
    marks: Marks | None = None
    """The marks drawn onto the sheet (``--marks``), as given."""

    @property
    def errors(self) -> list[Finding]:
        return [f for f in self.findings if f.severity == "error"]

    @property
    def warnings(self) -> list[Finding]:
        return [f for f in self.findings if f.severity == "warning"]

    def codes(self) -> set[str]:
        """All finding codes, handy for assertions."""
        return {f.code for f in self.findings}

    def summary(self) -> str:
        """Concise multi-line text for humans and agents (what the CLI prints)."""
        w, h = self.viewport
        d = self.duration
        lines = [
            f"framesheet: {self.source} ({self.kind}, {w}x{h} @{self.device_scale_factor:g}x)",
            f"duration: {d.seconds:g}s {d.method}: {d.detail}"
            + (" [looping]" if d.looping else ""),
        ]
        if v := self.video:
            facts = f"{v.container} {v.codec or '?'} {v.width}x{v.height}"
            if v.fps:
                facts += f" {v.fps:g}fps"
            if v.frame_count:
                facts += f", {v.frame_count} frames"
            lines.append(f"video: {facts}; range {v.start:g}-{v.end:g}s, {len(v.samples)} samples")
        busiest = max(self.frames, key=lambda f: f.changed_ratio)
        motion = (
            f"max change {busiest.changed_ratio:.1%} at t={busiest.t:.2f}s"
            if busiest.changed_ratio
            else "no pixel changes"
        )
        lines.append(
            f"frames: {len(self.times)} at t={self.times[0]:.2f}..{self.times[-1]:.2f}s; {motion}"
        )
        if self.loop.checked:
            verdict = "seamless" if self.loop.seamless else "NOT seamless"
            lines.append(f"loop: {verdict} ({self.loop.detail})")
        else:
            lines.append(f"loop: not checked ({self.loop.detail})")
        moving = [e.element for e in self.elements][:8]
        if moving:
            more = f" (+{len(self.elements) - 8} more)" if len(self.elements) > 8 else ""  # noqa: PLR2004
            lines.append(f"animated elements: {', '.join(moving)}{more}")
        counts = {
            s: sum(f.severity == s for f in self.findings) for s in ("error", "warning", "info")
        }
        lines.append(
            f"findings: {counts['error']} error(s), {counts['warning']} warning(s), "
            f"{counts['info']} info"
        )
        tags = {"error": "ERROR", "warning": "WARN ", "info": "INFO "}
        lines.extend(
            f"  {tags[f.severity]} [{f.check}] {f.code}: {f.message}" for f in self.findings
        )
        lines += [
            "images:",
            f"  full     {self.images.full}  (t={self.full_at:g}s: layout, text, margins)",
            f"  sheet    {self.images.sheet}  "
            + ("(tiles over the range + timeline)" if self.video else "(motion over one cycle)"),
            f"  heatmap  {self.images.heatmap}  (what moves at all)",
            f"  report   {self.images.report}",
        ]
        return "\n".join(lines)

canvas instance-attribute

canvas: Rect

Drawing area in CSS px (the viewBox for SVG documents, the viewport for HTML).

marks class-attribute instance-attribute

marks: Marks | None = None

The marks drawn onto the sheet (--marks), as given.

times instance-attribute

times: list[float]

Sample times of the contact-sheet tiles in seconds.

video class-attribute instance-attribute

video: VideoInfo | None = None

Media facts and per-tile metrics (video inputs only).

codes

codes() -> set[str]

All finding codes, handy for assertions.

Source code in src/framesheet/models.py
def codes(self) -> set[str]:
    """All finding codes, handy for assertions."""
    return {f.code for f in self.findings}

summary

summary() -> str

Concise multi-line text for humans and agents (what the CLI prints).

Source code in src/framesheet/models.py
def summary(self) -> str:
    """Concise multi-line text for humans and agents (what the CLI prints)."""
    w, h = self.viewport
    d = self.duration
    lines = [
        f"framesheet: {self.source} ({self.kind}, {w}x{h} @{self.device_scale_factor:g}x)",
        f"duration: {d.seconds:g}s {d.method}: {d.detail}"
        + (" [looping]" if d.looping else ""),
    ]
    if v := self.video:
        facts = f"{v.container} {v.codec or '?'} {v.width}x{v.height}"
        if v.fps:
            facts += f" {v.fps:g}fps"
        if v.frame_count:
            facts += f", {v.frame_count} frames"
        lines.append(f"video: {facts}; range {v.start:g}-{v.end:g}s, {len(v.samples)} samples")
    busiest = max(self.frames, key=lambda f: f.changed_ratio)
    motion = (
        f"max change {busiest.changed_ratio:.1%} at t={busiest.t:.2f}s"
        if busiest.changed_ratio
        else "no pixel changes"
    )
    lines.append(
        f"frames: {len(self.times)} at t={self.times[0]:.2f}..{self.times[-1]:.2f}s; {motion}"
    )
    if self.loop.checked:
        verdict = "seamless" if self.loop.seamless else "NOT seamless"
        lines.append(f"loop: {verdict} ({self.loop.detail})")
    else:
        lines.append(f"loop: not checked ({self.loop.detail})")
    moving = [e.element for e in self.elements][:8]
    if moving:
        more = f" (+{len(self.elements) - 8} more)" if len(self.elements) > 8 else ""  # noqa: PLR2004
        lines.append(f"animated elements: {', '.join(moving)}{more}")
    counts = {
        s: sum(f.severity == s for f in self.findings) for s in ("error", "warning", "info")
    }
    lines.append(
        f"findings: {counts['error']} error(s), {counts['warning']} warning(s), "
        f"{counts['info']} info"
    )
    tags = {"error": "ERROR", "warning": "WARN ", "info": "INFO "}
    lines.extend(
        f"  {tags[f.severity]} [{f.check}] {f.code}: {f.message}" for f in self.findings
    )
    lines += [
        "images:",
        f"  full     {self.images.full}  (t={self.full_at:g}s: layout, text, margins)",
        f"  sheet    {self.images.sheet}  "
        + ("(tiles over the range + timeline)" if self.video else "(motion over one cycle)"),
        f"  heatmap  {self.images.heatmap}  (what moves at all)",
        f"  report   {self.images.report}",
    ]
    return "\n".join(lines)

:fa-brands-github: Show source on GitHub