Skip to article frontmatterSkip to article content

Workshop 3: Developing napari Plugins

Level: Advanced (but beginner-friendly!)
Duration: 4-5 hours

Overview

This workshop teaches you how to package your custom napari functionality as plugins that can be shared with the broader scientific community. You’ll learn about the napari plugin ecosystem (npe2), how to structure plugins, contribute different types of functionality, test your code, and publish to PyPI and the napari hub. While this is an “advanced” workshop, it’s designed to be accessible to developers who have completed the previous workshops or have equivalent experience.

Learning Objectives

By completing this workshop, you will be able to:

Prerequisites

Workshop Structure

This workshop guides you through the complete plugin development lifecycle:

1. Plugin Overview & npe2 Architecture

Understand what plugins are and how they integrate with napari.

Topics covered:

2. Choosing Plugin Contributions

Decide what type of contribution(s) your plugin should provide.

Topics covered:

3. Using the Plugin Template

Bootstrap your plugin with best practices baked in.

Topics covered:

4. Building a Widget Plugin

Turn your magicgui widgets into a distributable plugin.

Topics covered:

5. Reader & Writer Plugins

Extend napari’s file format support.

Topics covered:

6. Testing & Debugging

Ensure your plugin is robust and maintainable.

Topics covered:

7. Publishing & Maintaining Plugins

Share your plugin with the community and keep it updated.

Topics covered:

Key Concepts

Plugin Manifest (napari.yaml)

The napari.yaml file is the heart of your plugin. It declares what your plugin provides:

name: napari-my-plugin
contributions:
  commands:
    - id: napari-my-plugin.spot_detection
      python_name: napari_my_plugin._widget:SpotDetector
      title: Detect Spots
  widgets:
    - command: napari-my-plugin.spot_detection
      display_name: Spot Detector

Contribution Types

napari plugins can provide:

Plugin Development Workflow

  1. Develop functionality as scripts (Workshop 2)
  2. Package using the plugin template
  3. Test with pytest and pytest-napari
  4. Document usage and API
  5. Publish to PyPI
  6. Register on napari hub
  7. Maintain over time

From Widget to Plugin: A Case Study

This workshop includes a complete case study of converting the spot detection widget from Workshop 2 into a published plugin, including:

Practical Considerations

When to Build a Plugin

Build a plugin when you want to:

Plugin Maintenance

Good plugins require ongoing maintenance:

We’ll discuss strategies to make maintenance manageable!

Resources

Getting Help

Next Steps

After completing this workshop: