Skip to content

Commit

Permalink
fix: Fix plugin discovery in bundle to register them in napari viewer (
Browse files Browse the repository at this point in the history
…#1175)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit


- **New Features**
- Enhanced the plugin registration process to dynamically discover and
register plugins from specified directories.
	- Improved extensibility and maintainability of the plugin system.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
Czaki authored Aug 9, 2024
1 parent 45d0f78 commit b824e34
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions package/PartSeg/plugins/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import contextlib
import importlib
import logging
import os
import pkgutil
import sys
import typing
from pathlib import Path

import PartSegCore.plugins

Expand All @@ -17,6 +19,12 @@ def register_napari_plugins(): # pragma: no cover
npe2.PluginManager.instance().register(
os.path.join(os.path.dirname(os.path.dirname(PartSeg.__file__)), "napari.yaml")
)
base_path = Path(__file__).parent.parent.parent / "plugins"
for el in base_path.glob("*/napari.yaml"):
try:
npe2.PluginManager.instance().register(str(el))
except Exception: # noqa: PERF203
logging.exception("Failed to register %s", el)


def get_plugins():
Expand Down

0 comments on commit b824e34

Please sign in to comment.