-
Notifications
You must be signed in to change notification settings - Fork 67
API server code health pass - rework parse* & extract* methods #1062
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
Conversation
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.
This looks pretty good, but out of curiousity: Did you do a straight copy of the 11 methods moved to _params.py
from _validate.py
and covidcast.py
, or did you make changes to them? Similarly, any changes in the test methods moved from test_validate.py
to test_params.py
? I presume there are no such changes, but i cant easily tell from the diffs shown by github.
...
also, optionally:
(if you dont want to do the following stuff now, its not a problem -- i will just put these comments into #998 for a future pass)
It would be nice if [for now] the only places request
is used as an import is in _params.py
(which is specifically used to get "parameters" from a "request"), in endpoints (which each legitimately process a "request"), in main.py
(which is effectively an endpoint itself), and in _common.py
(which uses it in the context of pre- and post-request app decorators)... To that end, can we:
- make the methods left in
_validate.py
takerequest
as a function argument instead of as an import? - change
print_non_standard()
andcreate_printer()
in_printer.py
to takeformat
as an argument instead of pulling it from the importedrequest
?
...which leaves _exceptions.py
, where the constructor for EpiDataException
uses request
in a hacky special-cased compatibility workaround. The subclasses of the exception make use of it too. We can leave that one alone [for now].
src/server/endpoints/covidcast.py
Outdated
from .._validate import( | ||
require_all, | ||
require_any, | ||
) |
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.
you can remove parens and newlines since this is now a single import
adec660
to
281d206
Compare
281d206
to
789fda2
Compare
@melange396 fixed some merge conflicts and your comment, so the PR should be good to review again! Regarding your followup questions:
|
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.
looks good, we will just need to remember to refer to my comment above regarding request
as an argument (in the subsequent PR)
Partially addresses #998.
Prerequisites:
dev
branchdev
Summary
Fixes a set of issues in the server code as described here.
parse_*
andextract_*
methods toparams.py
instead ofvalidate.py
.covidcast.py
.