simonpcouch / anyflights

An R package to generate `nycflights13`-like air travel dataπŸ›©οΈ

Home Page:https://simonpcouch.github.io/anyflights/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

utils::download.file timeout

patrickvossler18 opened this issue Β· comments

Hello,

When I try to download all of the flights for January 2020 originating from LAX, I get a timeout error:

library(anyflights)
# get all flights in January 2020 with origin LAX
la2020 <- anyflights("LAX", 2020, 1)
#>                                 Total Time Elapsed
#> Finished Processing Arguments                   1s
#> Warning in utils::download.file(fl_url, flight_temp, quiet = TRUE): downloaded
#> length 24250200 != reported length 30636034
#> Warning in utils::download.file(fl_url, flight_temp,
#> quiet = TRUE): URL 'https://transtats.bts.gov/PREZIP/
#> On_Time_Reporting_Carrier_On_Time_Performance_1987_present_2020_1.zip': Timeout
#> of 60 seconds was reached
#> Error in utils::download.file(fl_url, flight_temp, quiet = TRUE): download from 'https://transtats.bts.gov/PREZIP/On_Time_Reporting_Carrier_On_Time_Performance_1987_present_2020_1.zip' failed

Created on 2021-02-12 by the reprex package (v0.3.0)

Session info
devtools::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 4.0.3 (2020-10-10)
#>  os       macOS Catalina 10.15.7      
#>  system   x86_64, darwin17.0          
#>  ui       X11                         
#>  language (EN)                        
#>  collate  en_US.UTF-8                 
#>  ctype    en_US.UTF-8                 
#>  tz       America/Los_Angeles         
#>  date     2021-02-12                  
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version date       lib source                                 
#>  anyflights  * 0.3.1   2021-02-12 [1] Github (simonpcouch/anyflights@17c581f)
#>  assertthat    0.2.1   2019-03-21 [1] CRAN (R 4.0.2)                         
#>  cachem        1.0.1   2021-01-21 [1] CRAN (R 4.0.2)                         
#>  callr         3.5.1   2020-10-13 [1] CRAN (R 4.0.2)                         
#>  cli           2.3.0   2021-01-31 [1] CRAN (R 4.0.2)                         
#>  crayon        1.4.1   2021-02-08 [1] CRAN (R 4.0.2)                         
#>  curl          4.3     2019-12-02 [1] CRAN (R 4.0.1)                         
#>  DBI           1.1.1   2021-01-15 [1] CRAN (R 4.0.2)                         
#>  desc          1.2.0   2018-05-01 [1] CRAN (R 4.0.2)                         
#>  devtools      2.3.2   2020-09-18 [1] CRAN (R 4.0.2)                         
#>  digest        0.6.27  2020-10-24 [1] CRAN (R 4.0.2)                         
#>  dplyr         1.0.4   2021-02-02 [1] CRAN (R 4.0.2)                         
#>  ellipsis      0.3.1   2020-05-15 [1] CRAN (R 4.0.2)                         
#>  evaluate      0.14    2019-05-28 [1] CRAN (R 4.0.1)                         
#>  fastmap       1.1.0   2021-01-25 [1] CRAN (R 4.0.2)                         
#>  fs            1.5.0   2020-07-31 [1] CRAN (R 4.0.2)                         
#>  generics      0.1.0   2020-10-31 [1] CRAN (R 4.0.2)                         
#>  glue          1.4.2   2020-08-27 [1] CRAN (R 4.0.2)                         
#>  highr         0.8     2019-03-20 [1] CRAN (R 4.0.2)                         
#>  hms           1.0.0   2021-01-13 [1] CRAN (R 4.0.2)                         
#>  htmltools     0.5.1   2021-01-12 [1] CRAN (R 4.0.2)                         
#>  httr          1.4.2   2020-07-20 [1] CRAN (R 4.0.2)                         
#>  knitr         1.31    2021-01-27 [1] CRAN (R 4.0.2)                         
#>  lifecycle     0.2.0   2020-03-06 [1] CRAN (R 4.0.2)                         
#>  magrittr      2.0.1   2020-11-17 [1] CRAN (R 4.0.2)                         
#>  memoise       2.0.0   2021-01-28 [1] Github (hadley/memoise@a2187e6)        
#>  pillar        1.4.7   2020-11-20 [1] CRAN (R 4.0.2)                         
#>  pkgbuild      1.2.0   2020-12-15 [1] CRAN (R 4.0.2)                         
#>  pkgconfig     2.0.3   2019-09-22 [1] CRAN (R 4.0.2)                         
#>  pkgload       1.1.0   2020-05-29 [1] CRAN (R 4.0.2)                         
#>  prettyunits   1.1.1   2020-01-24 [1] CRAN (R 4.0.2)                         
#>  processx      3.4.5   2020-11-30 [1] CRAN (R 4.0.2)                         
#>  progress      1.2.2   2019-05-16 [1] CRAN (R 4.0.2)                         
#>  ps            1.5.0   2020-12-05 [1] CRAN (R 4.0.2)                         
#>  purrr         0.3.4   2020-04-17 [1] CRAN (R 4.0.2)                         
#>  R6            2.5.0   2020-10-28 [1] CRAN (R 4.0.2)                         
#>  readr         1.4.0   2020-10-05 [1] CRAN (R 4.0.2)                         
#>  remotes       2.2.0   2020-07-21 [1] CRAN (R 4.0.2)                         
#>  rlang         0.4.10  2020-12-30 [1] CRAN (R 4.0.2)                         
#>  rmarkdown     2.6     2020-12-14 [1] CRAN (R 4.0.2)                         
#>  rprojroot     2.0.2   2020-11-15 [1] CRAN (R 4.0.3)                         
#>  sessioninfo   1.1.1   2018-11-05 [1] CRAN (R 4.0.2)                         
#>  stringi       1.5.3   2020-09-09 [1] CRAN (R 4.0.2)                         
#>  stringr       1.4.0   2019-02-10 [1] CRAN (R 4.0.2)                         
#>  testthat      3.0.1   2020-12-17 [1] CRAN (R 4.0.2)                         
#>  tibble        3.0.6   2021-01-29 [1] CRAN (R 4.0.2)                         
#>  tidyselect    1.1.0   2020-05-11 [1] CRAN (R 4.0.2)                         
#>  usethis       2.0.1   2021-02-10 [1] CRAN (R 4.0.2)                         
#>  vctrs         0.3.6   2020-12-17 [1] CRAN (R 4.0.2)                         
#>  withr         2.4.1   2021-01-26 [1] CRAN (R 4.0.3)                         
#>  xfun          0.21    2021-02-10 [1] CRAN (R 4.0.2)                         
#>  yaml          2.2.1   2020-02-01 [1] CRAN (R 4.0.2)                         
#> 
#> [1] /Library/Frameworks/R.framework/Versions/4.0/Resources/library

It was able to track down the issue to be caused by the default R option timeout is set to 60 seconds. I found this stack overflow answer that shows how to change this option. I propose two possible ways to help users avoid this issue in the future:

  1. Explicitly tell users to consider increasing the timeout option in their R session: In the readme for the package, the importance of a strong internet connection is emphasized. It might be useful to inform users that they can increase the timeout option with something along the lines of

"If you are repeatedly getting a timeout error, try extending the timeout period for your R session using:"

options(timeout = timeout_value_in_seconds)
  1. Automatically set the timeout option to a larger value using the .onAttach() function.: This might be less ideal because it is changing a users' session, but if a package start-up message as done with the rpushbullet package I think this is another viable option.

Thanks for making this package, and if you'd like, I can submit a PR with one of the two changes.

Thanks for the issue! I appreciate your thoroughness.

I'd be all for your first proposal, either as

  • a note in help-files using @inheritSection, and/or
  • tryCatching on download.file and raising that more informative error message you wrote instead of what's currently supplied.

I'll keep an eye out for a PR, but will go ahead make those changes myself if I don't hear more. Thanks again.β˜ƒοΈ

commented

"If you are repeatedly getting a timeout error, try extending the timeout period for your R session using:"

option(timeout = timeout_value_in_seconds)

In case anyone comes across this in the future with the timeout issue, the command is options(...) not option(...).

Note the s that is missing in the OP's post.

Good catch! Updated my post and submitted #20 to fix this in the documentation.