-
Notifications
You must be signed in to change notification settings - Fork 5
Consolidate fetch_*
interfaces
#72
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
Comments
Pro: this actually gives us Epidata errors for everything. (We could get it while using csv delivery with some tweaks/details but I'm not sure the server does this now.) Bug:
vs. delphi_epidata.R's
Potential Con: in some/all operating systems & R versions, R cannot give RAM back to the OS after its freed. So the RAM increase is not just before converting to tibble but also after. Probably fine; if you're working with a really large amount of data your downstream models and forecasts are probably really large too. |
Re: CSV and UTF-8, nope:
This point might be somewhat irrelevant, since we are in control of the CSV encoding server-side, so we can enforce a standard. |
Todo if implemented: fix I like the default A: current proposal:
B: one exported fetch:
C: no exported fetch functions. Like B, but there's such a Question: since user might use csv option more performantly than our client code, should we allow it? Wish: improve naming of classic and fix any other bugs Worry: at some point, "classic" also referred to a list of data frames in covidcast. Doesn't seem to be the case when I try now, but not sure if somewhere this name would trip us up. |
Question: should we make |
Re: alternative interface proposals
Re: allowing users to use csv themselves, as we spoke in Slack, let's wait before optimizing in that direction. We can focus on providing a single clean interface through JSON for now and then consider other formats for speed if the need arises. Re: renaming classic, agreed, it's not great; if we give the user a single Re: classic being a list of data frames, maybe we can not export |
TODO
fetch_df
fetch_classic, fetch_json, fetch_csv, fetch_tbl
Notes on the current interface
fetch_classic, fetch_json, fetch_csv
reflect the interface of the API, but don't steer the user to the likeliest use case: download data and get it in a tibble, which is whatfetch_tbl
doesfetch_classic
is not a great name: it sounds outdated even though it is the default return format for the APIfetch_classic
is not clear that it capturesepidata
status codes from the server (while the other fetch function don't)fetch_classic
is not clear that it returns a data.frame for most endpoints, but a list for a few others (like the delphi endpoint)fetch_json
is not clear that it returns a data.framefetch_csv
is not clear that it returns a plain CSV stringfetch_tbl
is not clear that it requests a CSV first, before converting to a tibbleProposed new interface
A default
fetch
function that returns a tibble for most endpoints and a list for the few endpoints that can't be safely converted to a tibble. Thefetch
function will callfetch_classic
under the hood and will make a decision to convert to tibble based on the endpoint. Removefetch_json
,fetch_csv
.Discussion of JSON vs CSV performance
After an extensive conversation and some tests with @brookslogan, we found that the CSV format is not substantially more performant than JSON for serving our data:
The pros of JSON over CSV are:
h/t to @brookslogan for these benchmarks
The text was updated successfully, but these errors were encountered: