Skip to content
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

rate-limit-related functions to freemium (1) #138

Closed

Conversation

szaboildi
Copy link
Contributor

Rename the rate-limit-related variable HERE_RPS to HERE_FREEMIUM, and the functions hereR::set_rate_limit() and .get_freemium() functions to hereR::set_freemium() and .get_freemium(), respectively. Change the documentation to reflect the additional purpose of the now hereR::set_freemium() function. Use the HERE_FREEMIUM variable to determine a plan-specific size of sub-matrices in the hereR::route_matrix() function.

TomJaksztat and others added 7 commits January 20, 2021 09:41
If freemium is set to TRUE (default), hereR chops up the input matrix into smaller (15 x 100) submatrices, as it currently does, but if it is set to FALSE it chops it up into much bigger submatrices  (10000 x 10000 -- HERE's limit).
… var HERE_RPS

hereR::set_rate_limit() --> hereR::set_freemium()
.get_rate_limits() --> .get_freemium()  HERE_RPS --> HERE_FREEMIUM
To determine size of submatrices
@szaboildi szaboildi closed this Sep 21, 2021
@munterfi munterfi reopened this Sep 22, 2021
@munterfi munterfi changed the title rate-limit-related functions to freemium rate-limit-related functions to freemium (1) Sep 22, 2021
@munterfi
Copy link
Owner

Hi, thanks for your contribution!

I reopened the PR and:

  • Deprecated set_rate_limit, which now calls set_freemium.
  • Adjusted tests.
  • Added NEWS entries.
  • Updated README and vignette sections about rate limits.
  • New PR rate-limit-related functions to freemium (2) #139 (missing permissions) into develop branch.

Concerning the error message if freemium is deactivated and a large matrix is sent, it will return NULL and issue the warning “403 Forbidden”, which is OK I think:

library(hereR)
set_verbose(TRUE)
library(sf)
#> Linking to GEOS 3.8.1, GDAL 3.2.1, PROJ 7.2.1
n <- 200
l <- n * n
(sf <-
  data.frame(
    idx = seq(1, n),
    lng = runif(n, 7.5, 8.5),
    lat = runif(n, 47.25, 47.75)
  ) %>%
  st_as_sf(coords = c("lng", "lat")) %>%
  st_set_crs(4326))
#> Simple feature collection with 200 features and 1 field
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: 7.501837 ymin: 47.25312 xmax: 8.497909 ymax: 47.74764
#> Geodetic CRS:  WGS 84
#> First 10 features:
#>    idx                  geometry
#> 1    1 POINT (7.651816 47.54143)
#> 2    2 POINT (8.008282 47.40666)
#> 3    3 POINT (8.434565 47.66038)
#> 4    4  POINT (8.02256 47.56635)
#> 5    5 POINT (7.504335 47.65751)
#> 6    6 POINT (7.960898 47.35633)
#> 7    7  POINT (7.622075 47.3893)
#> 8    8 POINT (8.345096 47.55927)
#> 9    9  POINT (7.709078 47.6904)
#> 10  10 POINT (8.424419 47.62594)
m1 <- route_matrix(sf)
#> Sending 28 request(s) with 1 RPS to: 'https://matrix.router.hereapi.com/v8/matrix?...'
#> Received 28 response(s) with total size: 436.7 Kb
set_freemium(FALSE)
(m2 <- route_matrix(sf))
#> Sending 1 request(s) with unlimited RPS to: 'https://matrix.router.hereapi.com/v8/matrix?...'
#> Warning in .parse_response(i, out$responses()[[i]]): Request 'id = 1' failed:
#> Status 403.
#> Received 1 response(s) with total size: 288 bytes
#> NULL
Session info
devtools::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 4.1.0 (2021-05-18)
#>  os       macOS Big Sur 10.16         
#>  system   x86_64, darwin17.0          
#>  ui       X11                         
#>  language (EN)                        
#>  collate  en_US.UTF-8                 
#>  ctype    en_US.UTF-8                 
#>  tz       Europe/Zurich               
#>  date     2021-09-22                  
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version    date       lib source        
#>  cachem        1.0.6      2021-08-19 [1] CRAN (R 4.1.0)
#>  callr         3.7.0      2021-04-20 [1] CRAN (R 4.1.0)
#>  class         7.3-19     2021-05-03 [1] CRAN (R 4.1.0)
#>  classInt      0.4-3      2020-04-07 [1] CRAN (R 4.1.0)
#>  cli           3.0.1      2021-07-17 [1] CRAN (R 4.1.0)
#>  crayon        1.4.1      2021-02-08 [1] CRAN (R 4.1.0)
#>  crul          1.1.0      2021-02-15 [1] CRAN (R 4.1.0)
#>  curl          4.3.2      2021-06-23 [1] CRAN (R 4.1.0)
#>  data.table    1.14.0     2021-02-21 [1] CRAN (R 4.1.0)
#>  DBI           1.1.1      2021-01-15 [1] CRAN (R 4.1.0)
#>  desc          1.3.0      2021-03-05 [1] CRAN (R 4.1.0)
#>  devtools      2.4.2      2021-06-07 [1] CRAN (R 4.1.0)
#>  digest        0.6.27     2020-10-24 [1] CRAN (R 4.1.0)
#>  dplyr         1.0.7      2021-06-18 [1] CRAN (R 4.1.0)
#>  e1071         1.7-8      2021-07-28 [1] CRAN (R 4.1.0)
#>  ellipsis      0.3.2      2021-04-29 [1] CRAN (R 4.1.0)
#>  evaluate      0.14       2019-05-28 [1] CRAN (R 4.1.0)
#>  fansi         0.5.0      2021-05-25 [1] CRAN (R 4.1.0)
#>  fastmap       1.1.0      2021-01-25 [1] CRAN (R 4.1.0)
#>  fs            1.5.0      2020-07-31 [1] CRAN (R 4.1.0)
#>  generics      0.1.0      2020-10-31 [1] CRAN (R 4.1.0)
#>  glue          1.4.2      2020-08-27 [1] CRAN (R 4.1.0)
#>  hereR       * 0.7.1.9000 2021-09-22 [1] local         
#>  htmltools     0.5.2      2021-08-25 [1] CRAN (R 4.1.0)
#>  httpcode      0.3.0      2020-04-10 [1] CRAN (R 4.1.0)
#>  jsonlite      1.7.2      2020-12-09 [1] CRAN (R 4.1.0)
#>  KernSmooth    2.23-20    2021-05-03 [1] CRAN (R 4.1.0)
#>  knitr         1.34       2021-09-09 [1] CRAN (R 4.1.0)
#>  lifecycle     1.0.0      2021-02-15 [1] CRAN (R 4.1.0)
#>  magrittr      2.0.1      2020-11-17 [1] CRAN (R 4.1.0)
#>  memoise       2.0.0      2021-01-26 [1] CRAN (R 4.1.0)
#>  pillar        1.6.2      2021-07-29 [1] CRAN (R 4.1.0)
#>  pkgbuild      1.2.0      2020-12-15 [1] CRAN (R 4.1.0)
#>  pkgconfig     2.0.3      2019-09-22 [1] CRAN (R 4.1.0)
#>  pkgload       1.2.2      2021-09-11 [1] CRAN (R 4.1.0)
#>  prettyunits   1.1.1      2020-01-24 [1] CRAN (R 4.1.0)
#>  processx      3.5.2      2021-04-30 [1] CRAN (R 4.1.0)
#>  proxy         0.4-26     2021-06-07 [1] CRAN (R 4.1.0)
#>  ps            1.6.0      2021-02-28 [1] CRAN (R 4.1.0)
#>  purrr         0.3.4      2020-04-17 [1] CRAN (R 4.1.0)
#>  R6            2.5.1      2021-08-19 [1] CRAN (R 4.1.0)
#>  Rcpp          1.0.7      2021-07-07 [1] CRAN (R 4.1.0)
#>  remotes       2.4.0      2021-06-02 [1] CRAN (R 4.1.0)
#>  rlang         0.4.11     2021-04-30 [1] CRAN (R 4.1.0)
#>  rmarkdown     2.11       2021-09-14 [1] CRAN (R 4.1.0)
#>  rprojroot     2.0.2      2020-11-15 [1] CRAN (R 4.1.0)
#>  rstudioapi    0.13       2020-11-12 [1] CRAN (R 4.1.0)
#>  sessioninfo   1.1.1      2018-11-05 [1] CRAN (R 4.1.0)
#>  sf          * 1.0-2      2021-07-26 [1] CRAN (R 4.1.0)
#>  stringi       1.7.4      2021-08-25 [1] CRAN (R 4.1.0)
#>  stringr       1.4.0      2019-02-10 [1] CRAN (R 4.1.0)
#>  testthat      3.0.4      2021-07-01 [1] CRAN (R 4.1.0)
#>  tibble        3.1.4      2021-08-25 [1] CRAN (R 4.1.0)
#>  tidyselect    1.1.1      2021-04-30 [1] CRAN (R 4.1.0)
#>  units         0.7-2      2021-06-08 [1] CRAN (R 4.1.0)
#>  usethis       2.0.1      2021-02-10 [1] CRAN (R 4.1.0)
#>  utf8          1.2.2      2021-07-24 [1] CRAN (R 4.1.0)
#>  vctrs         0.3.8      2021-04-29 [1] CRAN (R 4.1.0)
#>  withr         2.4.2      2021-04-18 [1] CRAN (R 4.1.0)
#>  xfun          0.26       2021-09-14 [1] CRAN (R 4.1.0)
#>  yaml          2.2.1      2020-02-01 [1] CRAN (R 4.1.0)
#> 
#> [1] /Library/Frameworks/R.framework/Versions/4.1/Resources/library

@munterfi munterfi closed this Sep 22, 2021
@szaboildi
Copy link
Contributor Author

Sounds good, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants