Fix #766: handle missing terms-of-use columns gracefully#1095
Open
bleedblack1 wants to merge 4 commits intomalariagen:masterfrom
Open
Fix #766: handle missing terms-of-use columns gracefully#1095bleedblack1 wants to merge 4 commits intomalariagen:masterfrom
bleedblack1 wants to merge 4 commits intomalariagen:masterfrom
Conversation
When sample sets don't have terms-of-use columns (terms_of_use_expiry_date, terms_of_use_url, unrestricted_use) in the manifest, the functions now raise descriptive ValueError messages instead of KeyError. Changes: - lookup_terms_of_use_info: Check for column existence before accessing - _sample_set_has_unrestricted_use: Validate unrestricted_use column exists - Both functions now provide clear error messages explaining missing data Fixes malariagen#766
Contributor
Author
|
All 34 tests pass locally on Python 3.11, including on the master branch.
Ready for review! @jonbrenas @tristanpwdennis |
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
Fixes #766
When
terms_of_use_expiry_dateorterms_of_use_urlcolumns are missingfrom the manifest (e.g. during pre-release), functions like
lookup_terms_of_use_info()and_sample_set_has_unrestricted_use()previously raised a cryptic
KeyError. They now raise a clear,descriptive
ValueErrorwith a helpful message.Changes
malariagen_data/anoph/base.py:lookup_terms_of_use_info(): gracefully handles missingterms-of-use columns, raises descriptive
ValueError_sample_set_has_unrestricted_use(): raises descriptiveValueErrorwhenunrestricted_usecolumn is missinglookup_terms_of_use_info()tests/anoph/test_base.py:test_lookup_terms_of_use_info_missing_columns: verifies correcterror when columns are missing
test_sample_set_has_unrestricted_use_missing_column: verifiescorrect error for missing
unrestricted_usecolumntest_sample_sets_no_terms_of_use: verifiessample_sets()still works when terms-of-use columns are absent
Test Results