diff --git a/DESCRIPTION b/DESCRIPTION index feb68be..5213434 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: depmap Type: Package Title: Cancer Dependency Map Data Package -Version: 1.17.4 +Version: 1.17.5 Authors@R: c(person(given = "Laurent", family = "Gatto", email = "laurent.gatto@uclouvain.be", comment = c(ORCID = "0000-0002-1520-2268"), @@ -33,6 +33,7 @@ Imports: AnnotationHub, BiocFileCache, httr2, + curl, tibble License: Artistic-2.0 Encoding: UTF-8 diff --git a/NAMESPACE b/NAMESPACE index cee2768..461da59 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -30,6 +30,7 @@ importFrom(BiocFileCache,bfcquery) importFrom(BiocFileCache,bfcrpath) importFrom(ExperimentHub,ExperimentHub) importFrom(ExperimentHub,createHubAccessors) +importFrom(curl,has_internet) importFrom(httr2,req_perform) importFrom(httr2,request) importFrom(httr2,resp_body_json) diff --git a/NEWS.md b/NEWS.md index 5f38cc6..3c53764 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,10 @@ # depmap 1.17 +## Changes in version 1.17.5 + +- Check if there's internet connectivity before creating hub + accessors. + ## Changes in version 1.17.4 - Fix .onLoad() to create Hub accessors for all experiments, including diff --git a/R/loading_functions.R b/R/loading_functions.R index fb00338..822a901 100644 --- a/R/loading_functions.R +++ b/R/loading_functions.R @@ -1,3 +1,16 @@ +##' @importFrom utils read.csv +##' @importFrom ExperimentHub createHubAccessors +.createDepMapHubAccessors <- function(pkgname = "depmap") { + fls <- dir(system.file("extdata", pkgname), + full.names = TRUE, pattern = "metadata") + sapply(fls, + function(fl) { + titles <- read.csv(fl, stringsAsFactors = FALSE)$Title + ExperimentHub::createHubAccessors(pkgname, titles) + }) +} + + ##' @importFrom AnnotationHub query ##' @importFrom ExperimentHub ExperimentHub @@ -9,7 +22,7 @@ depmap_data_loading <- function(name) { } #' @export -depmap_rnai <- function() +depmap_rnai <- function() depmap_data_loading("rnai") #' @export diff --git a/R/zzz.R b/R/zzz.R index 4354388..15f1202 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -1,13 +1,10 @@ -##' @importFrom utils read.csv -##' @importFrom ExperimentHub createHubAccessors +##' @importFrom curl has_internet .onLoad <- function(libname, pkgname) { - fls <- dir(system.file("extdata", package = pkgname), - full.names = TRUE, pattern = "metadata") - sapply(fls, - function(fl) { - titles <- read.csv(fl, stringsAsFactors = FALSE)$Title - ExperimentHub::createHubAccessors(pkgname, titles) - }) + if (curl::has_internet()) + .createDepMapHubAccessors() + else + warning("Not internet connectivity. Unable to create Hub accessors.", + call. = FALSE) } .onAttach <- function(libname, pkgname) {