Skip to content

Conversation

@majiayu000
Copy link

Summary

  • Fix type mismatch in DynamicCommunitySelection.select() where children IDs (integers) were not matching string report keys
  • Convert child to string before checking membership in self.reports

Problem

In dynamic_community_selection.py, the children list may contain integers while self.reports keys are strings. This causes if child in self.reports to always return False, skipping all child communities during dynamic selection.

Solution

Convert children IDs to strings using str(child) before checking membership and appending to communities_to_rate.

Test Plan

  • Added unit tests for both integer and string children scenarios
  • All existing unit tests pass
  • Static checks (ruff, pyright) pass

Fixes #2004

Convert children IDs to strings before checking membership in self.reports
to handle cases where children list contains integers while reports dict
uses string keys.

Fixes microsoft#2004

Signed-off-by: majiayu000 <1835304752@qq.com>
@majiayu000 majiayu000 requested a review from a team as a code owner December 28, 2025 02:38
@gaudyb
Copy link
Contributor

gaudyb commented Dec 29, 2025

Implemented in PR #2159 using this logic and #2124 PRs. Thank you!

@gaudyb gaudyb closed this Dec 29, 2025
@majiayu000 majiayu000 deleted the fix/dynamic-community-selection-type-mismatch branch December 30, 2025 01:38
gaudyb added a commit that referenced this pull request Dec 31, 2025
* fix issue #2004 using KeenhoChu idea in his PR

* add unit test for dynamic community selection

* add unit test for dynamic community selection implementing #2158 logic

---------

Co-authored-by: Gaudy Blanco <gaudy-microsoft@MacBook-Pro-m4-Gaudy-For-Work.local>
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.

[Bug]: DynamicCommunitySelection skips child communities because children IDs are int while self.reports keys are str

2 participants