brisvag / napari-molecule-reader

BSD 3-Clause "New" or "Revised" License
4 stars 2 forks source link

on main read_molecules kwarg error #3

Closed sofroniewn closed 2 years ago

sofroniewn commented 2 years ago

I'm getting the following error on main

~/opt/anaconda3/lib/python3.7/site-packages/npe2/manifest/utils.py in exec(self=ReaderContribution(command='napari-molecule-read...ns=['*.pdb', '*.cif'], accepts_directories=False), args=(), kwargs={'path': '/Users/nsofroniew/Documents/proteins/pdb3mht.pdb'}, _registry=None)
     40         _registry: Optional[CommandRegistry] = None,
     41     ) -> R:
---> 42         return self.get_callable(_registry)(*args, **kwargs)
        self.get_callable = <bound method Executable.get_callable of ReaderContribution(command='napari-molecule-reader.get_reader', filename_patterns=['*.pdb', '*.cif'], accepts_directories=False)>
        _registry = None
        args = ()
        kwargs = {'path': '/Users/nsofroniew/Documents/proteins/pdb3mht.pdb'}
     43
     44     def get_callable(

TypeError: read_molecules() got an unexpected keyword argument 'path'
nclack commented 2 years ago

In this case, the problem is the function bound to the manifest needs to look something like this:

# in napari.yml :
#       python_name: napari_molecule_reader.molecule_reader:get_reader
def get_reader(_path):
  return read_molecule

It's not intuitive. The reason it's like this is a hold-over from the way readers worked in the previous plugin engine.

See here for the spec.

sofroniewn commented 2 years ago

@nclack are we going to be able to support more direct calls at some point in the future? (i.e. not the function that returns a function, but just the function that does the reading)

brisvag commented 2 years ago

Definitely would be nicer to do it directly, especially now that we don't need to check for extension in the plugin itself!

nclack commented 2 years ago

support more direct calls at some point in the future

would love to!

brisvag commented 2 years ago

closed by v0.1.1.