Skip to content

Leonlu2/error on geo values #1095

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

Merged
merged 30 commits into from
Mar 29, 2023
Merged

Leonlu2/error on geo values #1095

merged 30 commits into from
Mar 29, 2023

Conversation

LeonLu2
Copy link
Collaborator

@LeonLu2 LeonLu2 commented Feb 23, 2023

process about #641

Prerequisites:

  • Unless it is a documentation hotfix it should be merged against the dev branch
  • Branch is up-to-date with the branch to be merged with, i.e. dev
  • Build is successful
  • Code is cleaned up and formatted

Summary

  1. add valid geo_value validator in _params
  2. modified test_covidcast and test_delphi_epidata for server geo_value validation passing
  3. help wanted and added TODO in test files for patch and mock the return values of geo validator in server

2. modified test_covidcast and test_delphi_epidata for server geo_value validation passing
3. add TODO for patch and mock part
@LeonLu2 LeonLu2 requested a review from krivard February 23, 2023 19:42
Copy link
Collaborator

@melange396 melange396 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good job! i found a few things that might help reduce repetition and clean it up a bit

Comment on lines 472 to 474
for geo_value in geo_values:
if geo_value not in delphi_utils.geomap.GeoMapper().get_geo_values(geo_type):
raise ValidationFailedException("invalid geo_value for the requested geo_type")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is cool! A few notes though:

  • You should put it in a constructor for GeoSet instead (here), and then youl'l get this check for free in the call to parse_geo_arg() below (among other places).
  • It would be good for the Exception to include which of the specified geo_values is the offender.
  • nit: you can call/create GeoMapper() outside of the loops so its only done once

Comment on lines 25 to 27
fips = ['04019', '19143', '29063'] # Example list of valid FIPS codes as strings
msa = ['40660', '44180', '48620'] # Example list of valid MSAs as strings

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you might wanna put these into src/acquisition/covidcast/test_utils.py so they can be shared with other tests and dont have to be repeatedly defined in each test file. you could maybe even make them defaults in CovidcastTestRow in test_utils.py, and you wont have to specify them in every call to make_default_row()!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@melange396 thanks for jumping in on this review! i should provide some context for this particular change though: initially the plan was to mock out the GeoMapper calls in tests so that we wouldn't need to use actual FIPS and MSA codes. Leon hasn't had much mocking experience though, and we tried multiple ways to get it to work with no luck. so having these constants is a sortof stopgap to get this PR out, but i don't think they're a good solution long term.

what do you think, keep the constants, or find a mock wizard (a wizard at mock, not a sham magician) to take a look?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont think using those constants is all that bad, though not as nice as a mock. one argument against using mocks is that theyll hide (from the tests, at least) any changes to the arguments or output of the GeoMapper. i think the constants can stick around for now (especially if we put them in one place), but definitely keep that TODO comment along with them.

LeonLu2 and others added 5 commits February 23, 2023 19:18
… geo_value is invalid in the message

2. move the valid FIPS and MSA codes to test_utils.py, and import them when needed.
3. fix other failed places related to this change
Copy link
Contributor

@krivard krivard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 nice work!

Copy link
Contributor

@krivard krivard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh except the delete batch test is still failing; we should hold for that

Copy link
Collaborator

@melange396 melange396 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fantastic job! just found a few little things...

@LeonLu2
Copy link
Collaborator Author

LeonLu2 commented Mar 3, 2023

Oh except the delete batch test is still failing; we should hold for that

Yea I haven't finished working on this😂, I accidentally pushed after the commit

@LeonLu2 LeonLu2 requested review from krivard and melange396 March 20, 2023 18:44
Copy link
Collaborator

@melange396 melange396 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is lookin really good, and i think its almost ready. the only things left are 3 unresolved comments in integrations/server/test_covidcast.py and some format-tidying suggestions i made in tests/server/test_params.py.

melange396
melange396 previously approved these changes Mar 21, 2023
Copy link
Collaborator

@melange396 melange396 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks great! very nice job!

@LeonLu2
Copy link
Collaborator Author

LeonLu2 commented Mar 22, 2023

looks great! very nice job!

thanks :)

Copy link
Contributor

@krivard krivard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small confusion about placeholder set three

Copy link
Contributor

@krivard krivard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 nice work!

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants