Skip to content

Commit

Permalink
add .for_cran()
Browse files Browse the repository at this point in the history
  • Loading branch information
tanho63 committed Aug 8, 2023
1 parent f68c359 commit 7a0e36b
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: nflreadr
Title: Download 'nflverse' Data
Version: 1.3.2.06
Version: 1.3.2.07
Authors@R: c(
person("Tan", "Ho", , "[email protected]", role = c("aut", "cre", "cph"),
comment = c(ORCID = "0000-0001-8388-5155")),
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

S3method(print,nflverse_data)
export(.clear_cache)
export(.for_cran)
export(.sitrep)
export(clean_homeaway)
export(clean_player_names)
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ etc falsely returned last season after March 15th early in the month. (1.3.2.03)
- Clarified description of the `"special"` variable in the play-by-play data dictionary. (1.3.2.04) (#189)
- `nflreadr::nflverse_game_id()` accepts old team abbreviations and outputs useful errors. (1.3.2.05) (#191)
- Added `dictionary_player_stats_def` (thank you @mpcen!) (1.3.2.06) (#192)
- Added `.for_cran()` to limit parallelization in CRAN examples and tests (1.3.2.07)

# nflreadr 1.3.2

Expand Down
18 changes: 18 additions & 0 deletions R/utils_cran.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#' CRAN setup code
#'
#' Some code to comply with CRAN policies, e.g.
#' limiting data.table CPU cores for examples/tests
#'
#' @export
.for_cran <- function(){

cores <- min(
getOption("Ncpus", default = 2L),
as.integer(Sys.getenv("OMP_THREAD_LIMIT",unset = "2")),
floor(Sys.getenv("_R_CHECK_EXAMPLE_TIMING_CPU_TO_ELAPSED_THRESHOLD_", unset = 2)),
2L,
na.rm = TRUE
)

data.table::setDTthreads(cores)
}
12 changes: 12 additions & 0 deletions man/dot-for_cran.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7a0e36b

Please sign in to comment.