Package 'nflversedata'

Title: nflverse data storage functions
Description: This repository holds automated data releases for nflverse projects and helper functions for managing the uploads.
Authors: Tan Ho [aut, cre] (ORCID: <https://orcid.org/0000-0001-8388-5155>), Sebastian Carl [aut]
Maintainer: Tan Ho <[email protected]>
License: CC BY 4.0
Version: 0.0.18
Built: 2026-11-28 11:38:58 UTC
Source: https://github.com/nflverse/nflverse-data

Help Index


Download nflverse archive assets with gh cli

Description

Download nflverse archive assets with gh cli

Usage

.nflverse_download_assets(
  release_tag,
  file_type = ".rds",
  download_dir = tempdir(),
  repo = "nflverse/nflverse-data"
)

This functions tries the gh command in a terminal. If it errors, the gh cli isn't available on the machine or at least not on the PATH variable

Description

This functions tries the gh command in a terminal. If it errors, the gh cli isn't available on the machine or at least not on the PATH variable

Usage

gh_cli_available()

Upload files to a GitHub release with the gh cli

Description

Uploads files to release tag of repo and retries failed uploads.

Usage

gh_cli_release_upload(
  files,
  tag,
  ...,
  repo = "nflverse/nflverse-data",
  overwrite = TRUE
)

Arguments

files

vector of file paths to upload

tag

release tag

...

currently not used

repo

repository to upload to, default: "nflverse/nflverse-data"

overwrite

If TRUE (the default) existing assets are replaced

Details

Replacing an existing release asset (overwrite = TRUE) costs two requests (delete + upload). Many uploads at the same moment, e.g. from a lot of parallel workflow jobs, can trigger GitHub's secondary rate limit. After a rate limit error this function waits at least one minute (as GitHub asks clients to do), doubling up to 15 minutes, and then uploads only the files that didn't make it. If the primary rate limit (5,000 requests per hour) is exhausted, it waits until the limit resets.

The behavior can be configured with environment variables:

  • NFLVERSE.UPLOAD.INSIST: "false" disables retries.

  • NFLVERSE.UPLOAD.MAX_TIMES: maximum number of attempts, default 6.

  • NFLVERSE.UPLOAD.QUIET: "true" silences retry messages.

  • NFLVERSE.UPLOAD.WRITES_PER_HOUR: optional. If set, pace uploads so this R session makes no more than this many delete/upload requests per hour. After an upload, the function waits until the upload's share of the budget has passed. Unset (the default) means no pacing. Usually limiting the number of parallel jobs is enough.

Value

invisible TRUE on success, FALSE if there was nothing to upload. Errors if the upload still fails after the last attempt.


Archive nflverse

Description

Archive nflverse

Usage

nflverse_archive(
  release_name,
  archive_tag,
  ...,
  file_type = ".rds",
  repo = "nflverse/nflverse-data"
)

Arguments

release_name

Name of the release. Must be available in repo

archive_tag

The release tag to which data from release_name should be uploaded

...

Currently not in use

file_type

The file type that should be archived. In most cases this should be ".rds"

repo

The repo we want to download assets from.

Value

invisible TRUE after archiving


Save files to nflverse release

Description

This functions attaches nflverse attributes like type and timestamp, saves data to a temporary directory in all of csv, rds, and parquet formats, and then uploads to nflverse-data repository for a specified release tag.

Usage

nflverse_save(
  data_frame,
  file_name,
  nflverse_type,
  release_tag,
  file_types = c("rds", "csv", "parquet", "csv.gz"),
  repo = "nflverse/nflverse-data",
  timestamp = TRUE
)

Arguments

data_frame

data_frame to save

file_name

file_name to upload as, without the file extension

nflverse_type

metadata: name/information to add to data

release_tag

name of release to upload to

file_types

one or more of ⁠"rds", "csv", "parquet", "csv.gz"⁠

repo

repository to upload to, default: "nflverse/nflverse-data"

timestamp

If TRUE (the default), also upload the release timestamp files timestamp.txt and timestamp.json. Set to FALSE when uploading many files to the same release in one session and call nflverse_upload_timestamp() once at the end. Every replaced asset costs two requests against GitHub's secondary rate limit.


Upload to nflverse release

Description

Upload to nflverse release

Usage

nflverse_upload(
  files,
  tag,
  ...,
  repo = "nflverse/nflverse-data",
  overwrite = TRUE,
  timestamp = TRUE
)

Arguments

files

vector of filepaths to upload

tag

release name

...

currently not used

repo

repository to upload to, default: "nflverse/nflverse-data"

overwrite

If TRUE (the default) existing files will be overwritten

timestamp

If TRUE (the default), also upload the release timestamp files timestamp.txt and timestamp.json. Set to FALSE when uploading many files to the same release in one session and call nflverse_upload_timestamp() once at the end. Every replaced asset costs two requests against GitHub's secondary rate limit.


Upload release timestamp

Description

Uploads timestamp.txt and timestamp.json with the current time to a release. Use this after uploading several files with timestamp = FALSE.

Usage

nflverse_upload_timestamp(tag, ..., repo = "nflverse/nflverse-data")

Arguments

tag

release name

...

currently not used

repo

repository to upload to, default: "nflverse/nflverse-data"