Skip to content

Allow plugins to add morphometrics subcommands via entry points#58

Merged
bbarad merged 1 commit into
mainfrom
gui-plugin-command
Jun 19, 2026
Merged

Allow plugins to add morphometrics subcommands via entry points#58
bbarad merged 1 commit into
mainfrom
gui-plugin-command

Conversation

@bbarad

@bbarad bbarad commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

What

Lets third-party packages installed in the same environment contribute morphometrics subcommands by advertising a morphometrics.commands entry point. The immediate motivation is the napari GUI (surface-morphometrics-gui#41), which will expose morphometrics gui once it declares the matching entry point — without the pipeline taking a hard dependency on it.

Changes

  • surface_morphometrics/cli.pyLazyGroup now discovers commands from the morphometrics.commands entry-point group:
    • list_commands unions in discovered plugin names.
    • get_command falls back to EntryPoint.load(), wrapping failures in a clean ClickException (e.g. when the plugin is installed but its GUI deps aren't).
    • _short_help resolves plugin help so they render in --help.
    • Discovery reads package metadata only, so morphometrics --help stays fast and never imports napari/Qt. Plugin commands appear under "Other commands".
  • pyproject.toml — adds an optional gui extra pointing at the GUI's git repo (PyPI line left commented for when it's published):
    gui = ["surface-morphometrics-gui @ git+https://github.com/baradlab/surface-morphometrics-gui.git"]

Behavior

State Result
No GUI installed --help and command list unchanged
pip install surface-morphometrics[gui] morphometrics gui appears and launches the GUI
GUI installed but import fails Friendly Error: Could not load the 'gui' command …

Testing

  • Full suite passes (38 passed).
  • Verified end-to-end against a simulated plugin: discovery, listing under "Other commands", invocation, and the load-failure error path.

The GUI-side half (a thin import-light click command + the entry-point declaration) lands separately on surface-morphometrics-gui#41.

🤖 Generated with Claude Code

LazyGroup now discovers commands advertised under the
"morphometrics.commands" entry-point group, so packages installed in the
same environment (e.g. the napari GUI) can contribute subcommands such as
`morphometrics gui` without the pipeline depending on them. Discovery reads
package metadata only, so `morphometrics --help` stays fast; loading a
plugin that fails to import surfaces a clean ClickException.

Adds an optional `gui` extra pointing at the surface-morphometrics-gui git
repo (PyPI line left commented for later).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@bbarad

bbarad commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

@hemanthkapa this is the pipeline side update to allow surface morphometrics GUI to use morphometrics gui

@bbarad bbarad merged commit 78c7a91 into main Jun 19, 2026
2 checks passed
@bbarad bbarad deleted the gui-plugin-command branch June 19, 2026 03:05
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.

1 participant