Skip to content

Commit

Permalink
remove http from desc
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Oct 4, 2024
1 parent 6b57d38 commit efc2eb4
Show file tree
Hide file tree
Showing 10 changed files with 8 additions and 56 deletions.
1 change: 0 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ Suggests:
grDevices,
gt,
httptest2,
httr,
httr2,
interp,
ivreg,
Expand Down
48 changes: 0 additions & 48 deletions R/download_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,54 +32,6 @@ download_model <- function(name,
url = "https://raw.github.com/easystats/circus/master/data/",
extension = ".rda",
verbose = TRUE) {
if (check_if_installed("httr2", quietly = TRUE)) {
.download_data_httr2(name, url, extension, verbose)
} else {
.download_data_httr(name, url, extension, verbose)
}
}


# Download rda files from github, using httr
.download_data_httr <- function(name, url, extension, verbose) {
check_if_installed("httr", "to download models from the circus-repo")

url <- paste0(url, name, extension)

temp_file <- tempfile()
on.exit(unlink(temp_file))

result <- tryCatch(
{
request <- httr::GET(url)
httr::stop_for_status(request)
},
error = function(e) {
if (verbose) {
format_alert(
"Could not download model. Request failed with following error:",
e$message
)
}
NULL
}
)
if (is.null(result)) {
return(NULL)
}

writeBin(httr::content(request, type = "raw"), temp_file)

x <- load(temp_file)
model <- get(x)
rm(x)

model
}


# Download rda files from github, using httr2
.download_data_httr2 <- function(name, url, extension = ".rda", verbose = TRUE) {
check_if_installed("httr2", "to download models from the circus-repo")

url <- paste0(url, name, extension)
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-GLMMadaptive.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
skip_if_offline()
skip_if_not_installed("GLMMadaptive")
skip_if_not_installed("lme4")
skip_if_not_installed("httr")
skip_if_not_installed("httr2")

m <- download_model("GLMMadaptive_zi_2")
m2 <- download_model("GLMMadaptive_zi_1")
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-brms_aterms.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ skip_on_cran()
skip_if_offline()
skip_on_os("mac")
skip_if_not_installed("brms")
skip_if_not_installed("httr")
skip_if_not_installed("httr2")

# Model fitting -----------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-brms_missing.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ skip_on_cran()
skip_if_offline()
skip_on_os("mac")
skip_if_not_installed("brms")
skip_if_not_installed("httr")
skip_if_not_installed("httr2")

# Model fitting -----------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-clean_names.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ test_that("clean_names, model", {

skip_on_cran()
skip_if_offline()
skip_if_not_installed("httr")
skip_if_not_installed("httr2")

test_that("clean_names, multimembership", {
m1 <- suppressWarnings(insight::download_model("brms_mm_1"))
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-download_model.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
skip_if_not_installed("httptest2")
skip_if_not_installed("httr2")

httptest2::with_mock_dir("download-model-success", {
test_that("we can successfully get existing model", {
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-format_table.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ skip_if_offline()
skip_on_os(c("mac", "linux", "solaris"))
skip_if_not_installed("bayestestR")
skip_if_not_installed("rstanarm")
skip_if_not_installed("httr")
skip_if_not_installed("httr2")

# test for bayesian models -----------------
m1 <- insight::download_model("stanreg_glm_1")
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-gam.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
skip_if_offline()
skip_if_not_installed("mgcv")
skip_if_not_installed("httr")
skip_if_not_installed("httr2")
skip_if_not_installed("withr")

set.seed(123)
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-get_loglikelihood.R
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ test_that("get_loglikelihood - (g)lmer", {
ll2 <- stats::logLik(x, REML = FALSE)
expect_equal(as.numeric(ll), as.numeric(ll2), tolerance = 1e-4, ignore_attr = TRUE)

skip_if_not_installed("httr")
skip_if_not_installed("httr2")

model <- download_model("lmerMod_1")
skip_if(is.null(model))
Expand Down

0 comments on commit efc2eb4

Please sign in to comment.