Skip to content

Commit

Permalink
cran v1.3.1 (#153)
Browse files Browse the repository at this point in the history
* get_current_season alias

* simplify/update progressively

* update news

* fix URL relocations

* news, cran-comments, revdep checks

* update DESC

* run revdep from main pc instead of laptop

* news polishing
  • Loading branch information
tanho63 committed Sep 25, 2022
1 parent fc57cf3 commit 93341ef
Show file tree
Hide file tree
Showing 23 changed files with 121 additions and 111 deletions.
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.0.06
Version: 1.3.1
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 @@ -8,6 +8,7 @@ export(clean_player_names)
export(clean_team_abbrs)
export(csv_from_url)
export(ffverse_sitrep)
export(get_current_season)
export(get_current_week)
export(get_latest_season)
export(load_combine)
Expand Down
31 changes: 19 additions & 12 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
# nflreadr (development version)
# nflreadr 1.3.1

Fixes CRAN bug and provides some function improvements, most notably improved logic for `load_participation()`'s pbp join.

## New Features

- added the function `nflverse_game_id()` which computes valid nflverse game identifiers in the format `"{season}_{week}_{away}_{home}"`
- Added `nflverse_game_id()` which computes valid nflverse game identifiers in the format `"{season}_{week}_{away}_{home}"`

## Function Updates
- `load_participation()` now joins pbp on via `nflverse_game_id` instead of `old_game_id`
- `load_snap_counts()` now allows download of the 2012 season which was previously hardcoded from 2013 (#128)
- `progressively()` now works with purrr-style lambda functions and no longer checks for progressor class, allowing it to be used more flexibly (and with cli-based progress bars.)

## Bugfixes
- `load_snap_counts()` now allows download of the 2012 season which was previously hardcoded from 2013 (#128) (v1.3.0.01)
- `nflverse_releases()` and `nflverse_download()` now accept `.token` arguments which default to `gh::gh_token()`. This is mostly to let us test things properly. (#131) (v1.3.0.02)
- Adjust import references per Jenny Bryan's recommendations in hadley/r-pkgs#828 to avoid loading unused packages. (v1.3.0.03)
- `load_participation()` now joins pbp on via `nflverse_game_id` instead of `old_game_id` (v1.3.0.04)
- `clean_player_names()` now fully lives in nflreadr, the squish/trim happens first (v1.3.0.05)
- `progressively()` now works with lambda functions and no longer checks for progressors. (allows cli)
- player name mapping update (v1.3.0.06)
- `nflverse_releases()` and `nflverse_download()` now accept `.token` arguments which default to `gh::gh_token()`. This is mostly to let us test things properly. (#131)
- Adjust import references per Jenny Bryan's recommendations in hadley/r-pkgs#828 to avoid loading unused packages.
- `clean_player_names()` now fully lives in nflreadr, the squish/trim happens first
- player name mapping update
- `get_current_season()` now exists, because we can't agree on what to name things.

Thank you to [@atungate](https://github.com/atungate),[@grayhawk40](https://github.com/grayhawk40), [@guga31bb](https://github.com/guga31bb),[@jestarr](https://github.com/jestarr), [@john-b-edwards](https://github.com/john-b-edwards),[@marvin3FF](https://github.com/marvin3FF),[@mrcaseb](https://github.com/mrcaseb), [@SCasanova](https://github.com/SCasanova), [@shirondru](https://github.com/shirondru), [@tanho63](https://github.com/tanho63), and [@TheMathNinja](https://github.com/TheMathNinja) for their contributions and feedback towards this release!

---

Expand Down Expand Up @@ -142,11 +149,11 @@ The goal of {`nflreadr`} is to efficiently load data from [nflverse GitHub repos

At this time, it includes data from the following repositories:

- [nflverse/nflfastR-data](https://github.com/nflverse/nflfastR-data)
- [nflverse/nflverse-pbp](https://github.com/nflverse/nflverse-pbp)
- [nflverse/nfldata](https://github.com/nflverse/nfldata)
- [nflverse/nflfastR-roster](https://github.com/nflverse/nflfastR-roster)
- [nflverse/nflverse-rosters](https://github.com/nflverse/nflverse-rosters)
- [nflverse/espnscrapeR-data](https://github.com/nflverse/espnscrapeR-data)
- [nflverse/pfr_scrapR](https://github.com/nflverse/pfr_scrapR)
- [nflverse/nflverse-pfr](https://github.com/nflverse/nflverse-pfr)
- [dynastyprocess/data](https://github.com/dynastyprocess/data)

This will hopefully provide a unified and reliable package for downloading nflverse data that can be extended to the rest of the nflverse and ffverse package families.
Expand Down
44 changes: 0 additions & 44 deletions R/from_url.R
Original file line number Diff line number Diff line change
Expand Up @@ -208,50 +208,6 @@ qs_from_url <- function(url){
return(content)
}

#' Progressively
#'
#' This function helps add progress-reporting to any function - given function `f()` and progressor `p()`, it will return a new function that calls `f()` and then (on-exiting) will call `p()` after every iteration.
#'
#' This is inspired by purrr's `safely`, `quietly`, and `possibly` function decorators.
#'
#' @param f a function to add progressr functionality to.
#' @param p a progressor function such as one created by `progressr::progressor()`
#'
#' @examples
#'
#' \donttest{
#' try({ # prevents cran errors
#'
#' read_rosters <- function(){
#' urls <- c("https://github.com/nflverse/nflfastR-roster/raw/master/data/seasons/roster_2020.csv",
#' "https://github.com/nflverse/nflfastR-roster/raw/master/data/seasons/roster_2021.csv")
#'
#' p <- progressr::progressor(along = urls)
#' lapply(urls, progressively(read.csv, p))
#' }
#'
#' progressr::with_progress(read_rosters())
#'
#' })
#' }
#'
#' @return a function that does the same as `f` but it calls `p()` after iteration.
#'
#' @seealso <https://nflreadr.nflverse.com/articles/exporting_nflreadr.html> for vignette on exporting nflreadr in packages
#'
#' @export
progressively <- function(f, p = NULL){
if(!is.null(p)) p <- rlang::as_function(p)
if(is.null(p)) p <- function(...) NULL
force(f)

function(...){
on.exit(p("loading..."))
f(...)
}

}

cache_message <- function(){
do_it <- getOption("nflreadr.verbose", default = interactive()) && getOption("nflreadr.cache_warning", default = interactive())
if (isTRUE(do_it)){
Expand Down
2 changes: 1 addition & 1 deletion R/load_pbp.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#' @seealso <https://nflreadr.nflverse.com/articles/dictionary_pbp.html> for a web version of the data dictionary
#' @seealso [`dictionary_pbp`] for the data dictionary bundled as a package dataframe
#' @seealso <https://www.nflfastr.com/reference/build_nflfastR_pbp.html> for the nflfastR function `nflfastR::build_nflfastR_pbp()`
#' @seealso Issues with this data should be filed here: <https://github.com/nflverse/nflfastR-data>
#' @seealso Issues with this data should be filed here: <https://github.com/nflverse/nflverse-pbp>
#'
#' @export
load_pbp <- function(seasons = most_recent_season(), file_type = getOption("nflreadr.prefer", default = "rds")) {
Expand Down
2 changes: 1 addition & 1 deletion R/load_pfr_advstats.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#'
#' @seealso <https://nflreadr.nflverse.com/articles/dictionary_pfr_passing.html> for the web data dictionary
#' @seealso [`dictionary_pfr_passing`] for the data dictionary as bundled within the package
#' @seealso Issues with this data should be filed here: <https://github.com/nflverse/pfr_scrapR>
#' @seealso Issues with this data should be filed here: <https://github.com/nflverse/nflverse-pfr>
#'
#' @keywords internal
#' @export
Expand Down
2 changes: 1 addition & 1 deletion R/load_player_stats.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#'
#' @seealso <https://nflreadr.nflverse.com/articles/dictionary_player_stats.html> for a web version of the data dictionary
#' @seealso [`dictionary_player_stats`] for the data dictionary
#' @seealso Issues with this data should be filed here: <https://github.com/nflverse/nflfastR-data>
#' @seealso Issues with this data should be filed here: <https://github.com/nflverse/nflverse-pbp>
#'
#' @export
load_player_stats <- function(seasons = most_recent_season(),
Expand Down
2 changes: 1 addition & 1 deletion R/load_snap_counts.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#'
#' @seealso <https://nflreadr.nflverse.com/articles/dictionary_snap_counts.html> for the web data dictionary
#' @seealso [`dictionary_snap_counts`] for the data dictionary as bundled within the package
#' @seealso Issues with this data should be filed here: <https://github.com/nflverse/pfr_scrapR>
#' @seealso Issues with this data should be filed here: <https://github.com/nflverse/nflverse-pfr>
#'
#' @export
load_snap_counts <- function(seasons = most_recent_season(),
Expand Down
4 changes: 2 additions & 2 deletions R/load_teams.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
#'
#' @return A tibble of team-level image URLs and hex color codes.
#'
#' @seealso Issues with this data should be filed here: <https://github.com/nflverse/nflfastR-data>
#' @seealso Issues with this data should be filed here: <https://github.com/nflverse/nflverse-pbp>
#'
#' @export
load_teams <- function(){
out <- load_from_url("https://github.com/nflverse/nflfastR-data/raw/master/teams_colors_logos.rds",
out <- load_from_url("https://github.com/nflverse/nflverse-pbp/raw/master/teams_colors_logos.rds",
nflverse = TRUE,
nflverse_type = "team graphics")
out
Expand Down
5 changes: 5 additions & 0 deletions R/utils_date.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ most_recent_season <- function(roster = FALSE) {
#' @export
get_latest_season <- most_recent_season

#' @rdname latest_season
#' @export
get_current_season <- most_recent_season


#' Get Current Week
#'
#' A helper function that returns the upcoming NFL regular season week based on either
Expand Down
44 changes: 44 additions & 0 deletions R/utils_progressively.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#' Progressively
#'
#' This function helps add progress-reporting to any function - given function `f()` and progressor `p()`,
#' it will return a new function that calls `f()` and then (on exiting) will call `p()` after every iteration.
#' This is inspired by purrr's `safely`, `quietly`, and `possibly` function decorators.
#'
#' @param f a function to add progressor functionality to.
#' @param p a function such as one created by `progressr::progressor()` - also accepts purrr-style lambda functions.
#'
#' @examples
#'
#' \donttest{
#' try({ # prevents cran errors
#'
#' urls <- rep("https://github.com/nflverse/nflverse-data/releases/download/test/combines.csv",3)
#'
#' lapply(urls, progressively(read.csv, ~cli::cli_progress_step('Loading...')))
#'
#' read_rosters <- function(urls){
#' p <- progressr::progressor(along = urls)
#' lapply(urls, progressively(read.csv, p))
#' }
#'
#' progressr::with_progress(read_rosters())
#'
#' })
#' }
#'
#' @return a function that does the same as `f` but it calls `p()` after iteration.
#'
#' @seealso <https://nflreadr.nflverse.com/articles/exporting_nflreadr.html> for vignette on exporting nflreadr in packages
#'
#' @export
progressively <- function(f, p = NULL){
if(is.null(p)) p <- function(...) NULL
p <- rlang::as_function(p)
f <- rlang::as_function(f)

function(...){
on.exit(p())
f(...)
}

}
4 changes: 2 additions & 2 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## RESUBMISSION
## SUBMISSION

Resubmit to correct URL-redirection issues.
Resolves test failure.

## Test environments
* local windows R installation, R 4.2.0
Expand Down
3 changes: 3 additions & 0 deletions man/latest_season.Rd

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

2 changes: 1 addition & 1 deletion man/load_pbp.Rd

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

2 changes: 1 addition & 1 deletion man/load_pfr_passing.Rd

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

2 changes: 1 addition & 1 deletion man/load_player_stats.Rd

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

2 changes: 1 addition & 1 deletion man/load_snap_counts.Rd

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

2 changes: 1 addition & 1 deletion man/load_teams.Rd

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

18 changes: 9 additions & 9 deletions man/progressively.Rd

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

54 changes: 24 additions & 30 deletions revdep/README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,32 @@
# Platform

|field |value |
|:--------|:---------------------------------------------------------------------|
|version |R version 4.2.0 (2022-04-22 ucrt) |
|os |Windows 10 x64 (build 19044) |
|system |x86_64, mingw32 |
|ui |RStudio |
|language |(EN) |
|collate |English_Canada.utf8 |
|ctype |English_Canada.utf8 |
|tz |America/New_York |
|date |2022-08-06 |
|rstudio |2022.06.0-daily+477 Spotted Wakerobin (desktop) |
|pandoc |2.18 @ C:/Program Files/RStudio/bin/quarto/bin/tools/ (via rmarkdown) |
|field |value |
|:--------|:---------------------------------|
|version |R version 4.2.0 (2022-04-22 ucrt) |
|os |Windows 10 x64 (build 19044) |
|system |x86_64, mingw32 |
|ui |RTerm |
|language |(EN) |
|collate |English_Canada.utf8 |
|ctype |English_Canada.utf8 |
|tz |America/New_York |
|date |2022-09-24 |
|pandoc |NA |

# Dependencies

|package |old |new |Δ |
|:-------------|:------|:------|:--|
|nflreadr |1.2.0 |1.3.0 |* |
|cachem |1.0.6 |1.0.6 | |
|cli |3.3.0 |3.3.0 | |
|curl |4.3.2 |4.3.2 | |
|data.table |1.14.2 |1.14.2 | |
|fastmap |1.1.0 |1.1.0 | |
|glue |1.6.2 |1.6.2 | |
|memoise |2.0.1 |2.0.1 | |
|qs |0.25.3 |NA |* |
|RApiSerialize |0.1.0 |NA |* |
|rappdirs |0.3.3 |0.3.3 | |
|Rcpp |1.0.9 |NA |* |
|RcppParallel |5.1.5 |NA |* |
|rlang |1.0.4 |1.0.4 | |
|stringfish |0.15.7 |NA |* |
|package |old |new |Δ |
|:----------|:------|:------|:--|
|nflreadr |1.3.0 |1.3.1 |* |
|cachem |1.0.6 |1.0.6 | |
|cli |3.4.0 |3.4.0 | |
|curl |4.3.2 |4.3.2 | |
|data.table |1.14.2 |1.14.2 | |
|fastmap |1.1.0 |1.1.0 | |
|glue |1.6.2 |1.6.2 | |
|memoise |2.0.1 |2.0.1 | |
|rappdirs |0.3.3 |0.3.3 | |
|rlang |1.0.5 |1.0.5 | |

# Revdeps

Binary file modified revdep/data.sqlite
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/testthat/test-from_url.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ test_that("progress updates in raw_from_url work", {
# enable progress updates in batch mode for testing the progress updates
old <- options(progressr.enable = TRUE)

urls <- rep("https://github.com/nflverse/nflfastR-data/raw/master/teams_colors_logos.rds", 3)
urls <- rep("https://github.com/nflverse/nflverse-pbp/raw/master/teams_colors_logos.rds", 3)

expect_condition({
load <- progressr::with_progress({
Expand Down
Loading

0 comments on commit 93341ef

Please sign in to comment.