Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 5 additions & 16 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,33 +1,22 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
rev: v6.0.0
hooks:
- id: check-docstring-first
- id: end-of-file-fixer
- id: trailing-whitespace
exclude: ^\.napari-hub/.*
- id: check-yaml # checks for correct yaml syntax for github actions ex.
exclude:
(?x)(^src/ndevio/ndev_settings\.yaml$)
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.12.5
rev: v0.14.8
hooks:
- id: ruff
- repo: https://github.com/psf/black
rev: 25.1.0
hooks:
- id: black
- repo: https://github.com/tlambert03/napari-plugin-checks
- id: ruff-check
- id: ruff-format
- repo: https://github.com/napari/napari-plugin-checks
rev: v0.3.0
hooks:
- id: napari-plugin-checks
- repo: https://github.com/ndev-kit/ndev-settings
rev: v0.4.0
hooks:
- id: reset-settings-values
# https://mypy.readthedocs.io/en/stable/
# you may wish to add this as well!
# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: v1.9.0
# hooks:
# - id: mypy
29 changes: 2 additions & 27 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,9 @@ markers = [
[tool.coverage]
report.fail_under = 80

[tool.black]
line-length = 79
target-version = ['py311', 'py312', 'py313']

[tool.ruff]
line-length = 79
format.quote-style = "single"
lint.select = [
"E", "F", "W", #flake8
"UP", # pyupgrade
Expand All @@ -115,31 +112,9 @@ lint.select = [
"SIM", # flake8-simplify
]
lint.ignore = [
"E501", # line too long. let black handle this
"E501", # line too long. handled by formatter
"UP006", "UP007", # type annotation. As using magicgui require runtime type annotation then we disable this.
]

exclude = [
".bzr",
".direnv",
".eggs",
".git",
".mypy_cache",
".pants.d",
".ruff_cache",
".svn",
".tox",
".venv",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"venv",
"*vendored*",
"*_vendor*",
]
fix = true

[tool.pixi.workspace]
Expand Down
12 changes: 6 additions & 6 deletions src/ndevio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
try: # noqa: D104
from ._version import version as __version__
except ImportError:
__version__ = "unknown"
__version__ = 'unknown'

from . import helpers

Expand All @@ -14,15 +14,15 @@

def __getattr__(name: str):
"""Lazily import nImage to speed up package import."""
if name == "nImage":
if name == 'nImage':
from .nimage import nImage

return nImage
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
raise AttributeError(f'module {__name__!r} has no attribute {name!r}')


__all__ = [
"__version__",
"helpers",
"nImage",
'__version__',
'helpers',
'nImage',
]
152 changes: 76 additions & 76 deletions src/ndevio/_bioio_plugin_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,80 +45,80 @@
# 3. Known issues or limitations
BIOIO_PLUGINS = {
# Highest priority: OME formats with excellent metadata preservation
"bioio-ome-zarr": {
"extensions": [".zarr"],
"description": "OME-Zarr files",
"repository": "https://github.com/bioio-devs/bioio-ome-zarr",
"core": True,
'bioio-ome-zarr': {
'extensions': ['.zarr'],
'description': 'OME-Zarr files',
'repository': 'https://github.com/bioio-devs/bioio-ome-zarr',
'core': True,
},
"bioio-ome-tiff": {
"extensions": [".ome.tif", ".ome.tiff", ".tif", ".tiff"],
"description": "OME-TIFF files with valid OME-XML metadata",
"repository": "https://github.com/bioio-devs/bioio-ome-tiff",
"core": True,
'bioio-ome-tiff': {
'extensions': ['.ome.tif', '.ome.tiff', '.tif', '.tiff'],
'description': 'OME-TIFF files with valid OME-XML metadata',
'repository': 'https://github.com/bioio-devs/bioio-ome-tiff',
'core': True,
},
"bioio-ome-tiled-tiff": {
"extensions": [".tiles.ome.tif"],
"description": "Tiled OME-TIFF files",
"repository": "https://github.com/bioio-devs/bioio-ome-tiled-tiff",
'bioio-ome-tiled-tiff': {
'extensions': ['.tiles.ome.tif'],
'description': 'Tiled OME-TIFF files',
'repository': 'https://github.com/bioio-devs/bioio-ome-tiled-tiff',
},
# High priority: Format-specific readers with good metadata support
"bioio-tifffile": {
"extensions": [".tif", ".tiff"],
"description": "TIFF files (including those without OME metadata)",
"repository": "https://github.com/bioio-devs/bioio-tifffile",
"core": True,
'bioio-tifffile': {
'extensions': ['.tif', '.tiff'],
'description': 'TIFF files (including those without OME metadata)',
'repository': 'https://github.com/bioio-devs/bioio-tifffile',
'core': True,
},
"bioio-nd2": {
"extensions": [".nd2"],
"description": "Nikon ND2 files",
"repository": "https://github.com/bioio-devs/bioio-nd2",
'bioio-nd2': {
'extensions': ['.nd2'],
'description': 'Nikon ND2 files',
'repository': 'https://github.com/bioio-devs/bioio-nd2',
},
"bioio-czi": {
"extensions": [".czi"],
"description": "Zeiss CZI files",
"repository": "https://github.com/bioio-devs/bioio-czi",
'bioio-czi': {
'extensions': ['.czi'],
'description': 'Zeiss CZI files',
'repository': 'https://github.com/bioio-devs/bioio-czi',
},
"bioio-lif": {
"extensions": [".lif"],
"description": "Leica LIF files",
"repository": "https://github.com/bioio-devs/bioio-lif",
'bioio-lif': {
'extensions': ['.lif'],
'description': 'Leica LIF files',
'repository': 'https://github.com/bioio-devs/bioio-lif',
},
"bioio-dv": {
"extensions": [".dv", ".r3d"],
"description": "DeltaVision files",
"repository": "https://github.com/bioio-devs/bioio-dv",
'bioio-dv': {
'extensions': ['.dv', '.r3d'],
'description': 'DeltaVision files',
'repository': 'https://github.com/bioio-devs/bioio-dv',
},
"bioio-sldy": {
"extensions": [".sldy", ".dir"],
"description": "3i SlideBook files",
"repository": "https://github.com/bioio-devs/bioio-sldy",
'bioio-sldy': {
'extensions': ['.sldy', '.dir'],
'description': '3i SlideBook files',
'repository': 'https://github.com/bioio-devs/bioio-sldy',
},
# Lower priority: Generic/fallback readers
"bioio-imageio": {
"extensions": [".bmp", ".gif", ".jpg", ".jpeg", ".png"],
"description": "Generic image formats (PNG, JPG, etc.)",
"repository": "https://github.com/bioio-devs/bioio-imageio",
"core": True,
'bioio-imageio': {
'extensions': ['.bmp', '.gif', '.jpg', '.jpeg', '.png'],
'description': 'Generic image formats (PNG, JPG, etc.)',
'repository': 'https://github.com/bioio-devs/bioio-imageio',
'core': True,
},
"bioio-tiff-glob": {
"extensions": [".tiff"],
"description": "TIFF sequences (glob patterns)",
"repository": "https://github.com/bioio-devs/bioio-tiff-glob",
'bioio-tiff-glob': {
'extensions': ['.tiff'],
'description': 'TIFF sequences (glob patterns)',
'repository': 'https://github.com/bioio-devs/bioio-tiff-glob',
},
# Lowest priority: Requires external dependencies (Java)
"bioio-bioformats": {
"extensions": [".oib", ".oif", ".vsi", ".ims", ".lsm", ".stk"],
"description": "Proprietary microscopy formats (requires Java)",
"repository": "https://github.com/bioio-devs/bioio-bioformats",
"note": "Requires Java Runtime Environment",
'bioio-bioformats': {
'extensions': ['.oib', '.oif', '.vsi', '.ims', '.lsm', '.stk'],
'description': 'Proprietary microscopy formats (requires Java)',
'repository': 'https://github.com/bioio-devs/bioio-bioformats',
'note': 'Requires Java Runtime Environment',
},
}

# Map extensions to plugin names for quick lookup
_EXTENSION_TO_PLUGIN = {}
for plugin_name, info in BIOIO_PLUGINS.items():
for ext in info["extensions"]:
for ext in info['extensions']:
if ext not in _EXTENSION_TO_PLUGIN:
_EXTENSION_TO_PLUGIN[ext] = []
_EXTENSION_TO_PLUGIN[ext].append(plugin_name)
Expand Down Expand Up @@ -181,7 +181,7 @@ def format_plugin_installation_message(
if not suggested_plugins:
return (
f"\n\nNo bioio plugins found for '{filename}'.\n"
"See https://github.com/bioio-devs/bioio for available plugins."
'See https://github.com/bioio-devs/bioio for available plugins.'
)

# Format the plugin list (filters out core plugins automatically)
Expand All @@ -190,36 +190,36 @@ def format_plugin_installation_message(
# Build appropriate message based on what's installed/missing
if installed_plugins and installable_plugins and plugin_list:
# Case 1: Some plugins installed but failed, suggest alternatives
installed_str = ", ".join(sorted(installed_plugins))
installed_str = ', '.join(sorted(installed_plugins))
return (
f"\n\nInstalled plugin '{installed_str}' failed to read '{filename}'.\n"
"Try one of these alternatives:\n\n"
f"{plugin_list}"
"\nRestart napari/Python after installing."
'Try one of these alternatives:\n\n'
f'{plugin_list}'
'\nRestart napari/Python after installing.'
)

if installed_plugins and not installable_plugins:
# Case 2: All suggested plugins already installed but still failed
installed_str = ", ".join(sorted(installed_plugins))
installed_str = ', '.join(sorted(installed_plugins))
return (
f"\nFile '{filename}' is supported by: {installed_str}\n"
"However, the plugin failed to read it.\n"
"This may indicate a corrupt file or incompatible format variant."
'However, the plugin failed to read it.\n'
'This may indicate a corrupt file or incompatible format variant.'
)

if plugin_list:
# Case 3: No installed plugins, suggest installing
return (
f"\n\nTo read '{filename}', install one of:\n\n"
f"{plugin_list}"
"\nRestart napari/Python after installing."
f'{plugin_list}'
'\nRestart napari/Python after installing.'
)

# Case 4: All suggested plugins are core plugins (already should be installed)
return (
f"\n\nRequired plugins for '{filename}' should already be installed.\n"
"If you're still having issues, check your installation or "
"open an issue at https://github.com/ndev-kit/ndevio."
'open an issue at https://github.com/ndev-kit/ndevio.'
)


Expand Down Expand Up @@ -254,11 +254,11 @@ def suggest_plugins_for_path(path: Path | str) -> list[str]:

# Check compound extensions first (.ome.tiff, .tiles.ome.tif, etc.)
for plugin_name, info in BIOIO_PLUGINS.items():
for ext in info["extensions"]:
for ext in info['extensions']:
# Compound extension: multiple dots and matches filename
if (
ext.startswith(".")
and len(ext.split(".")) > 2
ext.startswith('.')
and len(ext.split('.')) > 2
and filename.endswith(ext)
):
return [plugin_name]
Expand Down Expand Up @@ -286,7 +286,7 @@ def _format_plugin_list(plugin_names: list[str]) -> str:
Formatted installation instructions
"""
if not plugin_names:
return ""
return ''

lines = []
for plugin_name in plugin_names:
Expand All @@ -296,13 +296,13 @@ def _format_plugin_list(plugin_names: list[str]) -> str:
continue

# Skip core plugins (already installed with ndevio)
if info.get("core", False):
if info.get('core', False):
continue

lines.append(f" • {plugin_name}")
lines.append(f" {info['description']}")
if info.get("note"):
lines.append(f" Note: {info['note']}")
lines.append(f" Install: pip install {plugin_name}\n")
lines.append(f' • {plugin_name}')
lines.append(f' {info["description"]}')
if info.get('note'):
lines.append(f' Note: {info["note"]}')
lines.append(f' Install: pip install {plugin_name}\n')

return "\n".join(lines)
return '\n'.join(lines)
18 changes: 9 additions & 9 deletions src/ndevio/_colormap_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
multichannel image display.
"""

SINGLE_CHANNEL_COLORMAP = "gray"
SINGLE_CHANNEL_COLORMAP = 'gray'

TWO_CHANNEL_CYCLE = ["magenta", "green"]
TWO_CHANNEL_CYCLE = ['magenta', 'green']

MULTI_CHANNEL_CYCLE = ["cyan", "magenta", "yellow", "blue", "green", "red"]
MULTI_CHANNEL_CYCLE = ['cyan', 'magenta', 'yellow', 'blue', 'green', 'red']

RGB = ["red", "green", "blue"]
RGB = ['red', 'green', 'blue']


def get_colormap_for_channel(channel_idx: int, n_channels: int) -> str:
Expand Down Expand Up @@ -43,9 +43,9 @@ def get_colormap_for_channel(channel_idx: int, n_channels: int) -> str:


__all__ = [
"SINGLE_CHANNEL_COLORMAP",
"TWO_CHANNEL_CYCLE",
"MULTI_CHANNEL_CYCLE",
"RGB",
"get_colormap_for_channel",
'SINGLE_CHANNEL_COLORMAP',
'TWO_CHANNEL_CYCLE',
'MULTI_CHANNEL_CYCLE',
'RGB',
'get_colormap_for_channel',
]
Loading