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

Fix #150 fix #149 fix#152 (#151) #153

Merged
merged 3 commits into from
Jul 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: rang
Title: Reconstructing Reproducible R Computational Environments
Version: 0.2.4
Version: 0.2.5
Authors@R:
c(person("Chung-hong", "Chan", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-6232-7530")),
Expand Down
20 changes: 19 additions & 1 deletion R/memo_misc.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,25 @@ NULL

## one hr

.memo_search <- memoise::memoise(pkgsearch::cran_package_history, cache = cachem::cache_mem(max_age = 60 * 60))
.cran_package_history <- function(package, max_retries = 5) {
n_retries <- 0
while(n_retries < max_retries) {
tryCatch({
return(pkgsearch::cran_package_history(package))
}, error = function(e) {
if (grepl("parse error: premature EOF", e$message)) {
n_retries <<- n_retries + 1
##message("retrying in 2s...")
Sys.sleep(2)
} else {
stop(e)
}
})
}
stop("Can't query this package: ", package, call. = FALSE)
}

.memo_search <- memoise::memoise(.cran_package_history, cache = cachem::cache_mem(max_age = 60 * 60))

.rver <- function() {
suppressWarnings(jsonlite::fromJSON(readLines("https://api.r-hub.io/rversions/r-versions"), simplifyVector = TRUE))
Expand Down
8 changes: 4 additions & 4 deletions R/resolve.R
Original file line number Diff line number Diff line change
Expand Up @@ -479,17 +479,17 @@ print.rang <- function(x, all_pkgs = FALSE, ...) {
return(res)
}

.gh <- function(path,ref = NULL,...){
.gh <- function(path,ref = NULL,...) {
url <- httr::parse_url("https://api.github.com/")
url <- httr::modify_url(url, path = path)
token <- Sys.getenv("GITHUB_PAT", NA_character_)
if(is.na(token)){
if(is.na(token)) {
token <- Sys.getenv("GITHUB_TOKEN", NA_character_)
}
if(is.na(token)){
if(is.na(token)) {
token <- ""
}
config <- httr::add_headers(Accept = "application/vnd.github.v3+json",Authorization=token)
config <- httr::add_headers(Accept = "application/vnd.github.v3+json", Authorization = paste0("token ", token))
params <- list(ref = ref,...)
request_results <- httr::GET(httr::modify_url(url, path = path), config, query = params)
status_code <- httr::status_code(request_results)
Expand Down
6 changes: 1 addition & 5 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@ To reconstruct a historical R computational environment, this package assumes on

Please cite this package as:

Chan CH, Schoch D (2023) rang: Reconstructing reproducible R computational environments. arXiv preprint:[2303.04758](https://doi.org/10.48550/arXiv.2303.04758)

Please cite this package as:

Chan CH, Schoch D (2023) rang: Reconstructing reproducible R computational environments. arXiv preprint:[2303.04758](https://doi.org/10.48550/arXiv.2303.04758)
Chan CH, Schoch D (2023) rang: Reconstructing reproducible R computational environments. PLOS ONE [https://doi.org/10.1371/journal.pone.0286761](https://doi.org/10.1371/journal.pone.0286761)

## Installation

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ of R.
Please cite this package as:

Chan CH, Schoch D (2023) rang: Reconstructing reproducible R
computational environments. arXiv
preprint:[2303.04758](https://doi.org/10.48550/arXiv.2303.04758)
computational environments. PLOS ONE
<https://doi.org/10.1371/journal.pone.0286761>

## Installation

Expand Down
4 changes: 2 additions & 2 deletions inst/CITATION
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ citHeader("To cite rang in publications use:")

bibentry(bibtype = "article",
title = "rang: Reconstructing reproducible R computational environments",
journal = "arXiv preprint 2303.04758",
journal = "PLOS ONE",
author = c(person("Chung-hong", "Chan"), person("David", "Schoch")),
url = "https://github.com/chainsawriot/rang",
year = 2023,
doi = "10.48550/arXiv.2303.04758")
doi = "10.1371/journal.pone.0286761")
2 changes: 2 additions & 0 deletions tests/testthat/test_resolve.R
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ test_that("Non-cran must enforce caching ref #22", {
## })

test_that("Integration of as_pkgrefs() in resolve() for sessionInfo()", {
skip_if_offline()
skip_on_cran()
x <- resolve(c("cran::sna"), snapshot_date = "2020-05-01", query_sysreqs = FALSE)
si <- readRDS("../testdata/sessionInfo2.RDS")
expect_error(graph <- resolve(si, snapshot_date = "2020-05-01", query_sysreqs = FALSE), NA)
Expand Down