cortex-lab / phy

phy: interactive visualization and manual spike sorting of large-scale ephys data
BSD 3-Clause "New" or "Revised" License
304 stars 155 forks source link

importlib update to plugin.py crashes phy loading #1281

Closed AceTylerCholine closed 4 weeks ago

AceTylerCholine commented 1 month ago

With these plugins in C:\Users\[username]\.phy\plugins: https://github.com/padillacoreanolab/PHY2_shortcuts/tree/main/plugins

and C:\Users\[username]\.phy\phy_config.py configured like this:

# You can also put your plugins in ~/.phy/plugins/.

from phy import IPlugin

# Plugin example:
#
# class MyPlugin(IPlugin):
#     def attach_to_cli(self, cli):
#         # you can create phy subcommands here with click
#         pass

c = get_config()
c.Plugins.dirs = [r'~\.phy\plugins']

c.TemplateGUI.plugins = ['ISIViolationPlugin1ms', 'ISIViolationPlugin1_5ms', 'ISIViolationPlugin2ms']  # list of plugin names to load in the TemplateGUI`

I get this terminal error when running Phy. Simply reverting to the previous plugin.py prevents this error.

(phy2) PS C:\Users\short\Documents\spike_sorting\20240323_144517_alone_comp_subj_3-1_t5b5_merged.rec\phy> phy template-gui params.py
20:20:32.248 [W] model:625            Unreferenced clusters found in spike_clusters (generally not a problem)
20:20:32.296 [W] model:667            Skipping spike waveforms that do not exist, they will be extracted on the fly from the raw data as needed.
20:20:33.613 [E] __init__:62          An error has occurred (TypeError): cannot unpack non-iterable NoneType object
Traceback (most recent call last):
  File "C:\Users\short\miniconda3\envs\phy2\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\short\miniconda3\envs\phy2\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\short\miniconda3\envs\phy2\Scripts\phy.exe\__main__.py", line 7, in <module>
    sys.exit(phycli())
  File "C:\Users\short\miniconda3\envs\phy2\lib\site-packages\click\core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\short\miniconda3\envs\phy2\lib\site-packages\click\core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "C:\Users\short\miniconda3\envs\phy2\lib\site-packages\click\core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\short\miniconda3\envs\phy2\lib\site-packages\click\core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\short\miniconda3\envs\phy2\lib\site-packages\click\core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "C:\Users\short\miniconda3\envs\phy2\lib\site-packages\click\decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "C:\Users\short\miniconda3\envs\phy2\lib\site-packages\phy\apps\__init__.py", line 159, in cli_template_gui
    template_gui(params_path, **kwargs)
  File "C:\Users\short\miniconda3\envs\phy2\lib\site-packages\phy\apps\template\gui.py", line 217, in template_gui
    controller = TemplateController(model=model, dir_path=dir_path, **kwargs)
  File "C:\Users\short\miniconda3\envs\phy2\lib\site-packages\phy\apps\base.py", line 470, in __init__
    super(TemplateMixin, self).__init__(*args, **kwargs)
  File "C:\Users\short\miniconda3\envs\phy2\lib\site-packages\phy\apps\base.py", line 916, in __init__
    self.attached_plugins = attach_plugins(
  File "C:\Users\short\miniconda3\envs\phy2\lib\site-packages\phy\utils\plugin.py", line 141, in attach_plugins
    discover_plugins(dirs)
  File "C:\Users\short\miniconda3\envs\phy2\lib\site-packages\phy\utils\plugin.py", line 104, in discover_plugins
    file, path, descr = importlib.util.find_spec(modname, [subdir])
TypeError: cannot unpack non-iterable NoneType object
zm711 commented 4 weeks ago

Fixed by #1282.