Skip to content

Handle missing root communities in dynamic selection#2413

Open
Kevin-Li-2025 wants to merge 1 commit into
microsoft:mainfrom
Kevin-Li-2025:kevin/dynamic-community-missing-root
Open

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

Conversation

@Kevin-Li-2025

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

@Kevin-Li-2025 Kevin-Li-2025 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