feat: Allow users to set custom rule names#274
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #274 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 54 54
Lines 3125 3129 +4
=========================================
+ Hits 3125 3129 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR adds a name parameter to the @dy.rule() decorator, allowing users to specify custom, user-friendly names for validation rules that will appear in failure reports. This addresses part of issue #122, which requested the ability to assign friendly names to rules for better failure reporting.
Changes:
- Added optional
nameparameter to@dy.rule()decorator for custom rule naming - Implemented validation to prevent duplicate rule names and reserved name conflicts (e.g., "primary_key")
- Added tests for custom rule names in both regular and group rules, plus error cases
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
dataframely/_rule.py |
Added name parameter to RuleFactory.__init__() and rule() decorator with updated docstring |
dataframely/_base_schema.py |
Updated metadata extraction to use custom names, added validation for duplicate and reserved names |
tests/schema/test_rule_implementation.py |
Added tests for illegal rule names (reserved "primary_key") and duplicate custom names |
tests/schema/test_filter.py |
Added tests verifying custom rule names appear correctly in FailureInfo.counts() for both regular and group rules |
borchero
left a comment
There was a problem hiding this comment.
I'm not sure you can answer that question because you didn't write the initial issue report... 😄 but what's the rationale of assigning custom names to rules but not being able to provide custom names to column-level checks 🤔
Motivation
Addresses part of #122
Changes
nameargument tody.rule, which allows users to set a custom name that will show up in any failure outputs.