spacr.qt.widgets.measurements_example

One “Load test data…” button for every screen that reads a measurements DB.

The Annotate example (einarolafsson/spacr-example-annotate) is a real plate: measurements/measurements.db with its cell, cytoplasm, nucleus and pathogen tables, and the 2,341 crops under data/ it indexes. Annotate and Classify already fetch it into the shared example plate folder (spacr.example_archives.example_plate_folder()). Every other screen that opens a measurements database can be shown working on the same plate, so this module fetches it once and hands it to whichever screen asked.

ONE HELPER, NOT ONE COPY PER SCREEN. The cached-or-download decision, the button’s busy state and the failure message are the same for Plate Viewer, Tabulate, Graph Builder and the rest; what differs is only which field is filled and which method opens it. So a screen passes that one difference as a callback and nothing else.

THE DOWNLOAD IS THE EXISTING ONE. Nothing new is published: the archive, the worker and the progress dialog are spacr.qt.hf_download.download_annotate_example(), the same call Classify’s button makes, and a plate already unpacked by any of them is reused without touching the network.

Functions

example_measurements_db(→ pathlib.Path)

The example plate's measurements/measurements.db, present or not.

example_measurements_folder(→ pathlib.Path)

The shared example plate folder the Annotate example unpacks into.

install_test_data_button(screen, layout, apply, *[, ...])

Add the "Load test data…" button to layout and wire it to apply.

load_test_data(→ Dict[str, str])

Reuse or fetch the example plate, then hand it to the screen.

Module Contents

spacr.qt.widgets.measurements_example.example_measurements_db() → pathlib.Path[source]

The example plate’s measurements/measurements.db, present or not.

spacr.qt.widgets.measurements_example.example_measurements_folder() → pathlib.Path[source]

The shared example plate folder the Annotate example unpacks into.

spacr.qt.widgets.measurements_example.install_test_data_button(screen, layout, apply: Callable[[pathlib.Path, pathlib.Path], Any], *, say: Callable[[str], Any] | None = None, index: int | None = None)[source]

Add the “Load test data…” button to layout and wire it to apply.

Parameters:
  • screen – the screen the button belongs to. The button, the callback and the reporter are kept on it, so load_test_data() can be called with the screen alone – which is what a test does.

  • layout – the box layout the button goes into, normally the row that holds the screen’s own source field.

  • apply – called as apply(folder, database) once the example is on disk: the plate folder and its measurements/measurements.db. It fills the screen’s source field and opens it.

  • say – where a failed download is reported, usually the screen’s status label’s setText. Logged when omitted.

  • index – position in layout; appended when omitted.

Returns:

the button.

spacr.qt.widgets.measurements_example.load_test_data(screen, *, ask=None) → Dict[str, str][source]

Reuse or fetch the example plate, then hand it to the screen.

Parameters:
Returns:

{"folder": ..., "db": ...} when the plate was handed over before returning – always, when it was already cached – and an empty mapping while a download is still running or after it failed.

Nested helpers

load_test_data._done(result, error) → None

Restore the button, then hand over the plate or say why not.

spacr/qt/widgets/measurements_example.py:130