Skip to content

fix(dedup): accept single-element input_keys in deduplicate filters - #553

Merged
SunnyHaze merged 1 commit into
OpenDCAI:mainfrom
raams95:fix/dedup-single-element-input-keys
Oct 13, 2026
Merged

SunnyHaze merged 1 commit into
OpenDCAI:mainfrom
raams95:fix/dedup-single-element-input-keys

Conversation

@raams95

@raams95 raams95 commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Summary

The deduplicate filters accept either input_key or input_keys. When input_keys is a list with a single column (for example input_keys=["text"]), run() takes the single-column branch, but that branch reads sample[self.input_key]. self.input_key is None in that case, so the operator crashes with KeyError: None on the first row.

storage = ...  # dataframe with a "text" column
HashDeduplicateFilter().run(storage, input_keys=["text"])
# KeyError: None

The same line exists in six operators:

  • HashDeduplicateFilter
  • MinHashDeduplicateFilter
  • NgramHashDeduplicateFilter
  • SimHashDeduplicateFilter
  • SemDeduplicateFilter
  • CCNetDeduplicateFilter

Fix

When input_keys is given, the single-column branch now reads input_keys[0]. This makes input_keys=["text"] behave the same as input_key="text". Passing input_key or a list of several keys works exactly as it did before.

Tests

I added test/cpu_only/test_dedup_single_input_keys.py. For each CPU-only dedup filter, it checks that input_keys=["text"] gives the same filtered dataframe as input_key="text".

  • Before the fix: 5 failed (KeyError: None)
  • After the fix: 5 passed. The existing test/cpu_only/test_minhash_short_texts.py also still passes.
pytest test/cpu_only/test_dedup_single_input_keys.py test/cpu_only/test_minhash_short_texts.py -q
13 passed

SemDeduplicateFilter gets the same one-line change. The new test doesn't cover it because it needs torch/transformers and a BERT model.

Fixes #552

@SunnyHaze SunnyHaze left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@SunnyHaze
SunnyHaze merged commit 05488be into OpenDCAI:main Oct 13, 2026
6 checks passed
rikkurea-boop added a commit to rikkurea-boop/DataFlow that referenced this pull request Oct 13, 2026
rikkurea-boop added a commit to rikkurea-boop/DataFlow that referenced this pull request Oct 13, 2026
… storage PR

Preserve existing OpenDCAI#550 commits and test coverage while integrating
upstream OpenDCAI#551 batched output cache invalidation.
rikkurea-boop added a commit to rikkurea-boop/DataFlow that referenced this pull request Oct 13, 2026
Bring OpenDCAI#536, OpenDCAI#553 and OpenDCAI#551 upstream changes into the existing PR branch
without rebasing away the previously reviewed Text2Model commits.
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.

Deduplicate filters crash with KeyError: None when input_keys has a single element

2 participants