spacr.qt.screens.report

Report — the Tools module that turns a run folder into one shareable file.

The screen is deliberately thin. Everything it knows about a run folder it learns from spacr.report, which is headless, read-only and testable without Qt. This file is the part that has to be a GUI: pick a folder, say what was found and — just as loudly — what was not, choose a format, and write the file off the GUI thread.

Two decisions are worth stating, because both are visible to the user:

  • Missing sections are shown, greyed, with the reason. The section list is not “here is what you will get”; it is “here is what exists and here is what does not”. A run with no segmentation QC shows Segmentation QC — not available before you generate anything, so you find out before your collaborator does.

  • No modal dialogs, ever. Every failure — a folder that is not a folder, an unwritable output path, a crash inside collection — lands in the inline status label and in ReportScreen.last_error. A QMessageBox hangs a headless run (it did, in MakeMasksScreen), and this screen is exercised headlessly.

Collection walks the folder and base64-encodes figures, which is slow enough on a full plate to freeze the window, so both scanning and generating go through spacr.qt.bridge.make_thread() like every other spaCR job.

Classes

ReportScreen

Build a shareable HTML/PDF report from a finished run folder.

Module Contents

class spacr.qt.screens.report.ReportScreen(parent=None, threaded: bool = True)[source]

Bases: PySide6.QtWidgets.QWidget

Build a shareable HTML/PDF report from a finished run folder.

Parameters:
  • parent – Qt parent.

  • threaded – run scanning and generation on a worker thread (the default). Tests pass False for deterministic, synchronous behaviour.

Variables:

last_error – text of the most recent failure, "" when the last operation succeeded. Errors are only ever reported here and in the inline status label — never in a modal dialog.

Build the screen and arm its drop zone.

Parameters:
  • parent – parent widget, or None.

  • threaded – scan and generate on a worker thread. Set False in tests so scan finishes before it returns.

active_jobs() → int[source]

How many worker threads are still winding down.

figure_cap() → int[source]

The figure cap currently selected.

found_sections() → List[str][source]

Keys of the sections the last scan found.

generate() → bool[source]

Write the report to the path in the output box.

Re-collects rather than reusing the scan, so the file reflects the folder as it is now and the figure cap as it is now.

Returns:

True when the job was started (or, unthreaded, ran).

is_busy() → bool[source]

True while a scan or a generate is in flight.

missing_sections() → List[str][source]

Keys of the sections the last scan did not find.

open_output() → bool[source]

Hand the newest written report to the desktop’s default opener.

Returns:

True when there was something to open.

output_format() → str[source]

"html", "pdf" or "both".

scan() → bool[source]

Collect the report for the folder in the source box.

Nothing is written; this only discovers what a report would contain, so the section list can be shown before the user commits.

Returns:

True when the job was started (or, unthreaded, ran).

set_format(fmt: str) → None[source]

Select an output format by its build_report key.

Parameters:

fmt – a key from FORMATS ("html", "pdf" or "both"); an unknown key leaves the current choice unchanged.

set_output(path: str) → None[source]

Put path in the output box.

Parameters:

path – output location shown in the output box; None or an empty value clears it.

set_source(path: str) → None[source]

Put path in the source box without scanning.

Parameters:

path – run folder shown in the source box; None or an empty value clears it.

status_text() → str[source]

The inline status line, for tests and for the tutorial engine.

property report: spacr.report.Report | None[source]

The most recently collected spacr.report.Report.

property written: List[str][source]

Paths written by the last successful generate.

Nested helpers

ReportScreen._deposit_zenodo._job()

Stage and upload the deposit; a failure comes back as text.

spacr/qt/screens/report.py:781

ReportScreen._run_job._job(payload: Dict[str, Any]) → None

Call the wrapped function, stashing its result in the payload.

spacr/qt/screens/report.py:836

ReportScreen._write_archive._job()

Write the package, then check it against the templates.

spacr/qt/screens/report.py:632

ReportScreen._zenodo_dialog._placeholder() → None

Say whether a token is already kept for this Zenodo.

spacr/qt/screens/report.py:712