weecology / portalr

A collection of functions to summarize the Portal Data
https://weecology.github.io/portalr/
Other
11 stars 12 forks source link

Allow passing of arguments to `download_observations` from calling functions #296

Open gavinsimpson opened 5 months ago

gavinsimpson commented 5 months ago

When running load_rodent_data(my_path) I encountered an error (cause unknown - though I presume it was due to a timeout) that caused the function to fail. I then ran download_observations(my_path) and I got:

Downloading version `5.56.0` of the data...
Warning messages:
1: In download.file(url = zipball_url, destfile = temp, quiet = !verbose,  :
  downloaded length 0 != reported length 0
2: In download.file(url = zipball_url, destfile = temp, quiet = !verbose,  :
  URL 'https://codeload.github.com/weecology/PortalData/legacy.zip/refs/tags/5.56.0': Timeout of 60 seconds was reached
3: In download_observations(path = here("data/portal/")) :
  Archive version `5.56.0` could not be downloaded

Increasing timeout worked fine and the data were download to my_path/PortalData. It would be helpful to allow timeout to be passed from load_rodent_data() > load_datafile() > download_observations(), either by adding timeout as an argument to the various functions in the stack or by allowing ... on the functions that call (or cause to be called) download_observations(). The ... mechanism would be preferable, I think, but it does bring with it the issue of it causing misspelled argument names to be silently ignored unless you go to a little more effort and actually check the ... and ensure that all passed arguments are used (e.g. using rlang::check_dots_used(): https://design.tidyverse.org/dots-inspect.html (Note that at that link it's talking about S3 methods, but the principle applies generally.)

Ideally I'd like to be able to use load_rodent_data(my_path, timeout = 360) and have that value be passed along, so I can follow @ha0ye's nice vignette without having to deviate from the code due to github, limiters/timeouts, etc.


The error I got with load_rodent_data(my_path) was

Downloading version `5.56.0` of the data...
Loading in data version < 1.1.0
Downloading version `5.56.0` of the data...
Downloading version `5.56.0` of the data...
Downloading version `5.56.0` of the data...
Downloading version `5.56.0` of the data...
Error in UseMethod("rename") : 
  no applicable method for 'rename' applied to an object of class "c('simpleWarning', 'warning', 'condition')"
In addition: Warning messages:
1: In load_datafile(file.path("Rodents", "Portal_rodent.csv"), na.strings = "",  :
  Proceeding to download data into specified path/home/********/work/projects/rank-abundance-diagrams-and-gams/repo/data/portal

2: In load_datafile(file.path("Rodents", "Portal_rodent_species.csv"),  :
  Proceeding to download data into specified path/home/********/work/projects/rank-abundance-diagrams-and-gams/repo/data/portal

3: In load_datafile(file.path("Rodents", "Portal_rodent_trapping.csv"),  :
  Proceeding to download data into specified path/home/********/work/projects/rank-abundance-diagrams-and-gams/repo/data/portal

4: In load_datafile(file.path("Rodents", "moon_dates.csv"), na.strings = "NA",  :
  Proceeding to download data into specified path/home/********/work/projects/rank-abundance-diagrams-and-gams/repo/data/portal

5: In load_datafile(file.path("SiteandMethods", "Portal_plots.csv"),  :
  Proceeding to download data into specified path/home/********/work/projects/rank-abundance-diagrams-and-gams/repo/data/portal
ethanwhite commented 2 months ago

Address Gavin Simpson's issues on portalr

ethanwhite commented 2 months ago

Thanks again for this @gavinsimpson.

@gmyenni - I agree with this suggestion and would be happy with either adding an explicit argument or the ... approach. Let me know if you want to chat details. We should probably also bump the default timeout again.