Skip to content

[feat] support label resolve to anonymize labels - #19

Merged
Moenupa merged 3 commits into
mainfrom
feat/label-resolve
Sep 1, 2026
Merged

Moenupa merged 3 commits into
mainfrom
feat/label-resolve

Conversation

@Moenupa

@Moenupa Moenupa commented Sep 1, 2026

Copy link
Copy Markdown
Owner

Before submitting

Changes

  • Describe each feature or fix and link the related issue/PR.
  • I updated the tests.
  • I updated documentation.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

There are correctness/clarity gaps (misleading test naming/docs) and avoidable performance/behavior issues in cast_cls (full-column materialization and double JSON reads) that should be addressed before approval.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds a --label-resolve / LABEL_RESOLVE workflow to the cls formatter path so label names can be anonymized (while emitting sidecar mapping files) and wires the option through CLI → ProcArgs → cast_cls.

Changes:

  • Add label_resolve to CLI (prep) and ProcArgs, plus helpers for label schema resolution.
  • Update cast_cls to support Value-typed label columns, optional label resolution, and anonymization via ClassLabel(num_classes=...).
  • Update/extend tests and the cls skill documentation to cover the new behavior.
File summaries
File Description
tests/api/test_formatter.py Updates expectations for cast_cls behavior when labels aren’t configured.
src/prep/cli.py Adds --label-resolve CLI option and passes it into ProcArgs.
src/prep/api/types.py Extends ProcArgs with label_resolve and adds ClassLabel/resolve helpers.
src/prep/api/formatter.py Implements mapping dump + label anonymization and expands cast_cls label handling.
skills/prep/cls.md Documents label anonymization and resolve sidecar outputs.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 6
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/api/test_formatter.py
Comment thread src/prep/api/types.py Outdated
Comment thread src/prep/api/formatter.py
Comment thread src/prep/api/formatter.py
Comment thread src/prep/api/formatter.py
Comment on lines +195 to +199
original_feat = d.features.get("label")
if not isinstance(original_feat, (ClassLabel, Value)):
raise ValueError(
"Please provide labels via ENV `LABELS='cls1 cls2'`"
" or CLI option `--labels cls1 --labels cls2`."
f"Expected label feature to be ClassLabel or Value, got {type(original_feat)}"
)
Comment thread skills/prep/cls.md
Comment on lines +31 to +34
## Label resolution and anonymization

`--label-resolve <to-resolve>.json` (or the `LABEL_RESOLVE` env var) points to a JSON file keyed by `'label'` (as provided to `--labels`). During `cls` conversion, case names are anonymized in favor of case IDs: the `label` column stores only integer case IDs (the index of each case name in `--labels`), and class names are dropped from the saved feature.

@Moenupa
Moenupa merged commit 9f0d20e into main Sep 1, 2026
4 checks passed
@Moenupa
Moenupa deleted the feat/label-resolve branch September 1, 2026 09:38

This branch had an error being deployed

1 failed deployment
pypi — f4d3b848 Deployed Sep 1, 2026 by Moenupa via run #4
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.

2 participants