From efc2eb4e33258ad70fcc18d0c1db004bf7f33b5f Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 4 Oct 2024 13:20:54 +0200 Subject: [PATCH] remove http from desc --- DESCRIPTION | 1 - R/download_model.R | 48 ------------------------- tests/testthat/test-GLMMadaptive.R | 2 +- tests/testthat/test-brms_aterms.R | 2 +- tests/testthat/test-brms_missing.R | 2 +- tests/testthat/test-clean_names.R | 2 +- tests/testthat/test-download_model.R | 1 + tests/testthat/test-format_table.R | 2 +- tests/testthat/test-gam.R | 2 +- tests/testthat/test-get_loglikelihood.R | 2 +- 10 files changed, 8 insertions(+), 56 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index d98a4ffc2..2a838c231 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -134,7 +134,6 @@ Suggests: grDevices, gt, httptest2, - httr, httr2, interp, ivreg, diff --git a/R/download_model.R b/R/download_model.R index 56e528e8d..afbdb0c58 100644 --- a/R/download_model.R +++ b/R/download_model.R @@ -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) diff --git a/tests/testthat/test-GLMMadaptive.R b/tests/testthat/test-GLMMadaptive.R index be014f897..96b7b8543 100644 --- a/tests/testthat/test-GLMMadaptive.R +++ b/tests/testthat/test-GLMMadaptive.R @@ -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") diff --git a/tests/testthat/test-brms_aterms.R b/tests/testthat/test-brms_aterms.R index 922bf4f24..fd0c50ef5 100644 --- a/tests/testthat/test-brms_aterms.R +++ b/tests/testthat/test-brms_aterms.R @@ -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 ----------------------------------------------------------- diff --git a/tests/testthat/test-brms_missing.R b/tests/testthat/test-brms_missing.R index 137818b4b..a4637555f 100644 --- a/tests/testthat/test-brms_missing.R +++ b/tests/testthat/test-brms_missing.R @@ -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 ----------------------------------------------------------- diff --git a/tests/testthat/test-clean_names.R b/tests/testthat/test-clean_names.R index 1b4b6df35..0b3ed1815 100644 --- a/tests/testthat/test-clean_names.R +++ b/tests/testthat/test-clean_names.R @@ -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")) diff --git a/tests/testthat/test-download_model.R b/tests/testthat/test-download_model.R index ad61084b3..257607dea 100644 --- a/tests/testthat/test-download_model.R +++ b/tests/testthat/test-download_model.R @@ -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", { diff --git a/tests/testthat/test-format_table.R b/tests/testthat/test-format_table.R index 2c8d67ff5..2aef7b5e0 100644 --- a/tests/testthat/test-format_table.R +++ b/tests/testthat/test-format_table.R @@ -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") diff --git a/tests/testthat/test-gam.R b/tests/testthat/test-gam.R index a5d08386d..ae6f4b2bb 100644 --- a/tests/testthat/test-gam.R +++ b/tests/testthat/test-gam.R @@ -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) diff --git a/tests/testthat/test-get_loglikelihood.R b/tests/testthat/test-get_loglikelihood.R index 74e924b2c..4fe347679 100644 --- a/tests/testthat/test-get_loglikelihood.R +++ b/tests/testthat/test-get_loglikelihood.R @@ -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))