Bioconductor / basilisk

Clone of the Bioconductor repository for the basilisk package.
https://bioconductor.org/packages/devel/bioc/html/basilisk.html
GNU General Public License v3.0
27 stars 14 forks source link

Unable to find reticulate function in fallback environment #37

Closed csoneson closed 7 months ago

csoneson commented 7 months ago

We are running into issues with the latest (release 1.14.3/devel 1.15.4) version of basilisk, which I think is caused by this change. Basically, after activating the fallback environment, reticulate functions such as use_condaenv() can not be found. For example:

# BiocManager::install("fmicompbio/sketchR")
> library(basilisk)
Loading required package: reticulate
> library(sketchR)
> sketchR::getScSamplerNames()
[1] "main"      "scsampler" "uclab"    
> setBasiliskForceFallback(TRUE)
[1] TRUE
> sketchR::getScSamplerNames()
Error in checkForRemoteErrors(lapply(cl, recvResult)) : 
  one node produced an error: could not find function "use_condaenv"

If I manually install the basilisk version just before the change above, it works fine - it activates the fallback environment, and returns the same vector as when the fallback was not used.

cc @ppapasaikas

vjcitn commented 7 months ago

This change was made to avoid a warning concerning library() calls in package source. I will look at this soon.

vjcitn commented 7 months ago

We are looking at this possible solution, to explicitly qualify the calls to use_condaenv and py_config where they occur:

diff --git a/R/useBasiliskEnv.R b/R/useBasiliskEnv.R
index d5a5ade..93b8590 100644
--- a/R/useBasiliskEnv.R
+++ b/R/useBasiliskEnv.R
@@ -50,11 +50,11 @@ useBasiliskEnv <- function(envpath, full.activation=NA) {
     envpath <- normalizePath(envpath, mustWork=TRUE)

     activateEnvironment(envpath, full.activation=full.activation)
-    use_condaenv(envpath, required=TRUE)
+    reticulate::use_condaenv(envpath, required=TRUE)

     # use_condaenv doesn't actually cause Python to be loaded immediately, 
     # so we force the issue to seal the deal.
-    py_config() 
+    reticulate::py_config() 

     invisible(NULL)
 }
vjcitn commented 7 months ago

Considered repaired via 6d0abb9 in devel branch and 6412875 in RELEASE_3_18

csoneson commented 7 months ago

Thanks! I pulled down the devel branch and can confirm that the fix works for me.