-
Notifications
You must be signed in to change notification settings - Fork 5
consider optimizing package organization for autocomplete/user assist #10
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
It seems like the key requirements are
The current version of endpoints.R suggests that most of the functions are simply input validation and parameter formatting -- i.e. mostly static data specifying arguments and formats, so a user's request can be formatted appropriately. Given the above, I see a new option besides the ones above (named lists, prefixes): Consolidated fetchingIf the endpoint functions are mostly static data + validation, why have one function per endpoint? Instead, have epidata::fetch_classic("cdc", epiweeks, locations)
The function namespace hence does not contain anything about the endpoints, and so it's easy to get the utility functions. But we can still put the data into the help namespace, by using roxygen: #' CDC endpoint.
#'
#' @usage{fetch_classic("cdc", epiweeks, locations)}
#'
#' @param epiweeks ....
#'
#' @name cdc
NULL This would still be fetchable with We'd need to experiment a bit to ensure the Rd system will accept this, but I think it will if we figure out the right way to do it. Side notesI actually think the autocomplete issue is not a serious issue here. The number of top-level endpoints is not huge, and users presumably come to Epidata with a vague idea of what kind of data they want. The issue is much bigger for signals within specific endpoints. covidcast is the biggest example, with signals nested within sources. But I don't think autocomplete is the right option there either; I think some functions that bring up the relevant documentation sections would be more useful. For example, perhaps |
while this reduces the number of exposed function it also has some drawbacks
|
Regarding R6 objects: this is more or less the "named list" approach, but maybe with some utilities that make various types of documentation easier. (But maybe also not quite the behavior that we might want.)
Regarding named list approaches:
Regarding consolidated fetching:
Regarding current approach:
Regarding prefixes:
On side notes:
or
or
or variants like
|
with #12 the current structure is covidcast_api <- covidcast_epidata()
epicall <- covidcast_api$sources$`fb-survey`$signals$smoothed_cli$call("nation", "us", epirange(20210405, 20210410))
epicall %>% fetch_json() the |
Cool! It seems possible to get rid of the [EDIT: we should check out promises using
Toy use below:
Actual use might be something like
and not exporting (This assumes no one will be running a really long R session and then trying to use new covidcast data sources that weren't created at the time they first used covidcast that R session.) EDIT: additional methods to provide implementations for may include |
In a similar vein, the
|
Noting here and above that there are already built-in mechanisms in R for thunks that look like "real" objects:
|
Messing around with
|
Progress so far: Endpoints have been prefixed with either However,
How much effort would it be to improve this? |
Very cursory guesses
A couple more things that came to mind:
This appears to work for covidcast since each source only has one |
There are a ton of endpoints, and most users will only use a small number of them.
Current organization is flat, with endpoints, fetchers, and utility functions all mixed together:
This organization is easiest to implement and automatically generates matching man pages, but it does flood autocomplete, making it difficult to refer to utility functions.
There are several alternative organization schemes we could consider, all with pros and cons:
Named lists
To make this work, we'd have to specify our own man files for the lists and their members.
Prefixes
We're already considering adding
pvt_
for the restricted endpoints; we could easily switch to egendpoint_covidcast
. Autocomplete would still be flooded but it would be easier for users to tell what was what.R6 objects
Not familiar wtih this; maybe @brookslogan can advise?
The text was updated successfully, but these errors were encountered: