Skip to content

Handle missing root communities in dynamic selection#2413

Open
yinli-systems wants to merge 1 commit into
microsoft:mainfrom
yinli-systems:kevin/dynamic-community-missing-root
Open

Handle missing root communities in dynamic selection#2413
yinli-systems wants to merge 1 commit into
microsoft:mainfrom
yinli-systems:kevin/dynamic-community-missing-root

Conversation

@yinli-systems

Copy link
Copy Markdown

Summary

Fixes #2382 by allowing DynamicCommunitySelection to initialize when the community hierarchy has no level 0 entries. In that case there are no root communities to seed the dynamic traversal, so the selector now starts with an empty queue instead of raising KeyError during construction.

Tests

  • git diff --check
  • PYTHONPYCACHEPREFIX=/private/tmp/graphrag-pycache /usr/bin/python3 -m py_compile packages/graphrag/graphrag/query/context_builder/dynamic_community_selection.py tests/unit/query/context_builder/dynamic_community_selection.py
  • UV_CACHE_DIR=/private/tmp/uv-cache-graphrag uv run ruff check packages/graphrag/graphrag/query/context_builder/dynamic_community_selection.py tests/unit/query/context_builder/dynamic_community_selection.py
  • UV_CACHE_DIR=/private/tmp/uv-cache-graphrag uv run ruff format --check packages/graphrag/graphrag/query/context_builder/dynamic_community_selection.py tests/unit/query/context_builder/dynamic_community_selection.py
  • UV_CACHE_DIR=/private/tmp/uv-cache-graphrag PYTHONPATH=packages/graphrag uv run --package graphrag pytest -q tests/unit/query/context_builder/dynamic_community_selection.py

@yinli-systems yinli-systems requested a review from a team as a code owner June 23, 2026 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DynamicCommunitySelection crashes with KeyError when no communities at level 0

1 participant