`run_sorter_jobs(engine='slurm')` writes an invalid Python script for a preprocessed recording
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ó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 75/100
Hướng nghiên cứu
Bắt đầu tại sorters/launcher.py, ở phần tạo tập lệnh Slurm quanh dòng 183–192, sau đó kiểm tra cách xử lý tuần tự hóa bản ghi. Tái hiện sự cố bằng cách biên dịch tập lệnh được tạo cho bản ghi thô, đã lọc và đã cắt; báo cáo có kèm ví dụ có thể chạy được. Hoàn tất khi cả ba tập lệnh đều biên dịch được và các đối số chuỗi hoặc đường dẫn có chứa dấu ngoặc kép hay dấu gạch chéo ngược được xử lý an toàn.
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/launcher.py, not in my own analyses, so this is a "for the sake of improvement" report.
With engine="slurm", the recording is written into the generated script as kwargs["recording"].to_dict() (line 192). Without recursive=True, the parent of a preprocessed or sliced recording is written as its repr, so the script is not valid Python. As sbatch does not parse the script, this would only show up when the job starts.
I have no slurm here, so the example mocks subprocess.run (no sbatch call) and compiles the generated script:
import contextlib
import io
import os
import subprocess
import tempfile
from pathlib import Path
from unittest import mock
from spikeinterface.core import generate_recording
from spikeinterface.preprocessing import bandpass_filter
from spikeinterface.sorters import run_sorter_jobs
if not hasattr(os, "fchmod"): # only needed on Windows with Python < 3.13
os.fchmod = lambda fd, mode: None
def slurm_script(recording, folder):
# sbatch is not called: only the generated script is kept and compiled
job = dict(sorter_name="simple", recording=recording, folder=(folder / "out").as_posix())
done = subprocess.CompletedProcess(args=[], returncode=0, stdout="", stderr="")
with mock.patch("subprocess.run", return_value=done), contextlib.redirect_stdout(io.StringIO()):
run_sorter_jobs([job], engine="slurm", engine_kwargs=dict(tmp_script_folder=folder))
script = folder / "si_script_0.py"
try:
compile(script.read_text(), str(script), "exec")
return "compiles"
except SyntaxError as e:
return f"SyntaxError: {e.msg} (line {e.lineno})"
if __name__ == "__main__":
recording = generate_recording(num_channels=4, durations=[5.0], seed=0)
with tempfile.TemporaryDirectory() as tmp:
print("raw: ", slurm_script(recording, Path(tmp) / "raw"))
print("filtered:", slurm_script(bandpass_filter(recording), Path(tmp) / "filtered"))
print("sliced: ", slurm_script(recording.select_channels(recording.channel_ids[:2]), Path(tmp) / "sliced"))
# Output:
# raw: compiles
# filtered: SyntaxError: invalid decimal literal (line 6)
# sliced: SyntaxError: invalid decimal literal (line 6)
# Expected: the script compiles in all three cases.
A string or path argument containing a quote or a backslash also breaks the script (lines 183-186).
Fix: write the recording to a JSON or pickle file next to the script and load it from there.
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 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
available bug good first issue tooling
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Nixitov/Riptide-Native#816 ·
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 70/100
teng-lin/notebooklm-py#2593 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
claimed-by:collie role:small-fix status:running
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Beovulfo/herd-sdlc#325 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
good first issue
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 94/100
omarelshamy25x/shamy-arabic-nlp#267 ·
Maintainer thường phản hồi trong vòng 1 ngày