ome/napari-ome-zarr

Install in dev mode / how to check if napari uses the plugin.

Closed this issue · 12 comments

I tried to install the plugin in dev mode via pip, i.e.

git clone install https://github.com/ome/napari-ome-zarr   (I used my own fork instead, but that shouldn't matter)
cd napari-ome-zarr
pip install -e . --no-deps  (In conda, so don't use pip deps, all deps should be there in my case)

However, when I try to run the example, it fails:

$ napari https://s3.embassy.ebi.ac.uk/idr/zarr/v0.1/6001240.zarr/                                                                                   
17:00:02 ERROR PluginError: Error in plugin 'builtins', hook 'napari_get_reader'                                                                                                       
  Cause was: ValueError('Not a zarr dataset or group: https://s3.embassy.ebi.ac.uk/idr/zarr/v0.1/6001240.zarr/')                                                                       
    in file: /home/pape/Work/software/conda/miniconda3/envs/main/lib/python3.7/site-packages/napari/utils/io.py                                                                        
    at line: 292                                                                                                                                                                       
     author: napari team                                                                                                                                                               
      email: napari-steering-council@googlegroups.com                                                                                                                                  
    package: napari                                                                                                                                                                    
        url: https://napari.org                                                                                                                                                        
    version: 0.3.6                                                                                                                                                                     
                                                                                                                                                                                       
17:00:02 WARNING No plugin found capable of reading 'https://s3.embassy.ebi.ac.uk/idr/zarr/v0.1/6001240.zarr/'.                                                                        
17:00:02 ERROR (1) error occurred in plugins: 'builtins'. See full error logs in "Plugins → Plugin Errors..." 

@constantinpape : why would you assume that all the deps are in your conda? Does this work if you pip install ome-zarr?

why would you assume that all the deps are in your conda?

Because I have a conda environment with all the necessary requirements already set up. Even if not all dependencies are present, I would much rather install them manually via conda, if possible, because pip packages do not interact nicely with conda dependency resolution.
In particular, I have a dev install of ome-zarr in that environment.

From what I can see the issue here is not related to the dependencies. If it was a dependency issue, I should see some ImportError.
Instead, the issue seems to be that the plugin is not registered properly with napari after pip install -e ..
Just for reference, here is the relevant part of conda list for this env (I don't want to paste the whole thing, this is my general dev environment, so it's rather large):

napari                    0.3.6                      py_0    conda-forge
napari-ome-zarr           0.1.dev30+gbe252c3.d20210613           dev_0    <develop>
napari-plugin-engine      0.1.6                      py_0    conda-forge
ome-zarr                  0.0.20.dev0               dev_0    <develop>

In particular, I have a dev install of ome-zarr in that environment.

👍

Instead, the issue seems to be that the plugin is not registered properly with napari after pip install -e ..

Ok. This is likely an issue for https://github.com/napari/cookiecutter-napari-plugin then. Perhaps @DragaDoncila can help us. In preparation for napari-hub, we created this fresh from the cookiecutter template to be as similar to other plugins as possible.

@constantinpape if you open a napari viewer and go to Plugins>Install/Uninstall Package(s) is napari-ome-zarr registered?

I just tried installing napari-ome-zarr with pip install -e . and it works fine

@DragaDoncila yes, it's listed.

@constantinpape I'm trying to recreate this locally but I'm not able to. Can you provide a list of commands you're using to create a fresh environment and add the required dependencies (including ome-zarr).

Additionally what you could check is whether napari-ome-zarr is reporting any errors in Plugins>Plugin Errors...

While reproducing the error I found that the issue seems to be that the plugin is not activated by default. So this fixes my issue for now, but I think that the plugin should be activated by default, or if that's not possible, we should add to the Readme that it has to be activated by the user. See detailed description below.

Reproducing the issue

Starting from a new conda environment and using pip for dependencies inside that environment to avoid confusion with dependencies. Also, assuming to start from a dir that holds the ome-zarr-py and napari-ome-zarr repos

Setting up the env

$ conda create -n napari -c conda-forge napari
$ conda activate napari
$ cd ome-zarr-py
$ pip install -e .
$ cd ../napari-ome-zarr
$ pip install -e .

checking ome-zarr-py installation

$ ome_zarr download https://s3.embassy.ebi.ac.uk/idr/zarr/v0.1/6001240.zarr/

This works.

trying napari plugin from the command line

$ napari 'https://s3.embassy.ebi.ac.uk/idr/zarr/v0.1/6001240.zarr/'

fails with

Traceback (most recent call last):
  File "/home/pape/Work/software/conda/miniconda3/envs/napari/bin/napari", line 10, in <module>
    sys.exit(main())
  File "/home/pape/Work/software/conda/miniconda3/envs/napari/lib/python3.9/site-packages/napari/__main__.py", line 414, in main
    _run()
  File "/home/pape/Work/software/conda/miniconda3/envs/napari/lib/python3.9/site-packages/napari/__main__.py", line 298, in _run
    viewer = view_path(  # noqa: F841
  File "/home/pape/Work/software/conda/miniconda3/envs/napari/lib/python3.9/site-packages/napari/view_layers.py", line 169, in view_path
    return _make_viewer_then('open', args, kwargs)
  File "/home/pape/Work/software/conda/miniconda3/envs/napari/lib/python3.9/site-packages/napari/view_layers.py", line 119, in _make_viewer_then
    method(*args, **kwargs)
  File "/home/pape/Work/software/conda/miniconda3/envs/napari/lib/python3.9/site-packages/napari/components/viewer_model.py", line 857, in open
    self._add_layers_with_plugins(
  File "/home/pape/Work/software/conda/miniconda3/envs/napari/lib/python3.9/site-packages/napari/components/viewer_model.py", line 902, in _add_layers_with_plugins
    layer_data, hookimpl = read_data_with_plugins(
  File "/home/pape/Work/software/conda/miniconda3/envs/napari/lib/python3.9/site-packages/napari/plugins/io.py", line 131, in read_data_with_plugins
    raise ValueError(message)
ValueError: No plugin found capable of reading 'https://s3.embassy.ebi.ac.uk/idr/zarr/v0.1/6001240.zarr/'.

trying the plugin from napari gui

$ napari

Open "Plugins->Install/Uninstall Pacakge(s)". This is what I see:
napari-plugin
I.e. the plugin is listed, but it does not have a checkbox.

If I just drag and drop the file downloaded above, it fails with (same traceback as above):

ValueError: No plugin found capable of reading '/home/pape/Work/mobie/napari-ome-zarr/6001240.zarr'.

If I set the checkbox, it works and also subsequent calls via the CLI work.

I'm wondering if this isn't covered by the fact that the ome-zarr-py PR wasn't merged. Investigating now.

Hmmm.... pip install -e ing ome-zarr-py 0.0.20 and napari-ome-zarr 0.1.1 (which now depends on ome-zarr-py >= 0.0.20) certainly works. I haven't found a combination that I can rollback to yet though that shows the behavior you describe. For me the available plugins are always activated. The only case I've run into is that older ome-zarr-py repositories may take precedence over the napari-ome-zarr one.

Thanks for checking @joshmoore. I guess this will be very hard to pin down, as the installation order etc. might play a role and I have the feeling that this is rather an upstream issue in the napari plugin system. I will close this for now as this issue might only occur in certain dependency combinations so I might be the only one encountering it and having to set the checkbox once is not a problem at all in my dev env.
Just for reference, here are the relevant versions for which I have encountered this problem:

napari                    0.4.9              pyhd8ed1ab_0    conda-forge
napari-console            0.0.3              pyhd8ed1ab_0    conda-forge
napari-ome-zarr           0.1.dev30+gbe252c3.d20210614           dev_0    <develop>
napari-plugin-engine      0.1.9            py39hf3d152e_1    conda-forge
ome-zarr                  0.0.20.dev0               dev_0    <develop>

@constantinpape thanks for the detail on this. I do think this is a recent issue with our plugin eco system and some work we've been doing to allow users to enable/disable plugins and reorder them through preferences. You're definitely right - a freshly installed plugin should be enabled by default - I'll chase this up on the napari end.

Thanks @DragaDoncila. Let me know if you need any more information.