spacr.qt.hf_download¶
Hugging Face dataset downloader with a Qt progress dialog.
Wraps the two demo repositories (einarolafsson/toxo_mito for images
and einarolafsson/spacr_settings for the accompanying settings
pack) into a single download_toxo_mito_demo(parent, dest) call
that:
Pops a modal
QProgressDialogwith per-file granularity.Runs the downloads in a QThread so the UI stays responsive.
Reports the resulting local paths back via a completion callback.
The classic Tk downloader in spacr.gui_utils uses a queue-
based background thread. This module reimplements the same behaviour
using Qt’s threading + signals so the Qt GUI doesn’t need to spin up
a Tk mainloop just to see download progress.
Classes¶
Outcome of one |
Functions¶
|
Fetch the Annotate/Classify example set, with the shared dialog. |
|
Fetch the chosen pieces of the published screen. |
|
Fetch Measure's example plate, with the same dialog as the Mask demo. |
|
Kick off the demo download with a modal progress dialog. |
Module Contents¶
- class spacr.qt.hf_download.DownloadResult[source]¶
Outcome of one
download_toxo_mito_demo()call.- Parameters:
dataset_path – local folder holding the downloaded data, as the worker reported it on success.
settings_path – local folder holding the settings files that came with the download.
- spacr.qt.hf_download.download_annotate_example(parent, dest: pathlib.Path, on_done: Callable[[DownloadResult | None, str], None]) None[source]¶
Fetch the Annotate/Classify example set, with the shared dialog.
- Parameters:
parent – QWidget that parents the progress dialog and the worker thread.
dest – local directory the example archive is unpacked into; created if missing.
on_done – called with
(result, error_message)when the download ends;resultis aDownloadResulton success andNoneon failure or cancellation.
- spacr.qt.hf_download.download_chosen_screen_data(parent, dest: pathlib.Path, archives, repo: str, on_done) None[source]¶
Fetch the chosen pieces of the published screen.
- Parameters:
parent – QWidget that parents the progress dialog and the worker thread.
dest – local directory every archive is unpacked into; created if missing.
archives – archive file names to fetch from
repo, in order. An empty selection ends the run with “Nothing was selected.” instead of fetching everything.repo – Hugging Face dataset repo id the archives are read from; an empty string keeps the worker’s default.
on_done – called with
(result, error_message)when the download ends;resultis aDownloadResulton success andNoneon failure or cancellation.
- spacr.qt.hf_download.download_measure_example(parent, dest: pathlib.Path, on_done: Callable[[DownloadResult | None, str], None]) None[source]¶
Fetch Measure’s example plate, with the same dialog as the Mask demo.
- Parameters:
parent – any QWidget — the progress dialog parents to this.
dest – local directory that will hold
merged/andsettings/.on_done – called with
(result, error_message);resultisNoneon failure or cancellation.
- spacr.qt.hf_download.download_toxo_mito_demo(parent, dest: pathlib.Path, on_done: Callable[[DownloadResult | None, str], None], *, worker_factory=None, title: str = 'Downloading spaCR test data') None[source]¶
Kick off the demo download with a modal progress dialog.
- Parameters:
parent – any QWidget — the progress dialog parents to this.
dest – local directory that will hold
plate1/andsettings/subfolders.on_done – callback fired on completion or cancellation with
(result, error_message).resultisNoneon failure / cancel; otherwise the two local paths.
Nothing is returned — the callback carries the outcome. Errors and cancellations are non-fatal: they just call
on_donewith aNoneresult and an explanatory string.
Nested helpers¶
- download_chosen_screen_data._factory(where)¶
Build the worker for the chosen archives.
spacr/qt/hf_download.py:723
- download_toxo_mito_demo._stop_before_quitting(_w=worker, _t=thread)¶
Cancel and join the download before the application exits.
The worker and thread are bound as default arguments so this still refers to THIS download if another starts before the quit.
spacr/qt/hf_download.py:875