pykilosort, spykingcircus and rtsort wrappers are broken on main

未关闭 适合新手
#5,003 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
75/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python
领域
backend

调研方向

阅读指定方法中的 sorters/external/pykilosort.py、sorters/external/spyking_circus.py 和 sorters/external/rt_sort.py,然后检查相关 sorter 测试。修正报告中的三个调用,并验证这些 wrapper 接受预期的包版本且能加载 sorting 结果;每个报告的失败都由测试覆盖后即为完成。

由索引模型根据 Issue 内容生成。

描述

I found this while reading sorters/external/pykilosort.py, spyking_circus.py and rt_sort.py, not in my own analyses, so this is a "for the sake of improvement" report. Three wrappers are broken on the current main:

  • pykilosort: _run_from_folder (l. 157) calls binary_compatible_with(time_axis=0, file_paths_lenght=1). #4222 fixed the same typo in _setup_recording only, so the run fails with TypeError before pykilosort's run is called.
  • spykingcircus: get_sorter_version (l. 76) calls version("circus"), but the distribution is named spyking-circus (circus is only its import name). run_from_folder calls it before sorting, so the run fails with PackageNotFoundError. This came with d2392ce, which replaced circus.__version__.
  • rtsort: _get_result_from_folder (l. 192) calls NumpySorting.load_from_folder, removed in #4664, so reading the result fails with AttributeError after sorting.
import importlib
import importlib.metadata
import sys
import tempfile
from pathlib import Path

from spikeinterface.core import generate_recording, generate_sorting
from spikeinterface.sorters.external.rt_sort import RTSortSorter
from spikeinterface.sorters.external.spyking_circus import SpykingcircusSorter

if __name__ == "__main__":
    with tempfile.TemporaryDirectory(ignore_cleanup_errors=True) as tmp:
        tmp = Path(tmp)

        # 1. pykilosort.py, _run_from_folder: same call as in the wrapper
        recording = generate_recording(num_channels=4, durations=[1.0], seed=0)
        try:
            recording.binary_compatible_with(time_axis=0, file_paths_lenght=1)
        except TypeError as e:
            print("TypeError:", e)
            # TypeError: BaseRecording.binary_compatible_with() got an unexpected keyword argument 'file_paths_lenght'

        # 2. spyking_circus.py: distribution "spyking-circus" with import name "circus",
        #    simulated by a minimal dist-info folder
        site = tmp / "site"
        (site / "circus").mkdir(parents=True)
        (site / "circus" / "__init__.py").write_text("")
        (site / "spyking_circus-1.1.0.dist-info").mkdir()
        (site / "spyking_circus-1.1.0.dist-info" / "METADATA").write_text(
            "Metadata-Version: 2.1\nName: spyking-circus\nVersion: 1.1.0\n"
        )
        sys.path.insert(0, str(site))
        importlib.invalidate_caches()
        print(SpykingcircusSorter.is_installed(), importlib.metadata.version("spyking-circus"))  # True 1.1.0
        try:
            SpykingcircusSorter.get_sorter_version()
        except importlib.metadata.PackageNotFoundError as e:
            print("PackageNotFoundError:", e)
            # PackageNotFoundError: No package metadata was found for circus
        sys.path.remove(str(site))

        # 3. rt_sort.py: reading a NumpySorting saved as the wrapper saves it
        sorting = generate_sorting(num_units=3, durations=[1.0], seed=0)
        sorting.save(folder=tmp / "rt_sorting")
        try:
            RTSortSorter._get_result_from_folder(tmp)
        except AttributeError as e:
            print("AttributeError:", e)
            # AttributeError: type object 'NumpySorting' has no attribute 'load_from_folder'

None of these sorters is installed on my side: the calls above reproduce the failing lines, and the spyking-circus install is simulated by a minimal dist-info folder.

Fix:

  • pykilosort: file_paths_length=1.
  • spykingcircus: version("spyking-circus").
  • rtsort: NumpySorting.load(...), which load_from_folder wrapped.

I can open a PR with a test if you agree.

主要语言
Python
星标
883
派生
291
平均合并
3 天 17 小时
30 天内合并 PR
40

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

SpikeInterface/spikeinterface 的其他 Issue

查看 SpikeInterface/spikeinterface 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。