waldronlab / bugsigdbr

R-side access to published microbial signatures from BugSigDB
https://bioconductor.org/packages/bugsigdbr
GNU General Public License v3.0
4 stars 2 forks source link

Error if more than 1 devel cache #52

Open jwokaty opened 7 months ago

jwokaty commented 7 months ago

If you have more than one BiocFileCache entry the conditional qgsc$rtype != "web" fails. Prior to these lines of code, I had run bugsigdbr::importBugSigDB(version="devel", cache=FALSE) at least twice with time in between runs in that time it looks like the downloads had happened different ways. (I'm not sure if this is a problem users will have but I am documenting it in case I encounter again.)

Code

> bsdb <- bugsigdbr::importBugSigDB(version = "devel")
Error in if (qgsc$rtype != "web") BiocFileCache::bfcremove(bfc, rid) else { : 
  the condition has length > 1
> traceback()
2: .getResourceFromCache(rname, FUN = .getdf)
1: bugsigdbr::importBugSigDB(version = "devel")

The following shows what was in my cache, which shows 2 fpaths so I wonder if that's why they were treated like different resources rather than the same resource.

> rname <- paste("bugsigdb", "devel", sep = "-")
> ucdir <- "bugsigdbr"
> cache.dir <- tools::R_user_dir(ucdir, which = "cache")
> bfc <- BiocFileCache::BiocFileCache(cache.dir) 
> qgsc <-  BiocFileCache::bfcquery(bfc, rname, exact = TRUE)
> qgsc
  id   rid          rname         create_time         access_time
1  2  BFC2 bugsigdb-devel 2022-01-11 17:23:37 2023-12-01 14:25:15
2 17 BFC17 bugsigdb-devel 2023-12-01 15:24:59 2023-12-01 15:24:59
                            rpath rtype
1       3e171791b43d_3nvzm3fx.rds   web
2 67fb23817f1e4_full_dump.csv.rds   web
                                                                             fpath
1                                                     https://tinyurl.com/3nvzm3fx
2 https://raw.githubusercontent.com/waldronlab/BugSigDBExports/devel/full_dump.csv
  last_modified_time
1                 NA
2                 NA
                                                                etag
1 W/83be0521ad06490f16f09ca292ba45855b431ffc07dc1703845cecea88c7a3db
2                                                               <NA>
              expires
1 2023-12-01 14:30:15
2                <NA>
> BiocFileCache::bfccount(qgsc)
[1] 2

Reproducible Example

Not sure yet how to reproduce because I'm not sure why they have different fpaths. One way to resolve the issue to delete the bugsigdbr cache in BiocFileCache.

R session information

> sessionInfo()                                                                                                                                                                                                                               
R version 4.3.2 (2023-10-31)                                                                                                                                                                                                                  
Platform: x86_64-pc-linux-gnu (64-bit)                                                                                                                                                                                                        
Running under: Ubuntu 22.04.3 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0 
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

time zone: America/New_York
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] bugsigdbr_1.8.1      BiocFileCache_2.10.1 dbplyr_2.4.0        

loaded via a namespace (and not attached):
 [1] vctrs_0.6.4      httr_1.4.7       cli_3.6.1        rlang_1.1.2     
 [5] DBI_1.1.3        purrr_1.0.2      generics_0.1.3   glue_1.6.2      
 [9] bit_4.0.5        fansi_1.0.5      tibble_3.2.1     filelock_1.0.2  
[13] fastmap_1.1.1    lifecycle_1.0.4  memoise_2.0.1    compiler_4.3.2  
[17] dplyr_1.1.4      RSQLite_2.3.3    blob_1.2.4       pkgconfig_2.0.3 
[21] R6_2.5.1         tidyselect_1.2.0 utf8_1.2.4       pillar_1.9.0    
[25] curl_5.1.0       magrittr_2.0.3   withr_2.5.2      tools_4.3.2     
[29] bit64_4.0.5      cachem_1.0.8    
>