feat/Add --checks option to filter great-expectations export by quality/properties - #1617
Open
julienguilhempartner-spec wants to merge 15 commits into
Open
julienguilhempartner-spec wants to merge 15 commits into
julienguilhempartner-spec wants to merge 15 commits into
Conversation
Co-authored-by: julienguilhempartner-spec <276929201+julienguilhempartner-spec@users.noreply.github.com>
…cument --checks option
…options-for-export-great-expectations Add --checks option to filter great-expectations export by quality/properties
jschoedl
requested changes
Sep 16, 2026
Comment on lines
+581
to
+595
| def _parse_great_expectations_checks(value: Optional[str]) -> Optional[set[str]]: | ||
| """Parse `--checks` into a set of `GreatExpectationsCheckCategory` values, or None if omitted.""" | ||
| if value is None: | ||
| return None | ||
| categories = {v.strip().lower() for v in value.split(",") if v.strip()} | ||
| if not categories: | ||
| console.print("[red]Empty --checks specified.[/red]") | ||
| console.print(f"Available categories: {', '.join(sorted(_GE_VALID_CHECKS))}") | ||
| raise typer.Exit(code=1) | ||
| invalid = categories - _GE_VALID_CHECKS | ||
| if invalid: | ||
| console.print(f"[red]Invalid --checks specified: {', '.join(sorted(invalid))}[/red]") | ||
| console.print(f"Available categories: {', '.join(sorted(_GE_VALID_CHECKS))}") | ||
| raise typer.Exit(code=1) | ||
| return categories |
Collaborator
There was a problem hiding this comment.
This functionality is already implemented in _parse_enum_csv(...) in command_test.py. Please move it to datacontract/cli.py and only import it here.
Contributor
Author
There was a problem hiding this comment.
Done! ✅
Moved _parse_enum_csv() to cli.py as a reusable utility (commit dc41a0d). Removed duplicate _parse_great_expectations_checks() from command_export.py. Both command modules now import from cli.py.
Co-authored-by: Jakob Schödl <jakob.schoedl@mailbox.org>
Co-authored-by: Jakob Schödl <jakob.schoedl@mailbox.org>
Co-authored-by: Jakob Schödl <jakob.schoedl@mailbox.org>
Co-authored-by: Jakob Schödl <jakob.schoedl@mailbox.org>
Co-authored-by: Jakob Schödl <jakob.schoedl@mailbox.org>
- Move generic _parse_enum_csv() from command_test.py to datacontract/cli.py - Update command_export.py to use _parse_enum_csv instead of _parse_great_expectations_checks - Remove duplicate function _parse_great_expectations_checks and _GE_VALID_CHECKS constant - Update command_test.py to import _parse_enum_csv from cli - All tests pass (44 tests for Great Expectations export verified)
Remove the deferred CLI registration code that was causing F401 errors for unused imports in cli.py. This code was not needed for the refactoring of _parse_enum_csv to cli.py.
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.
Summary:
Adds a
--checksoption todatacontract export great-expectationsallowing users to filter exported expectations by category:quality(rules from contractquality:blocks) and/orproperties(constraints inferred from logical types). Omit the option to export both (unchanged behavior).Key Changes:
great_expectations_exporter.py— NewGreatExpectationsCheckCategoryenum, fail-fast validation of categories, and conditional generation logic that skips property constraint processing whenpropertiesis not selected.command_export.py— New--checksCLI option with dedicated parsing and validation.great-expectations.md— Documentation of the new option.test_export_great_expectations.py— Tests covering filtering, validation, and regression fix for unsupported types.