Repository navigation
[feat] support label resolve to anonymize labels - #19
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟡 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_resolveto CLI (prep) andProcArgs, plus helpers for label schema resolution. - Update
cast_clsto supportValue-typed label columns, optional label resolution, and anonymization viaClassLabel(num_classes=...). - Update/extend tests and the
clsskill 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 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 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. | ||
|
|
This branch had an error being deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before submitting
Changes