Skip to content

Fix delete_topics crash when custom labels are set - #2534

Open
gyanu2507 wants to merge 3 commits into
MaartenGr:masterfrom
gyanu2507:fix/delete-topics-custom-labels
Open

Fix delete_topics crash when custom labels are set#2534
gyanu2507 wants to merge 3 commits into
MaartenGr:masterfrom
gyanu2507:fix/delete-topics-custom-labels

Conversation

@gyanu2507

Copy link
Copy Markdown

I ran into this after set_topic_labelsdelete_topics() blows up with AttributeError: 'list' object has no attribute 'items'.

custom_labels_ is a list in topic-id order (that's what set_topic_labels stores). The delete path treated it as a dict. It also tried custom_labels_[-1] = "" when creating the outlier topic, which overwrites the last label instead of adding one for -1.

This remaps the surviving labels and writes them back as a list, including an empty label if -1 shows up for the first time.

Fixes #2529

custom_labels_ is a list aligned with sorted topic ids, so treating it as a dict raised AttributeError on delete.
Deleting topic 0 still leaves a topic 0 because remaining topics are renumbered by frequency.
kmeans remaps remaining clusters, so deleting one topic can leave the unique count unchanged.
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.

Topic deletion fails if topics have custom lables

1 participant