Skip to content

Install dependencies the way Slicer expects, fix the failing self-test, add a real icon - #3

Merged
MarkDanielArndt merged 20 commits into
MarkDanielArndt:mainfrom
JonaRichter:feature/issue-102-catalog-release-polish
Jul 28, 2026
Merged

Install dependencies the way Slicer expects, fix the failing self-test, add a real icon#3
MarkDanielArndt merged 20 commits into
MarkDanielArndt:mainfrom
JonaRichter:feature/issue-102-catalog-release-polish

Conversation

@JonaRichter

Copy link
Copy Markdown
Contributor

This addresses the feedback from the extension catalog review, fixes the self-test that is
currently failing on the build dashboard, and replaces the placeholder icon.

One small follow-up is needed after merging — a one-line edit to the catalog entry,
because this changes EXTENSION_DEPENDS. Exact instructions at the end of this description.

Dependency installation

The review raised two points: use slicer.util.pip_install instead of a custom installer,
and obtain PyTorch from the PyTorch extension instead of installing it directly.

  • The custom _pip_install — a subprocess.Popen with a manual poll loop plus a hand-built
    progress dialog, roughly 120 lines — is removed. slicer.util.pip_install provides both.
  • The hard-coded CPU wheel index is gone. Torch comes from the PyTorch extension through
    PyTorchUtils, so the build matching the user's hardware is selected. If that extension is
    missing it is installed first and the required restart is communicated.
  • EXTENSION_DEPENDS is now PyTorch instead of NA.
  • All remaining packages are installed in a single pip invocation. Installing them one at
    a time let pip resolve each in isolation, so a later package could pull in a dependency
    that broke an earlier one: scikit-image drags in tifffile, whose current release requires
    numpy>=2.1, which replaced the numpy 1.x that the macOS torch build needs. Handing pip
    the whole set at once lets it pick versions that fit together.
  • On macOS the numpy cap travels in that same invocation, because the newest torch build
    available there is compiled against the NumPy 1 C API. On Linux and Windows numpy is left
    untouched. This matches how other PyTorch-based extensions handle the same platform limit.

Build dashboard

Testing/CMakeLists.txt passed a relative script path to slicer_add_python_unittest. That
macro derives the directory it puts on sys.path from the script path and only falls back to
CMAKE_CURRENT_SOURCE_DIR when that directory comes out empty — a relative Python/ is not
empty, so the fallback never fired and the test module could not be imported. It now passes an
absolute path.

The failure was retrieved from the dashboard and the path derivation reproduced with CMake
directly, so the cause is established. Whether the eight test methods then pass can only be
confirmed by the nightly build after this is merged.

First-use experience

Dependencies were installed when the module was opened. Now nothing happens on open, and each
action installs only what it needs:

Action Packages
Load images OpenCV
Auto-detect scale bar OpenCV, pytesseract
Export to Excel openpyxl
Run analysis everything, including torch

Exporting a result table no longer offers a two-gigabyte torch install. A notice above the Run
button reports outstanding packages so the user learns about a pending install before loading
images and setting parameters.

A restart is now only required when it is genuinely needed. A package that was missing a moment
ago was never imported in this session and is usable immediately, so the action that triggered
the install simply continues. Only a replaced numpy — the macOS torch case — forces a restart.

The hand-built setup dialog and the custom restart dialog are replaced by
slicer.util.confirmOkCancelDisplay, with the package list in the dialog's detail area.
Analysis errors are reported the same way: the message names the affected files and the full
text including tracebacks sits behind "Details", so the Python console is no longer needed to
find out why an image failed.

Loading images ran on the main thread without yielding to the event loop, freezing the
application until the last file was read. It now hands control back between images, so the
window stays usable and thumbnails appear one by one. The button that started the load reports
progress and doubles as Cancel while the load runs; cancelling keeps the thumbnails already
read and leaves the images queued, since the analysis reads the files itself.

Icon

The 128×128 placeholder is replaced by a 512×512 icon of a zebrafish larva with the curved
body path and the straight-line distance whose ratio the extension reports.

Verification

Automated: 508 tests pass.

Manual, in Slicer 5.13 on macOS: installation from a clean state, per-action package
selection, the restart behaviour, a full analysis run with plausible measurements, error
reporting for a corrupt image, and loading a large folder including cancelling it midway.

Not verified: the self-test fix, which needs a dashboard build. No Windows build has appeared
on the dashboard so far, independently of this change.

Follow-up after merging: one line in the catalog entry

EXTENSION_DEPENDS in the top-level CMakeLists.txt changes from NA to PyTorch. Tier 1
requires the catalog entry to stay consistent with it, so build_dependencies has to name
PyTorch as well. The catalog lives in a different repository, so this cannot happen
automatically — it needs a separate pull request there, after this one is merged.

The whole change is one line in ZebrafishEmbryoAnalyzer.json:

-  "build_dependencies": [],
+  "build_dependencies": ["PyTorch"],

For reference, the file currently reads:

{
  "$schema": "https://raw.githubusercontent.com/Slicer/Slicer/main/Schemas/slicer-extension-catalog-entry-schema-v1.0.1.json#",
  "category": "Analysis",
  "scm_url": "https://github.com/MarkDanielArndt/SlicerZebrafishEmbryoAnalyzer.git",
  "scm_revision": "main",
  "scm_type": "git",
  "build_dependencies": [],
  "build_subdirectory": ".",
  "enabled": true,
  "tier": 1
}

Quickest way, entirely in the browser and taking about a minute:

  1. Open ZebrafishEmbryoAnalyzer.json in the extension catalog repository
  2. Click the pencil icon — GitHub forks the repository automatically
  3. Change line 7 as shown above
  4. "Commit changes…", suggested message: Add PyTorch build dependency for ZebrafishEmbryoAnalyzer
  5. "Propose changes", then "Create pull request"

Nothing else in the entry changes. scm_revision is a branch name, so every other change in
this pull request reaches the build without any catalog edit at all.

Drops the redundant queue list (already visible in the Gallery once loaded),
moves Model and Scale bar ahead of Analysis to match the actual workflow
order, expands the Model accordion by default, and hides the confidence
threshold checkbox/slider (ported from the equivalent dev-branch change,
issue #79 — the widgets stay wired into settings sync, just not shown).
@MarkDanielArndt
MarkDanielArndt merged commit 254e730 into MarkDanielArndt:main Jul 28, 2026
6 checks passed
@JonaRichter
JonaRichter deleted the feature/issue-102-catalog-release-polish branch July 29, 2026 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants