Skip to content

Fix AnchorText metadata including invalid parameters (#459)#1063

Open
rodriguescarson wants to merge 1 commit into
SeldonIO:masterfrom
rodriguescarson:fix/anchortext-metadata-invalid-params
Open

Fix AnchorText metadata including invalid parameters (#459)#1063
rodriguescarson wants to merge 1 commit into
SeldonIO:masterfrom
rodriguescarson:fix/anchortext-metadata-invalid-params

Conversation

@rodriguescarson

Copy link
Copy Markdown

Fixes #459

Problem

AnchorText.meta['params'] recorded all parameters passed via kwargs, including misspelled or otherwise invalid ones. _validate_kwargs returned two dicts — perturb_opts (only the validated perturbation params) and all_opts (the defaults plus the raw kwargs) — and __init__ updated the metadata from all_opts:

self.perturb_opts, all_opts = self._validate_kwargs(...)
...
self.meta['params'].update(**all_opts)

So an invalid key like sampl_proba=0.6 (typo) would be logged as incorrect but still leak into meta['params'].

Fix

Per the issue, record only the validated self.perturb_opts in the metadata, and drop all_opts entirely — _validate_kwargs is only called here, so it now returns just perturb_opts:

  • self.meta['params'].update(**self.perturb_opts)
  • _validate_kwargs return type Tuple[dict, dict]dict; removed the all_opts deepcopy/update.

Test

Added test_metadata_excludes_invalid_params (mirrors test_neighbors, using the nlp fixture): constructs an AnchorText with one valid (sample_proba) and one invalid (not_a_real_param) kwarg and asserts the invalid one is absent from meta['params'] while the valid one is retained.

I wasn't able to run the full test suite locally (it needs the spaCy model + heavy deps), but both files parse cleanly and the change matches the fix described in the issue.

🤖 Generated with Claude Code

AnchorText.meta['params'] was updated with all_opts, which _validate_kwargs
populated from the raw kwargs and therefore included misspelled/invalid
parameter names. Record only the validated perturbation parameters
(self.perturb_opts) instead, and drop the now-unused all_opts from
_validate_kwargs (its sole caller no longer needs it).

Adds a regression test asserting invalid kwargs are excluded from meta['params']
while valid perturbation params are retained.

Fixes SeldonIO#459
@CLAassistant

CLAassistant commented Jul 2, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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.

AnchorText - fix metadata

2 participants