Skip to main content

napari plugin devtool

Project description

napari-plugin-devtools

License PyPI Python Version tests

A repo with tools and services for napari plugin developers

Installation

This tool can be installed via pip: pip install napari-plugin-devtools, you can also add it to your requirements.txt to be installed with other dependencies automatically.

Validation tool

The validation tools provides automated tests for plugin developers, these checks verify that the plugin is available for users of napari to install, and would register entry points with napari.

There are two parts to the validation tool. One part is a command line interface and the other is a pytest fixture.

Command Line Interface (CLI) Usage

The CLI can be used by continuous integration (CI) pipelines to perform a quick verification of a plugins setup without any specific input required. It serves as a quick "sanity check". (It is also accessible from python in validation.py)

The tool can be run as npd <cmd>. where currently we support cmd validate:

npd validate: validate classifiers and function hooks can be recognized by napari. The validation would run on built packages under dist folder to check if they are annotated properly with framework classifier, and validate hooks are properly annotated that they can be found by napari.

npd validate -i|--include-plugin INCLUDE_PLUGIN [INCLUDE_PLUGIN ...] run hook checks only on listed plugins, this is useful to filter out other plugins on a complicated python environment.

npd validate -e|--exclude-plugin EXCLUDE_PLUGIN [EXCLUDE_PLUGIN ...] do not run hook checks on listed plugins, this is useful to filter out other plugins on a complicated python environment.

npd validate -v|--verbose enable verbose mode, gives slightly more information on the underlying findings of validation process.

Pytest fixture usage

devtools provides a pytest fixture: napari_plugin_tester in plugin_tester.py, it extends a plugin manager used by napari and have additional assertion modes ready:

def test_pm(napari_plugin_tester):
    napari_plugin_tester.assert_plugin_name_registered("test-plugin")
    napari_plugin_tester.assert_module_registered(_test)
    napari_plugin_tester.assert_implementations_registered(
        "test-plugin", "napari_get_reader"
    )

where you can check more specifically on a module or function being registered under napari annotations, see hook specifications to find what other annotations are avaiable in addition to napari_get_reader

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for napari-plugin-devtools, version 0.4.2
Filename, size File type Python version Upload date Hashes
Filename, size napari_plugin_devtools-0.4.2-py3-none-any.whl (9.0 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size napari-plugin-devtools-0.4.2.tar.gz (12.2 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page