Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while opening image via HTTPS #16

Closed
haesleinhuepf opened this issue Jul 11, 2021 · 1 comment · Fixed by #17
Closed

Error while opening image via HTTPS #16

haesleinhuepf opened this issue Jul 11, 2021 · 1 comment · Fixed by #17

Comments

@haesleinhuepf
Copy link
Contributor

Description

Hi @JacksonMaxfield ,

I'm trying to load example data into napari from zenodo.org, therefore, I implemented this hook:

@napari_hook_implementation
def napari_provide_sample_data():
    return {
        "Haase_MRT_tfl3d1": "https://zenodo.org/record/5090508/files/Haase_MRT_tfl3d1.tif?download=1",
    }

When clicking on it, AICSImageIO causes an error (see full log at the bottom):

ModuleNotFoundError: No module named 'aiohttp'
[...]
PluginCallError: Error in plugin 'aicsimageio-in-memory', hook 'napari_get_reader': HTTPFileSystem requires "requests" and "aiohttp" to be installed

Expected Behavior

It would be cool if AICSImageIO could not try to load that file in case those dependencies are not installed. Another napari loader plugin would then have the chance to try.

Alternatively, could you ship those missing dependencies when installing napari-aicsimageio?

Reproduction

You can install napari-pyclesperanto-assistant 0.9.5 with napari-aicsimageio in your napari. You will then find this entry under File > Open Samples > clEsperanto > Haase_MRT_tfl3d1. Click it to reproduce the error above.

Environment

That's my napari environment:

napari: 0.4.10
Platform: Windows-10-10.0.19041-SP0
Python: 3.9.4 | packaged by conda-forge | (default, May 10 2021, 22:10:34) [MSC v.1916 64 bit (AMD64)]
Qt: 5.12.9
PyQt5: 5.12.3
NumPy: 1.19.5
SciPy: 1.6.3
Dask: 2021.06.0
VisPy: 0.6.6

OpenGL:

  • GL version: 4.6.0 NVIDIA 466.77
  • MAX_TEXTURE_SIZE: 32768

Screens:

  • screen 1: resolution 1920x1200, scale 1.0

Plugins:

  • OpenCL_Random_Forest_Classifier: 0.3.1
  • StarDist: 2021.6.1
  • aicsimageio-in-memory: 0.3.2
  • animation: 0.0.2
  • clEsperanto: 0.9.5
  • console: 0.0.3
  • devbio: 0.1.0
  • napari-skimage-regionprops: 0.1.0
  • scikit-image: 0.4.10
  • svg: 0.1.5

Full error log

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
c:\users\rober\miniconda3\envs\bio2\lib\site-packages\fsspec\registry.py in get_filesystem_class(protocol='https')
    212         try:
--> 213             register_implementation(protocol, _import_class(bit["class"]))
        global register_implementation = 
        protocol = 'https'
        global _import_class = 
        bit = {'class': 'fsspec.implementations.http.HTTPFileSystem', 'err': 'HTTPFileSystem requires "requests" and "aiohttp" to be installed'}
    214         except ImportError as e:

c:\users\rober\miniconda3\envs\bio2\lib\site-packages\fsspec\registry.py in _import_class(cls='fsspec.implementations.http.HTTPFileSystem', minv={'gcsfs': LooseVersion ('0.3.0'), 's3fs': LooseVersion ('0.3.0')})
    227 
--> 228     mod = importlib.import_module(mod)
        mod = 'fsspec.implementations.http'
        global importlib.import_module = 
    229     if minversion:

c:\users\rober\miniconda3\envs\bio2\lib\importlib\__init__.py in import_module(name='fsspec.implementations.http', package=None)
    126             level += 1
--> 127     return _bootstrap._gcd_import(name[level:], package, level)
        global _bootstrap._gcd_import = 
        name = 'fsspec.implementations.http'
        level = 0
        package = None
    128 

c:\users\rober\miniconda3\envs\bio2\lib\importlib\_bootstrap.py in _gcd_import(name='fsspec.implementations.http', package=None, level=0)

c:\users\rober\miniconda3\envs\bio2\lib\importlib\_bootstrap.py in _find_and_load(name='fsspec.implementations.http', import_=)

c:\users\rober\miniconda3\envs\bio2\lib\importlib\_bootstrap.py in _find_and_load_unlocked(name='fsspec.implementations.http', import_=)

c:\users\rober\miniconda3\envs\bio2\lib\importlib\_bootstrap.py in _load_unlocked(spec=ModuleSpec(name='fsspec.implementations.http', l...site-packages\\fsspec\\implementations\\http.py'))

c:\users\rober\miniconda3\envs\bio2\lib\importlib\_bootstrap_external.py in exec_module(self=, module=)

c:\users\rober\miniconda3\envs\bio2\lib\importlib\_bootstrap.py in _call_with_frames_removed(f=, *args=( at 0x0000021149D7D870, fil...packages\fsspec\implementations\http.py", line 1>, {'__builtins__': {'ArithmeticError': , 'AssertionError': , 'AttributeError': , 'BaseException': , 'BlockingIOError': , 'BrokenPipeError': , 'BufferError': , 'BytesWarning': , 'ChildProcessError': , 'ConnectionAbortedError': , ...}, '__cached__': r'c:\users\rober\miniconda3\envs\bio2\lib\site-pac...c\implementations\__pycache__\http.cpython-39.pyc', '__doc__': None, '__file__': r'c:\users\rober\miniconda3\envs\bio2\lib\site-packages\fsspec\implementations\http.py', '__loader__': , '__name__': 'fsspec.implementations.http', '__package__': 'fsspec.implementations', '__spec__': ModuleSpec(name='fsspec.implementations.http', l...site-packages\\fsspec\\implementations\\http.py'), 'absolute_import': _Feature((2, 5, 0, 'alpha', 1), (3, 0, 0, 'alpha', 0), 262144), 'asyncio': , ...}), **kwds={})

c:\users\rober\miniconda3\envs\bio2\lib\site-packages\fsspec\implementations\http.py in 
      9 
---> 10 import aiohttp
        global aiohttp = undefined
     11 import requests

ModuleNotFoundError: No module named 'aiohttp'

The above exception was the direct cause of the following exception:

ImportError                               Traceback (most recent call last)
    [... skipping hidden 1 frame]

c:\users\rober\miniconda3\envs\bio2\lib\site-packages\napari_plugin_engine\implementation.py in __call__(self=, *args=('https://zenodo.org/record/5090508/files/Haase_MRT_tfl3d1.tif?download=1',))
     65     def __call__(self, *args):
---> 66         return self.function(*args)
        self.function = 
        args = ('https://zenodo.org/record/5090508/files/Haase_MRT_tfl3d1.tif?download=1',)
     67 

c:\users\rober\miniconda3\envs\bio2\lib\site-packages\napari_aicsimageio\in_memory.py in napari_get_reader(path='https://zenodo.org/record/5090508/files/Haase_MRT_tfl3d1.tif?download=1')
     14 def napari_get_reader(path: core.PathLike) -> Optional[core.ReaderFunction]:
---> 15     return core.get_reader(path, in_memory=True)
        global core.get_reader = 
        path = 'https://zenodo.org/record/5090508/files/Haase_MRT_tfl3d1.tif?download=1'
        global in_memory = undefined

c:\users\rober\miniconda3\envs\bio2\lib\site-packages\napari_aicsimageio\core.py in get_reader(path='https://zenodo.org/record/5090508/files/Haase_MRT_tfl3d1.tif?download=1', in_memory=True)
    113         # So only determine reader for the first one
--> 114         AICSImage.determine_reader(path)
        global AICSImage.determine_reader = 
        path = 'https://zenodo.org/record/5090508/files/Haase_MRT_tfl3d1.tif?download=1'
    115 

c:\users\rober\miniconda3\envs\bio2\lib\site-packages\aicsimageio\aics_image.py in determine_reader(image='https://zenodo.org/record/5090508/files/Haase_MRT_tfl3d1.tif?download=1', **kwargs={})
    145         for ReaderClass in AICSImage.SUPPORTED_READERS:
--> 146             if ReaderClass.is_supported_image(image, **kwargs):  # type: ignore
        ReaderClass.is_supported_image = >
        image = 'https://zenodo.org/record/5090508/files/Haase_MRT_tfl3d1.tif?download=1'
        kwargs = {}
    147                 return ReaderClass

c:\users\rober\miniconda3\envs\bio2\lib\site-packages\aicsimageio\readers\reader.py in is_supported_image(cls=, image='https://zenodo.org/record/5090508/files/Haase_MRT_tfl3d1.tif?download=1', **kwargs={})
     97             # Expand details of provided image
---> 98             fs, path = io_utils.pathlike_to_fs(image, enforce_exists=True)
        fs = undefined
        path = undefined
        global io_utils.pathlike_to_fs = 
        image = 'https://zenodo.org/record/5090508/files/Haase_MRT_tfl3d1.tif?download=1'
        global enforce_exists = undefined
     99 

c:\users\rober\miniconda3\envs\bio2\lib\site-packages\aicsimageio\utils\io_utils.py in pathlike_to_fs(uri='https://zenodo.org/record/5090508/files/Haase_MRT_tfl3d1.tif?download=1', enforce_exists=True)
     46     # Get details
---> 47     fs, path = url_to_fs(uri)
        fs = undefined
        path = undefined
        global url_to_fs = 
        uri = 'https://zenodo.org/record/5090508/files/Haase_MRT_tfl3d1.tif?download=1'
     48 

c:\users\rober\miniconda3\envs\bio2\lib\site-packages\fsspec\core.py in url_to_fs(url='https://zenodo.org/record/5090508/files/Haase_MRT_tfl3d1.tif?download=1', **kwargs={})
    371         protocol = split_protocol(url)[0]
--> 372         cls = get_filesystem_class(protocol)
        cls = undefined
        global get_filesystem_class = 
        protocol = 'https'
    373 

c:\users\rober\miniconda3\envs\bio2\lib\site-packages\fsspec\registry.py in get_filesystem_class(protocol='https')
    214         except ImportError as e:
--> 215             raise ImportError(bit["err"]) from e
        global ImportError = undefined
        bit = {'class': 'fsspec.implementations.http.HTTPFileSystem', 'err': 'HTTPFileSystem requires "requests" and "aiohttp" to be installed'}
        e = undefined
    216     cls = registry[protocol]

ImportError: HTTPFileSystem requires "requests" and "aiohttp" to be installed

The above exception was the direct cause of the following exception:

PluginCallError                           Traceback (most recent call last)
c:\users\rober\miniconda3\envs\bio2\lib\site-packages\napari\_qt\qt_main_window.py in _add_sample(plg='clEsperanto', smp='Haase_MRT_tfl3d1', *args=(False,))
    604 
    605                 def _add_sample(*args, plg=plugin_name, smp=samp_name):
--> 606                     self.qt_viewer.viewer.open_sample(plg, smp)
        global self.qt_viewer.viewer.open_sample = undefined
        plg = 'clEsperanto'
        smp = 'Haase_MRT_tfl3d1'
    607 
    608                 menu.addAction(action)

c:\users\rober\miniconda3\envs\bio2\lib\site-packages\napari\components\viewer_model.py in open_sample(self=Viewer(axes=Axes(visible=False, labels=True, col..._viewer.QtViewer object at 0x000002112D8EE0D0>>}), plugin='clEsperanto', sample='Haase_MRT_tfl3d1', reader_plugin=None, **kwargs={})
    780                 return added
    781             elif isinstance(data, (str, Path)):
--> 782                 return self.open(data, plugin=reader_plugin)
        self.open = ], _persisted_mouse_event={}, _mouse_drag_gen={}, _mouse_wheel_gen={}, keymap={'Control-Shift-C': >})>
        data = 'https://zenodo.org/record/5090508/files/Haase_MRT_tfl3d1.tif?download=1'
        plugin = 'clEsperanto'
        reader_plugin = None
    783             else:
    784                 raise TypeError(

c:\users\rober\miniconda3\envs\bio2\lib\site-packages\napari\components\viewer_model.py in open(self=Viewer(axes=Axes(visible=False, labels=True, col..._viewer.QtViewer object at 0x000002112D8EE0D0>>}), path='https://zenodo.org/record/5090508/files/Haase_MRT_tfl3d1.tif?download=1', stack=False, plugin=None, layer_type=None, **kwargs={})
    854         for _path in paths:
    855             added.extend(
--> 856                 self._add_layers_with_plugins(
        self._add_layers_with_plugins = ], _persisted_mouse_event={}, _mouse_drag_gen={}, _mouse_wheel_gen={}, keymap={'Control-Shift-C': >})>
        _path = 'https://zenodo.org/record/5090508/files/Haase_MRT_tfl3d1.tif?download=1'
        kwargs = {}
        plugin = None
        layer_type = None
    857                     _path, kwargs, plugin=plugin, layer_type=layer_type
    858                 )

c:\users\rober\miniconda3\envs\bio2\lib\site-packages\napari\components\viewer_model.py in _add_layers_with_plugins(self=Viewer(axes=Axes(visible=False, labels=True, col..._viewer.QtViewer object at 0x000002112D8EE0D0>>}), path_or_paths='https://zenodo.org/record/5090508/files/Haase_MRT_tfl3d1.tif?download=1', kwargs={}, plugin=None, layer_type=None)
    899         from ..plugins.io import read_data_with_plugins
    900 
--> 901         layer_data, hookimpl = read_data_with_plugins(
        layer_data = undefined
        hookimpl = undefined
        read_data_with_plugins = 
        path_or_paths = 'https://zenodo.org/record/5090508/files/Haase_MRT_tfl3d1.tif?download=1'
        plugin = None
    902             path_or_paths, plugin=plugin
    903         )

c:\users\rober\miniconda3\envs\bio2\lib\site-packages\napari\plugins\io.py in read_data_with_plugins(path='https://zenodo.org/record/5090508/files/Haase_MRT_tfl3d1.tif?download=1', plugin=None)
     91     layer_data = None
     92     while True:
---> 93         result = hook_caller.call_with_result_obj(
        result = undefined
        hook_caller.call_with_result_obj = >
        path = 'https://zenodo.org/record/5090508/files/Haase_MRT_tfl3d1.tif?download=1'
        global _skip_impls = undefined
        skip_impls = []
     94             path=path, _skip_impls=skip_impls
     95         )

c:\users\rober\miniconda3\envs\bio2\lib\site-packages\napari_plugin_engine\hooks.py in call_with_result_obj(self=, _skip_impls=[], **kwargs={'path': 'https://zenodo.org/record/5090508/files/Haase_MRT_tfl3d1.tif?download=1'})
    459         self._check_call_kwargs(kwargs)
    460         impls = [imp for imp in self.get_hookimpls() if imp not in _skip_impls]
--> 461         return self._hookexec(self, impls, kwargs)
        self._hookexec = >
        self = 
        impls = [, ]
        kwargs = {'path': 'https://zenodo.org/record/5090508/files/Haase_MRT_tfl3d1.tif?download=1'}
    462 
    463     def __call__(

c:\users\rober\miniconda3\envs\bio2\lib\site-packages\napari_plugin_engine\manager.py in _hookexec(self=, caller=, methods=[, ], kwargs={'path': 'https://zenodo.org/record/5090508/files/Haase_MRT_tfl3d1.tif?download=1'})
    157             The result object produced by the multicall loop.
    158         """
--> 159         return self._inner_hookexec(caller, methods, kwargs)
        self._inner_hookexec = . at 0x000002112BC4EF70>
        caller = 
        methods = [, ]
        kwargs = {'path': 'https://zenodo.org/record/5090508/files/Haase_MRT_tfl3d1.tif?download=1'}
    160 
    161     def iter_available(

c:\users\rober\miniconda3\envs\bio2\lib\site-packages\napari_plugin_engine\manager.py in (c=, m=[, ], k={'path': 'https://zenodo.org/record/5090508/files/Haase_MRT_tfl3d1.tif?download=1'})
    118         self.trace = _tracing.TagTracer().get("pluginmanage")
    119         self.hook = _HookRelay(self)
--> 120         self._inner_hookexec: HookExecFunc = lambda c, m, k: c.multicall(
        global self._inner_hookexec = undefined
        global HookExecFunc = typing.Callable[[ForwardRef('HookCaller'), typing.List[napari_plugin_engine.implementation.HookImplementation], dict], napari_plugin_engine.callers.HookResult]
        c = 
        m = [, ]
        k = {'path': 'https://zenodo.org/record/5090508/files/Haase_MRT_tfl3d1.tif?download=1'}
        c.multicall = 
        global firstresult = undefined
        c.is_firstresult = True
    121             m, k, firstresult=c.is_firstresult
    122         )

c:\users\rober\miniconda3\envs\bio2\lib\site-packages\napari_plugin_engine\callers.py in _multicall(hook_impls=[, ], caller_kwargs={'path': 'https://zenodo.org/record/5090508/files/Haase_MRT_tfl3d1.tif?download=1'}, firstresult=True)
    209     finally:
    210         if firstresult and errors:
--> 211             raise errors[-1]
        errors = [PluginCallError('Error in plugin \'aicsimageio-in-memory\', hook \'napari_get_reader\': HTTPFileSystem requires "requests" and "aiohttp" to be installed')]
    212 
    213         outcome = HookResult(

PluginCallError: Error in plugin 'aicsimageio-in-memory', hook 'napari_get_reader': HTTPFileSystem requires "requests" and "aiohttp" to be installed
@evamaxfield
Copy link
Collaborator

Huh. I never noticed this before because I thought fsspec came with requests installed. I think I will add fsspec[http] s3fs[boto3] and gcsfs to the requirements to cover the major bases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants