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>. There are 2 commands currently:

npd --validate-packages should be used after packages are built for pypi releases, (example: this repo is built by pep517 standard pip install pep517 && python -m pep517.build .). The validator checks that all packages built under dist are correctly tagged with classifier "Framework :: napari". This is recommended for most plugins unless you do not want your plugin to appear in the napari built-in plugin installation tool.

npd --validate-readers|--validate-writers|--validate-functions|--validate-widgets, verifies that after the plugin is installed to current python environment, typically done through pip install -e ., there is at least one hook under corresponding category registered by the plugin, and there are no conflicts in name or registration error, it also output all registered function signatures in a json format that can be used for further inspection, for example:

    [{
        "plugin name": "napari-demo",
        "function name": "image arithmetic",
        "args": ["layerA", "operation", "layerB"],
        "annotations": {
            "return": "napari.types.ImageData",
            "layerA": "napari.types.ImageData",
            "operation": "<enum 'Operation'>",
            "layerB": "napari.types.ImageData"
        },
        "defaults": null
    }]

Multiple cmds in one execution is supported, for example: npd --validate-readers --validate-functions --validate-packages

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.

Source Distribution

napari-plugin-devtools-0.2.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

napari_plugin_devtools-0.2-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file napari-plugin-devtools-0.2.tar.gz.

File metadata

  • Download URL: napari-plugin-devtools-0.2.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for napari-plugin-devtools-0.2.tar.gz
Algorithm Hash digest
SHA256 282c544137ddf06216ae7a919a88c382c7707184b34a4d4183e6d939b5fa7072
MD5 a792c269c6354cbfcbc4d786ed89a036
BLAKE2b-256 e3a28820c30e1bb1a64d48a8254506726263f78b6bf1e97b7f58864117e68c19

See more details on using hashes here.

File details

Details for the file napari_plugin_devtools-0.2-py3-none-any.whl.

File metadata

  • Download URL: napari_plugin_devtools-0.2-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for napari_plugin_devtools-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 824d4545e0592579fc673e8c55c99680076aee772e7cd79f5826bbd2a16ca299
MD5 4b9a5b02808a94120957353891551c7e
BLAKE2b-256 68722b283931b428793d92722895cd9f21d67d2af61c60f9f544fce408f94bcf

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page