Stream the graph/ validation in flpq-check-archive (fix the #188 OOM)
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- Nửa ngày
- Mức phù hợp với người mới
- 45/100
Hướng nghiên cứu
Start in flpq_data/tools/check_archive_structure.py at _validate_root (around line 603), which calls graph_from_mtx_dir only for its ValueError side effect, and at the local _mtx_entries and _mtx_header helpers. Read iter_edges_from_mtx_dir in flpq_data/graphs/readwrite/mtx.py to see how it raises on header, malformed-line and nnz-mismatch errors. Done when the graph/ check consumes the edge stream without building a MultiDiGraph, a regression test still rejects nnz-mismatched and malformed graph directories, and each format problem is reported exactly once.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Motivation
flpq-check-archive OOMs on large graph archives (#188): _validate_root materializes the entire graph into an in-memory nx.MultiDiGraph via graph_from_mtx_dir, purely for its ValueError side effect (the return value is discarded). This task makes the graph/ validation stream (O(1) in edges), restoring the streaming design of the main archive pipeline. Because the materialization sits in the shared validate_archive, fixing it once repairs every archive-lifecycle tool.
Root cause (why it was missed)
The streaming decision (#153, motivated by #138) was scoped to format conversion (convert_graph) — not to validation. The docs designate graph_from_*/graph_to_* as the "NetworkX boundary" where materialization is legitimate (docs/graphs/index.rst "The NetworkX boundary"; docs/file_structure.rst:74 "A whole directory is loaded by graph_from_mtx_dir"). The checker (#165, after #153) used graph_from_mtx_dir because:
- It is the documented way to read a graph directory.
- It is the only thing that bundles all three format-error classes (bad header, malformed entry line, nnz mismatch) in one
ValueError. - The checker's local streaming helpers do not cover all three:
_mtx_entries(line 256) skips the nnz check, and_mtx_header(line 237) returnsNoneinstead of raising. - It only breaks at scale: small test graphs are fine; the OOM surfaces on
pokec(30M edges) /yago2s(77M edges) from #187, so it passed every test.
Scope (one shared choke point)
The materialization is in _validate_root (flpq_data/tools/check_archive_structure.py:603), inside validate_archive. Every archive-lifecycle tool funnels through it, so the single bug OOMs all of them:
flpq-check-archiveCLI (direct)utils/upload_to_s3.py:180(validates before any.tar.gzupload)utils/merge_archive.py:166,169,242(validates 3×: existing, partial, merged)utils/add_reachable_pairs.py:276utils/strip_reverse_edges.py:204
Fixing _validate_root once repairs all five. No other part of the main pipeline materializes unnecessarily — the rest (graph_from_*/graph_to_*, the generators, the adjacency utilities, query materialization, and the RDF source) is the documented, intentional NetworkX boundary.
Design decisions (confirmed)
D1. Stream the format check. Replace the graph_from_mtx_dir(root / "graph") call with a full streaming consumption of the shared iter_edges_from_mtx_dir (flpq_data/graphs/readwrite/mtx.py), catching the same (ValueError, OSError). It raises on exactly the three error classes (header / malformed line / nnz mismatch — the nnz check fires on exhaustion, so the loop must run to completion). O(1) in edges.
D2. Consolidate the local duplicate (reuse). Fold the checker's local _mtx_entries (and, where it fits, _mtx_header) onto the shared iter_edges_from_mtx_dir so the checker has a single streaming reader — honoring "one source of truth / no duplicates". Care needed: the local helpers currently skip format-broken files to avoid double-reporting (the "already reported" comments at lines 288/301/303), so the consolidated pass must report each problem exactly once.
Plan
- S1. Swap the materializing call in
_validate_rootfor a streaming consumption ofiter_edges_from_mtx_dir; drop thegraph_from_mtx_dirimport. Add a regression test that a graph dir with a nnz mismatch / malformed line is still rejected, and that validation does not build aMultiDiGraph(e.g. assert the reader used is the streaming one, or run on a dir sized to OOM under materialization). - S2. Consolidate
_mtx_entries/_mtx_headerontoiter_edges_from_mtx_dir; ensure format problems are reported exactly once (no double-reporting, no silent skips). Update the "already reported" comments. - S3. Docs: note that archive validation streams — the
graph/check is O(1) in edges, consistent with the conversion path (map the code change to the doc update per the documentation skill). - S4. Verify the entry points run on a large archive without OOM (at least
flpq-check-archiveand theupload_to_s3validation path); run the quality gate.
Closes #188.
- Ngôn ngữ chính
- Python
- Star
- 13
- Fork
- 16
- Merge trung bình
- 1 ngày 15 giờ
- Pull request đã merge (30 ngày)
- 7
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Không có hướng dẫn đóng góp
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 FormalLanguageConstrainedPathQuerying/FLPQ_Data
-
documentation task
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
-
task
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
FormalLanguageConstrainedPathQuerying/FLPQ_Data#185 · 1 bình luận ·
-
Page title is CFPQ_DataĐang mởbug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
-
task
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 58/100
FormalLanguageConstrainedPathQuerying/FLPQ_Data#192 · 1 bình luận ·
-
enhancement task
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 12/100
Tất cả issue của FormalLanguageConstrainedPathQuerying/FLPQ_Data
Issue tương tự
-
separate_packages splits imports from the same explicitly configured packageCó thể đã có người làm @rahul05ranjan đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
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 66/100
TigreGotico/text2spoken#626 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
oncoref MappingProxyType in proteome.layers breaks deepcopy in reference_coverage._inventoryCó thể đã có người làm @iskandr đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
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 82/100
pipecat-ai/pipecat#7014 ·
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 62/100
NL-BioImaging/biomero#136 ·
Maintainer thường phản hồi trong vòng 1 ngày