spacr.qt.screens.methods_export¶
Methods & Results — the two paragraphs, written from the run.
The end of an analysis is a paper, and the part of the paper that is pure transcription — what software, what version, what parameters, what n, what came out — is the part everyone writes from memory three months later and gets subtly wrong. spaCR knows all of it: the run journal has the versions and the timings, the emitted macro has the modules and the parameters the user actually chose, the artifact registry has the provenance, the QC modules have the verdicts, and the hit list has the statistics.
This screen assembles that into a run digest and turns it into two sections: Methods and Results.
The model never sees the data. It sees the digest — numbers already computed — and writes prose around them. Then every number it wrote is checked back against the digest, and a draft carrying a figure that is not there is refused: the panel says which numbers were invented, keeps the model’s text where you can read it, and shows the sections spaCR wrote from the digest instead. The check is visible in the strip under the tabs, because “an AI wrote my methods section” is only acceptable if the reader can see the provenance of every figure in it.
With no AI configured it still works. The deterministic renderer writes both sections from the same digest with no model at all. The panel says which one produced what you are looking at, and what to install if you want the other.
The caveats are not optional. Which QC flags fired, whether illumination
correction ran, the seed, the on_error policy and what it dropped, the
classifier’s held-out metrics — the digest collects them and the Methods
section has to state every one. A draft that drops one is refused for that
alone.
Classes¶
Build the run digest; draft the two sections; show the number check. |
Functions¶
|
Build the screen with nothing filled in. |
Module Contents¶
- class spacr.qt.screens.methods_export.MethodsExportScreen(parent=None, project: str = '', run_dir: str = '', results_folder: str = '', model_path: str = '', threaded: bool = True)[source]¶
Bases:
PySide6.QtWidgets.QWidgetBuild the run digest; draft the two sections; show the number check.
- Parameters:
parent – Qt parent.
project – pre-fill the project field.
run_dir – pre-fill the run-journal folder field.
results_folder – pre-fill the regression results field.
model_path – pre-fill the classifier checkpoint field.
threaded –
Falseruns everything inline, so a test drives the screen synchronously without the behaviour diverging.
- Variables:
last_error – text of the most recent failure,
""when the last operation worked.
Build the methods-export screen.
- Parameters:
parent – parent widget, or
None.project – the project folder to describe.
run_dir – the specific run within it.
results_folder – where the regression results live.
model_path – the trained model to name in the methods text.
threaded – gather the digest on a worker thread. Set
Falsein tests so it finishes before the call returns.
- closeEvent(event) None[source]¶
Drain the worker before the widget goes.
- Parameters:
event – the close event, passed on to the base class once the drafting job has been shut down.
- export(path: str) str[source]¶
Write both sections plus the digest to a Markdown file.
The digest travels WITH the prose, as an appendix. A methods section whose provenance is a separate file is a methods section whose provenance is lost.
- Parameters:
path – where to write.
- Returns:
the path written, or
""when there was nothing to write.
- provenance_message(draft: Any) str[source]¶
The sentence under the tabs: where the prose came from, and why.
Split out from the widget so a test can assert on the wording — this line is the entire user-facing guarantee, and a vague one would be worse than none.
- Parameters:
draft – the
spacr.qt.ai.manuscript.ManuscriptDraftjust produced. Whenok, its provider and the counts of checked numbers are quoted; otherwise itsproblemsare listed one per line.
- spacr.qt.screens.methods_export.make_methods_export_screen(app_key: str | None = None) PySide6.QtWidgets.QWidget[source]¶
Build the screen with nothing filled in.
The constructor for a caller that has no run to point it at. Regression seeds one instead — see
spacr.qt.screens.regression.build_methods_export(), which fills in the project and the results folder that screen is already reading.