Construction and state in extractors: a framework for serialization and saving
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ó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 25/100
Hướng nghiên cứu
Start by reading the linked discussions and changes in #4928, #4921, #4883, and #4671, then trace how extractors currently construct, serialize, and propagate state. The issue proposes a broad framework but asks whether the breakdown makes sense rather than specifying an implementation. Done would require agreement on state categories and consumer behavior before concrete changes can be scoped.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
I have written this after our discussion in our maintainers meeting today as I have been thinking about this and I want to write a big framework here before commenting with what we discussed today on Graham's issue #4928.
Several bugs we fixed or discussed recently come from the same place: we don't have clear boundaries between the construction of an extractor and the different kinds of state it holds, so each serialization or saving path decides on its own what to carry. Some examples:
- #4928: the noise levels are cached as a property, so they are returned without checking the parameters that produced them.
- #4921:
select_periodsdropped the properties, annotations, registered recording and start times of a sorting. - #4883: the Open Ephys reader set its timestamps with
set_times, and after #4671 that got them dumped to the dict as if a user had set them. set_timesandshift_timesdo nothing on a preprocessed recording or on a frame slice of a recording with a time vector.
In addition, I have a few more timing bugs of this kind that I haven't filed yet as I do not want someone to fix them with AI and then I will get caught up with reviewing them (I would like to merge #4931 as soon as possible).
The purpose of this issue is to establish a framework so we can agree on what kinds of state we have and what each of them requires, and come back to it as we solve these problems. An extractor holds four types of content:
| Type | Description | Examples |
|---|---|---|
| Construction | The arguments of the constructor. | read_spikeglx(folder_path, stream_id="imec0.ap") |
| Format data | Data the reader sets from the format during __init__. Rebuilding from the construction sets it again. |
the gains, the channel locations, inter_sample_shift, the probe, the native timestamps |
| User state | State the user sets after construction. Only the user knows it. | recording.set_property("brain_area", ...), set_times(), a probe attached by hand, annotations |
| Computed state | Values computed from the traces. They can be rebuilt but it costs time and sometimes involves randomness. | the noise levels, W and M of whiten |
Right now format data, user state and computed state go through the same setters, so the extractor can't tell them apart. #4883 is that case for the times, and the metadata dict discussed in #4928 would record the origin for properties.
The most important point about state in SpikeInterface is that which types are required depends on the consumer and not on the extractor:
| Consumer | Construction | Format data | User state | Computed state |
|---|---|---|---|---|
Pickling to a worker or deepcopy |
carry | rebuilt | carry* | carry |
| Saving to binary, zarr or another format | carry | carry | carry | carry |
Provenance (provenance.json) |
carry | drop | drop | drop |
Preprocessing (bandpass_filter(recording)) |
delegate | delegate until set* | drop | |
recording.frame_slice(start_frame, end_frame) |
delegate | delegate until set* | delegate until set, if still valid | |
recording.select_channels(channel_ids) |
delegate | delegate until set | delegate until set |
Delegate means the derived recording reads its parent's value each time instead of storing a copy, unless its own __init__ sets a different one, as scale_to_uV does with the gains. Delegate until set means the derived recording reads its parent's value until it sets its own, for example with set_times, and from then on it keeps its own.
* This is what I think the library should do. Right now it does something different, which I think is an error: pickling drops the properties and annotations set by the user, and set_times and shift_times do nothing on a preprocessed recording or on a frame slice of a recording with a time vector (shift_times throws an error there). A lot of the bugs that I mentioned are cases of this: state is mishandled by some consumer.
Also, note that this is a general categorization to get the point through. A specific multiprocessing job can need almost no state or only a very specific part of it. For example, the workers of get_noise_levels only read traces and need none of the user state but in most cases, because the multiprocessing chain is general, all the state should be propagated as such.
To illustrate how this can be helpful:
- #4928: the noise levels are computed state stored as a property like user state, so they travel without the parameters that produced them. With computed state in its own place together with its parameters,
get_noise_levelschecks them before returning the cached value, andcopy_metadatadrops all computed state by rule instead of through the hardcoded_skip_propertieslist. - #4883: the native timestamps of Open Ephys are format data, but the reader set them with
set_times, the setter for user state, so after #4671 they were dumped to the dict. With a setter for format data the reader would have used it and serialization would skip them by rule. The fix sets the time vector of the segment directly. - #4921:
select_periodsdropped the properties, annotations, registered recording and start times of a sorting as it overwrote the sorting before callingcopy_metadata. The framework doesn't prevent that kind of mistake, but the rule "a selection keeps the format data and the user state" becomes a generic test that every selection and preprocessing step should pass, and that test would have caught it.
I think that having a separate place for each type, or at least a record of where each value comes from, is the way forward. I wrote this so we can think these scenarios through as we solve those bugs and add more features to the library.
Does this breakdown make sense? Am I missing a type or a consumer?
@alejoe91 @samuelgarcia @grahamfindlay @JoeZiminski @chrishalcrow
- 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