Repository navigation
Fix compilation workflow - #16819
Fix compilation workflow#16819
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe dataset navigation compiler now stores documents in hierarchical ChangesDataset navigation hierarchy
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant Caller
participant upsert_dataset_nav_doc
participant embd_mdl
participant RedisDistributedLock
participant docStoreConn
Caller->>upsert_dataset_nav_doc: provide document summary
upsert_dataset_nav_doc->>embd_mdl: encode summary
upsert_dataset_nav_doc->>RedisDistributedLock: acquire tenant lock
upsert_dataset_nav_doc->>docStoreConn: search cluster hierarchy
upsert_dataset_nav_doc->>docStoreConn: upsert nav_cluster and nav_doc
upsert_dataset_nav_doc->>docStoreConn: split cluster when thresholds are exceeded
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (3 warnings)
✅ Passed checks (2 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@rag/advanced_rag/knowlege_compile/dataset_nav.py`:
- Around line 561-566: In the lock acquisition handling around
lock.spin_acquire(), do not continue into the clustering upsert when acquisition
fails. After logging the exception, return from the enclosing operation or
re-raise the exception so the write block executes only after the distributed
lock is successfully acquired.
- Around line 435-437: Update the best-candidate advancement logic near
best_name and sim so best_parent is read from the same child node being
selected, rather than from the stale best node; ensure parent_for_new receives
the child’s parent_kwd and remains synchronized with best_name.
- Around line 899-901: In both loops around the child-row lookups, stop
inferring row type from the `kn` string or its `navc_` prefix. Use the
already-fetched `type_kwd` value to distinguish `nav_doc` from cluster rows,
then call `_nav_doc_id` for document rows and `_nav_cluster_id` for cluster rows
before `_es_get`.
- Around line 630-643: In the new-cluster creation logic, update the
_make_nav_cluster_row call to pass new_depth instead of depth_of_parent so the
cluster depth reflects its child position; also remove the redundant conditional
vector assignment using _vec_field.
In `@test/unit_test/rag/advanced_rag/knowlege_compile/test_dataset_nav.py`:
- Around line 308-310: Rename the ids_stable test method to test_ids_stable so
pytest collects and executes the assertions for _nav_doc_id and _nav_cluster_id.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 78b1f269-b5c7-4357-9df9-3f2774e4a86d
📒 Files selected for processing (3)
conf/infinity_mapping.jsonrag/advanced_rag/knowlege_compile/dataset_nav.pytest/unit_test/rag/advanced_rag/knowlege_compile/test_dataset_nav.py
| best_name = child.get("name", best_name) | ||
| best_parent = best.get("parent_kwd", best_parent) | ||
| sim = child_sim |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
file="rag/advanced_rag/knowlege_compile/dataset_nav.py"
# Show the relevant area with line numbers
sed -n '380,480p' "$file" | cat -n
# Find the surrounding function and any uses of best_parent / parent_for_new
rg -n -C 4 "best_parent|parent_for_new|parent_kwd|best_name|child_sim|sim = child_sim" "$file"
# Print a slightly larger context around the suspect block
python3 - <<'PY'
from pathlib import Path
path = Path("rag/advanced_rag/knowlege_compile/dataset_nav.py")
lines = path.read_text().splitlines()
for i in range(400, 460):
if i <= len(lines):
print(f"{i:4d}: {lines[i-1]}")
PYRepository: infiniflow/ragflow
Length of output: 14699
best_parent needs to advance with best_name. In rag/advanced_rag/knowlege_compile/dataset_nav.py:435-437, best.get("parent_kwd") still reads the old node, so once best moves to child, best_parent becomes the grandparent. That sends parent_for_new to the wrong cluster.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@rag/advanced_rag/knowlege_compile/dataset_nav.py` around lines 435 - 437,
Update the best-candidate advancement logic near best_name and sim so
best_parent is read from the same child node being selected, rather than from
the stale best node; ensure parent_for_new receives the child’s parent_kwd and
remains synchronized with best_name.
| new_depth = depth_of_parent + 1 | ||
| new_name = f"navc_{xxhash.xxh64(summary.encode()).hexdigest()[:12]}" | ||
| new_desc = await _llm_create_summary(chat_mdl, [summary]) | ||
| new_cluster = _make_nav_cluster_row( | ||
| kb_id, | ||
| new_name, | ||
| new_desc, | ||
| parent_for_new, | ||
| depth_of_parent, | ||
| [doc_id], | ||
| doc_embedding, | ||
| ) | ||
| if embd_mdl and doc_embedding: | ||
| new_cluster[_vec_field(len(doc_embedding))] = doc_embedding |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
file='rag/advanced_rag/knowlege_compile/dataset_nav.py'
echo '--- lines 560-690 ---'
sed -n '560,690p' "$file" | cat -n
echo '--- _make_nav_cluster_row definition ---'
rg -n "def _make_nav_cluster_row|_make_nav_cluster_row\(" "$file" -n -A 40 -B 20
echo '--- _vec_field definition ---'
rg -n "def _vec_field|_vec_field\(" "$file" -n -A 20 -B 10
echo '--- depth assignments around branch names ---'
rg -n "new_depth|depth_of_parent|nav_doc|merge branch|root branch|parent_for_new" "$file" -n -A 8 -B 8Repository: infiniflow/ragflow
Length of output: 35931
🏁 Script executed:
#!/bin/bash
set -euo pipefail
file='rag/advanced_rag/knowlege_compile/dataset_nav.py'
sed -n '340,420p' "$file" | cat -n
echo '---'
sed -n '600,670p' "$file" | cat -nRepository: infiniflow/ragflow
Length of output: 6100
Use new_depth for the new cluster. The cluster is created under parent_for_new, so its depth_int should be new_depth; otherwise the cluster and its nav_doc end up at the same depth. The extra vector assignment is redundant and can be removed.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@rag/advanced_rag/knowlege_compile/dataset_nav.py` around lines 630 - 643, In
the new-cluster creation logic, update the _make_nav_cluster_row call to pass
new_depth instead of depth_of_parent so the cluster depth reflects its child
position; also remove the redundant conditional vector assignment using
_vec_field.
| def ids_stable(self, nav): | ||
| assert nav._nav_doc_id("x") == nav._nav_doc_id("x") | ||
| assert nav._nav_cluster_id("kb", "c") == nav._nav_cluster_id("kb", "c") |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
ids_stable is never collected — missing test_ prefix.
pytest only collects functions prefixed with test_, so ids_stable silently never runs and the ID-stability guarantee is untested.
💚 Proposed fix
- def ids_stable(self, nav):
+ def test_ids_stable(self, nav):
assert nav._nav_doc_id("x") == nav._nav_doc_id("x")
assert nav._nav_cluster_id("kb", "c") == nav._nav_cluster_id("kb", "c")📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| def ids_stable(self, nav): | |
| assert nav._nav_doc_id("x") == nav._nav_doc_id("x") | |
| assert nav._nav_cluster_id("kb", "c") == nav._nav_cluster_id("kb", "c") | |
| def test_ids_stable(self, nav): | |
| assert nav._nav_doc_id("x") == nav._nav_doc_id("x") | |
| assert nav._nav_cluster_id("kb", "c") == nav._nav_cluster_id("kb", "c") |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@test/unit_test/rag/advanced_rag/knowlege_compile/test_dataset_nav.py` around
lines 308 - 310, Rename the ids_stable test method to test_ids_stable so pytest
collects and executes the assertions for _nav_doc_id and _nav_cluster_id.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
rag/advanced_rag/knowlege_compile/dataset_nav.py (1)
900-918: 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy liftSplit needs to rewrite the parent row and recurse descendant depths
- Clear or recompute
cluster_name’sdoc_ids_kwd/doc_count_intafter reparenting; the current row still reflects the pre-split membership.- Propagate
depth_intto nestednav_clusterdescendants too; the update here only adjusts the immediate children.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@rag/advanced_rag/knowlege_compile/dataset_nav.py` around lines 900 - 918, The split logic around _make_nav_cluster_row and the child reparenting loop must update the parent cluster after membership changes and recursively adjust descendant depths. Recompute cluster_name’s doc_ids_kwd and doc_count_int from its final children (or clear them if appropriate), persist the revised parent row, and traverse nested nav_cluster descendants to set each depth_int relative to the new parent before upserting them.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@rag/advanced_rag/knowlege_compile/dataset_nav.py`:
- Around line 900-918: The split logic around _make_nav_cluster_row and the
child reparenting loop must update the parent cluster after membership changes
and recursively adjust descendant depths. Recompute cluster_name’s doc_ids_kwd
and doc_count_int from its final children (or clear them if appropriate),
persist the revised parent row, and traverse nested nav_cluster descendants to
set each depth_int relative to the new parent before upserting them.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e347da78-f4d7-49c2-960d-69464216d4f4
📒 Files selected for processing (1)
rag/advanced_rag/knowlege_compile/dataset_nav.py
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #16819 +/- ##
=======================================
Coverage 93.16% 93.16%
=======================================
Files 10 10
Lines 717 717
Branches 118 118
=======================================
Hits 668 668
Misses 29 29
Partials 20 20 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Dataset_nav can not support large number of documents, introducing AHC clustering as well as retrieval engine as the clustering database