Add comparison level validation check #1926
Merged
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.
Type of PR
Is your Pull Request linked to an existing Issue or Pull Request?
Tags onto #1921 and addresses a "bug" that Chloe was getting in one of our pipeline runs.
Give a brief description for the solution you have provided
Previously, if a user attempted to use a comparison as a comparison level, they would be greeted with a "not JSON serializable" error:
![Screenshot 2024-02-05 at 11 20 39](https://private-user-images.githubusercontent.com/45356472/302271147-2ba438b1-d5ef-4ded-bde8-995e3f253b6c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzNDAxNjIsIm5iZiI6MTczOTMzOTg2MiwicGF0aCI6Ii80NTM1NjQ3Mi8zMDIyNzExNDctMmJhNDM4YjEtZDVlZi00ZGVkLWJkZTgtOTk1ZTNmMjUzYjZjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEyVDA1NTc0MlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWI1YzAwZDU2MmNmMDQ1ODI5MTVkMWUzODRiZmM0Y2E0ZDQzNjkxYzVhM2I4MTRlNGRmZmNlODFhYjZkNmE5YWEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.uX_Nft384vaqgFaxzG-IsWPIfs9yNtrLHyIKcxv71nY)
due to
Comparison
not being "dumpable" - https://github.com/moj-analytical-services/splink/blob/master/splink/validate_jsonschema.py#L65.This is hard to interpret and debug for anyone unfamiliar with Splink.
This PR primarily aims to address this by adding an explicit validation check for invalid comparison levels (i.e. a level that is neither a dict or a
ComparisonLevel
). This check is performed within thecheck_comparison_level_types
function, which simply loops through a Comparison and checks the data types within.Any errors identified will be added to the
ErrorLogger
and printed to console once all settings have been checked.Example of new breakdown with broken settings
Other Changes
ErrorLogger
class. This now has more descriptive method names, easier to interpret code and logs the errors in red text (more on this below).settings_validation_log_strings.py
.sorted()
method fromevaluate_comparison_dialects
and switched off SplinkDeprecation warnings unless requested by the user.PR Checklist