Git Product home page Git Product logo

Comments (10)

igordot avatar igordot commented on July 18, 2024 1

I was using reticulate 1.24 (the latest). I assume that's the case for GitHub Actions as well.

It looks like it's still using "r-reticulate" by default, though:
https://github.com/rstudio/reticulate/blob/256e3bc440a78a8f289b214ca715e65ce6b1e43d/R/miniconda.R#L66

from leiden.

TomKellyGenetics avatar TomKellyGenetics commented on July 18, 2024 1

Leiden v0.3.10 which should resolve this has been submitted to CRAN.

from leiden.

TomKellyGenetics avatar TomKellyGenetics commented on July 18, 2024

Thank you for reporting this. This is unexpected. Of course I already had a conda environment installed on my machine before adding this feature to later versions.

Note that the .onAttach function requires that a conda environment named "r-reticulate" must be installed. It attempts to install missing dependencies there.

onAttach <- function(libname, pkgname) {
    if(!reticulate::py_available()){
        tryCatch({
            if(!("r-reticulate" %in% reticulate::conda_list()$name)){

As you've noted this is for convenience only and the package can be used if a conda environment is already set up.

This subroutine appears not to work due to different naming schemes between reticulate in R and conda in the command-line. I will investigate this to patch in a future release. Since some install steps are OS-specific, are you able to share details on which system you encountered the error?

Thanks for testing it on GH Actions, that is really helpful.

from leiden.

TomKellyGenetics avatar TomKellyGenetics commented on July 18, 2024

Perhaps further complicating the issue. My system (Mac OS) has multiple environments with the same name and no "base" environment.

> reticulate::conda_list()
           name                                                      python
2         conda        /Users/tom/Library/r-miniconda/envs/conda/bin/python
7  r-reticulate /Users/tom/Library/r-miniconda/envs/r-reticulate/bin/python
11 r-reticulate          /Users/tom/miniconda3/envs/r-reticulate/bin/python
conda env list
# conda environments:
base                  *  /Users/tom/Library/r-miniconda
conda                    /Users/tom/Library/r-miniconda/envs/conda
r-reticulate             /Users/tom/Library/r-miniconda/envs/r-reticulate
                         /Users/tom/miniconda3/envs/r-reticulate

You're right, reticulate seems to be doing something strange here so the .onLoad or .onAttach functions may not be working correctly.

from leiden.

TomKellyGenetics avatar TomKellyGenetics commented on July 18, 2024

I've looked into this further and found that the default conda environment for reticulate seems to be updated from "r-reticulate" to "r-miniconda". Which version of reticulate are you using?

It seems to work without duplicate environments on the new version using "r-miniconda" as a base image. So potential solutions are:

  • update the .onLoad function to use "r-miniconda" if available
  • update the DESCRIPTION to specific a minimum version of reticulate as a dependency to ensure the new environment is used
  • update the documentation describing the installation process recommending pre-configured conda environments

from leiden.

TomKellyGenetics avatar TomKellyGenetics commented on July 18, 2024

Thanks for the quick response. Sorry it's taken a long time to get back to you. Other updates to the package are necessary so I am considering whether it is possible to fix this as well.

from leiden.

igordot avatar igordot commented on July 18, 2024

No problem. This is a relatively obscure error, so shouldn't be high priority. It seemed like it may have a simple fix.

from leiden.

TomKellyGenetics avatar TomKellyGenetics commented on July 18, 2024

Thanks for the feedback. I agree it's better to have it fixed but is more complicated than I originally expected. I tried to reproduce the error on a new machine without reticulate installed before and encountered this.

Preparing transaction: done

Verifying transaction: done

Executing transaction: done

conda environment r-reticulate installed

 
CondaValueError: The target prefix is the base prefix. Aborting.

Unable to install python modules igraph and leidenalg

run in terminal:

conda install -n r-reticulate -c conda-forge vtraag python-igraph pandas umap learn

python modules igraph and leidenalg installed

I think I have a solution so I am testing installing it from this branch (the dev branch is a major update #1):
https://github.com/TomKellyGenetics/leiden/tree/test-conda-setup

devtools::install_github("TomKellyGenetics/leiden", ref = "test-conda-setup")

I am able to install this version without errors on a new system.

from leiden.

igordot avatar igordot commented on July 18, 2024

That was fast!

from leiden.

TomKellyGenetics avatar TomKellyGenetics commented on July 18, 2024

The CRAN testing system has installed Python so I had some issues with checks invoking the install which writes to disk to create a conda environment.

I've modified it so that it will prompt the user for consent to setting up a conda environment if it is not available and it will only run in interactive sessions (not in Rscript calls or R CMD CHECK). This version was resubmitted to CRAN and accepted this today. It is now available to installed from source and Windows/Mac binaries are building now.

from leiden.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.