-
Notifications
You must be signed in to change notification settings - Fork 135
[curate apply-geolocation-rules] treat '?' values akin to empty values #1929
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jameshadfield
wants to merge
2
commits into
master
Choose a base branch
from
james/curate-geo-question-marks
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
61 changes: 61 additions & 0 deletions
61
tests/functional/curate/cram/apply-geolocation-rules/question-mark-values.t
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| Setup | ||
|
|
||
| $ export AUGUR="${AUGUR:-$TESTDIR/../../../../../bin/augur}" | ||
|
|
||
| We sometimes use question marks '?' as an unknown field. `augur curate apply-record-annotations` | ||
| special-cases these so that they aren't interpreted as a valid value. | ||
|
|
||
| This test uses real data from seasonal-flu where this bug was first observed | ||
|
|
||
| Rules taken directly from `augur/data/geolocation_rules.tsv` as at c8181c7 | ||
|
|
||
| $ cat >rules.tsv <<~~ | ||
| > Asia/Bangladesh/Jashore/ Asia/Bangladesh/Khulna/Jashore | ||
| > Asia/Bangladesh/Jashore/* Asia/Bangladesh/Khulna/* | ||
| > ~~ | ||
|
|
||
| Fist check that if the division is EMPTY then the first rule is applied, as we expect | ||
|
|
||
| $ echo '{"region": "Asia", "country": "Bangladesh", "division": "Jashore", "location": ""}' \ | ||
| > | ${AUGUR} curate apply-geolocation-rules --no-default-rules --geolocation-rules rules.tsv | ||
| {"region": "Asia", "country": "Bangladesh", "division": "Khulna", "location": "Jashore"} | ||
|
|
||
| but if the location is a "?", which is the case in our seasonal-flu ingest pipeline we want to use the first rule too | ||
| rather than interpreting "?" as a valid location to preserve | ||
|
|
||
|
|
||
| $ echo '{"region": "Asia", "country": "Bangladesh", "division": "Jashore", "location": "?"}' \ | ||
| > | ${AUGUR} curate apply-geolocation-rules --no-default-rules --geolocation-rules rules.tsv | ||
| {"region": "Asia", "country": "Bangladesh", "division": "Khulna", "location": "Jashore"} | ||
|
|
||
|
|
||
| Edge case: preserve '?' in the output if we don't replace it via a rule | ||
|
|
||
| $ echo '{"region": "Asia", "country": "X", "division": "?", "location": "?"}' \ | ||
| > | ${AUGUR} curate apply-geolocation-rules --no-default-rules --geolocation-rules rules.tsv | ||
| {"region": "Asia", "country": "X", "division": "?", "location": "?"} | ||
|
|
||
|
|
||
| This works for multiple fields in a work-backwards fashion | ||
|
|
||
| $ cat >rules.tsv <<~~ | ||
| > North America/USA Alabama// North America/USA/Alabama/ | ||
| > ~~ | ||
|
|
||
| $ echo '{"region": "North America", "country": "USA Alabama", "division": "", "location": ""}' \ | ||
| > | ${AUGUR} curate apply-geolocation-rules --no-default-rules --geolocation-rules rules.tsv | ||
| {"region": "North America", "country": "USA", "division": "Alabama", "location": ""} | ||
|
|
||
| Note that the corrected location is '?', not '' which the rule may suggest -- we attempt to preserve the empty-string value which is used | ||
| $ echo '{"region": "North America", "country": "USA Alabama", "division": "?", "location": "?"}' \ | ||
| > | ${AUGUR} curate apply-geolocation-rules --no-default-rules --geolocation-rules rules.tsv | ||
| {"region": "North America", "country": "USA", "division": "Alabama", "location": "?"} | ||
|
|
||
| NOTE: but division=? and location=empty string (or vice-versa) doesn't work - it's expected that the missing-value is used consistently | ||
| $ echo '{"region": "North America", "country": "USA Alabama", "division": "?", "location": ""}' \ | ||
| > | ${AUGUR} curate apply-geolocation-rules --no-default-rules --geolocation-rules rules.tsv | ||
| {"region": "North America", "country": "USA Alabama", "division": "?", "location": ""} | ||
|
|
||
| $ echo '{"region": "North America", "country": "USA Alabama", "division": "", "location": "?"}' \ | ||
| > | ${AUGUR} curate apply-geolocation-rules --no-default-rules --geolocation-rules rules.tsv | ||
| {"region": "North America", "country": "USA Alabama", "division": "", "location": "?"} |
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: instead of adding duplicate rule entries for a new null value, add logic for different null values on the data. Something like this: 5588acb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll defer to @joverlee521 here - my heads mostly focused on the downstream fixes this entails rather than the specific way it's fixed. I'm happy to change to your approach as desired.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @victorlin, I like 5588acb!
We can come back to this at a later date since the seasonal-flu ingest is changing the
?values to empty strings as discussed in nextstrain/seasonal-flu#267 (comment).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, easy fix!