`run_sorter` in a container returns the previous sorting when the output folder already exists
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 65/100
Hướng nghiên cứu
Start in spikeinterface/sorters/runsorter.py at run_sorter_container and compare its output-folder handling with initialize_folder and the local run_sorter_local path. Reproduce the issue with the supplied LocalClient stub: run once, then run again into the same folder. The fix is complete when the second container call raises the expected error, or removes the folder when requested, instead of returning the previous sorting; add a regression test for both behaviors.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
I found this while reading sorters/runsorter.py, not in my own analyses, so this is a "for the sake of improvement" report.
With docker_image or singularity_image, run_sorter keeps its default remove_existing_folder=False. If the output folder already exists, run_sorter_local fails inside the container, but run_sorter_container only reads spikeinterface_log.json (lines 663-678), which still comes from the earlier run, so the earlier sorting is returned without any error. Without a container, the same call raises ValueError.
I have no docker here, so the example replaces ContainerClient with a stub that runs the generated in-container script with the local Python:
import subprocess
import sys
import tempfile
from pathlib import Path
from spikeinterface.core import generate_ground_truth_recording
from spikeinterface.sorters import run_sorter, run_sorter_container, runsorter
class LocalClient:
"""Stand-in for docker: runs the generated in-container script with the local Python."""
last_output = ""
def __init__(self, *args):
pass
def start(self):
pass
def stop(self):
pass
def run_command(self, cmd):
if cmd[-1].endswith("in_container_sorter_script.py"):
p = subprocess.run([sys.executable, cmd[-1]], capture_output=True, text=True)
LocalClient.last_output = p.stdout + p.stderr
return LocalClient.last_output
return ""
def sort_in_container(recording, folder, n_clusters):
# remove_existing_folder=False is the default of run_sorter(..., docker_image=...)
return run_sorter_container(
"simple", recording, mode="docker", container_image="any", installation_mode="no-install",
folder=folder, remove_existing_folder=False,
clusterer="kmeans", clusterer_kwargs={"n_clusters": n_clusters, "random_state": 0}, seed=0,
)
if __name__ == "__main__":
runsorter.ContainerClient = LocalClient
recording, _ = generate_ground_truth_recording(num_channels=4, durations=[5.0], num_units=3, seed=0)
with tempfile.TemporaryDirectory() as tmp:
recording = recording.save(folder=Path(tmp) / "recording", progress_bar=False) # serializable for the container
folder = Path(tmp) / "sorting"
print("1st run, 3 clusters:", sort_in_container(recording, folder, 3).unit_ids)
print("2nd run, 6 clusters:", sort_in_container(recording, folder, 6).unit_ids)
print(" inside the container:", LocalClient.last_output.strip().splitlines()[-1].replace(tmp, "<tmp>"))
try:
run_sorter("simple", recording, folder=folder, clusterer="kmeans", clusterer_kwargs={"n_clusters": 6})
except ValueError as e:
print("same call without container:", type(e).__name__)
del recording # release the memmap so the folder can be removed on Windows
# Output:
# 1st run, 3 clusters: [0 1 2]
# 2nd run, 6 clusters: [0 1 2]
# inside the container: ValueError: Folder <tmp>\sorting already exists
# same call without container: ValueError
# Expected: an error on the 2nd run, as without a container.
Fix: check the output folder on the host before starting the container (raise, or remove it when remove_existing_folder=True), as initialize_folder does locally.
I can open a PR with a test if you agree.
- Ngôn ngữ chính
- Python
- Star
- 883
- Fork
- 291
- Merge trung bình
- 3 ngày 17 giờ
- Pull request đã merge (30 ngày)
- 40
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của SpikeInterface/spikeinterface
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
SpikeInterface/spikeinterface#5008 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
`plot_potential_merges` draws the correlograms of other units when a merge group is not sortedĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
SpikeInterface/spikeinterface#5007 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
`plot_unit_presence` shows bin indices on the `Time (s)` axis when `time_range` is not givenĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
SpikeInterface/spikeinterface#5006 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
SpikeInterface/spikeinterface#5005 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
SpikeInterface/spikeinterface#5004 ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của SpikeInterface/spikeinterface
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 69/100
daniel-ospina/tortoise#15308 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Maintainer thường phản hồi trong vòng 1 ngày
-
difficulty:easy prio:low type:bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
NatronGitHub/Natron#2405 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Jstar269/nakagawa-recomp#3746 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày