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. AQMessageBoxhangs a headless run (it did, inMakeMasksScreen), 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¶
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.QWidgetBuild 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
Falsefor 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
Falsein tests soscanfinishes before it returns.
- 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).
- open_output() bool[source]¶
Hand the newest written report to the desktop’s default opener.
- Returns:
True when there was something to open.
- 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_reportkey.- 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
pathin 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
pathin the source box without scanning.- Parameters:
path – run folder shown in the source box; None or an empty value clears it.
- property report: spacr.report.Report | None[source]¶
The most recently collected
spacr.report.Report.
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