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

MethodsExportScreen

Build the run digest; draft the two sections; show the number check.

Functions

make_methods_export_screen(→ PySide6.QtWidgets.QWidget)

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.QWidget

Build 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 – False runs 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 False in tests so it finishes before the call returns.

active_jobs() → int[source]

How many worker threads are still winding down.

build() → None[source]

Assemble the digest from whichever sources were named.

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.

digest() → Dict[str, Any] | None[source]

The digest currently built, or None.

draft() → Any[source]

The draft currently shown, or None.

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.

generate() → None[source]

Ask the configured AI provider for the two sections.

is_busy() → bool[source]

True while a digest or a draft is still being produced.

prompt() → str[source]

The exact user message the model would be sent, or "".

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.ManuscriptDraft just produced. When ok, its provider and the counts of checked numbers are quoted; otherwise its problems are listed one per line.

sources() → Dict[str, str][source]

The four source paths as the fields currently stand.

text() → str[source]

Both sections as they currently stand, ready to paste.

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.