Code Monkey home page Code Monkey logo

cookbook-r's Introduction

Description

This cookbook installs and configures R. It also contains an r_package provider which can be used in recipes to install R packages from CRAN.

Requirements

  • apt: Required for APT installation.
  • build-essential: Required for source installation.

Attributes

  • node['r']['install_method']: Specifies either "source" or "package" install method.

  • node['r']['cran_mirror]: Used by the Rprofile.site template to set the system-wide default CRAN mirror.

  • node['r']['version']: The R version to install. When using Apt, set to nil to always get the latest version.

  • node['r']['checksum']: SHA256-sum of the R source package.

  • node['r']['config_opts]: Options to pass to R's configure script. Source install only.

Providers

r_package

The r_package provider can be used to manage packages available in the CRAN repository. Currently to use this provider, your default CRAN mirror must be set. The default recipe sets this for you.

Actions

  • :install: Installs the package from CRAN. Does nothing if the package is already installed. [default]

  • :upgrade: Upgrades the package to the latest version. Currently this will re-install the package even if it is at the latest version.

  • :remove: Removes the package if it is installed.

Examples

Install a package:

r_package "snow"

Remove a package:

r_package "snow" do
    action :remove
end

Usage

Add the default recipe to the run_list of a Node or Role.

cookbook-r's People

Contributors

alejandrod avatar andirayo avatar buysse avatar davidski avatar guilhem avatar stevendanna avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

cookbook-r's Issues

Case problem

r cookbook is defined as "r" everywhere, but here http://community.opscode.com/cookbooks/r it's an "R".

Bad luck, it breaks berkshelf. when it try to get r cookbook (with a "depend r" in metadata), I get:

`stat': No such file or directory - /tmp/d20130717-10057-1gmq8xf/r (Errno::ENOENT)

Because it's /tmp/d20130717-10057-1gmq8xf/R

What is your point of view? use "R" everywhere or change cookbook to "r" in opscode website (maybe with a remove / re-create).

Install R packages via attributes

Being able to install R packages via attributes would be nice:

node['r']['packages'] = ["Rserve", "RMySQL"]

I'd be happy to give it a try, but I'm not that familiar with chef yet.

R echoing not properly turned off

When I use r_package more than once, calls alternate between correctly and fully suppressing echoing from rinruby to allowing some echoing; something is being toggled on/off with each call.

I believe that libraries/default.rb should read

def r_package_installed?(package)
  require 'rinruby'
  r = RinRuby.new(:echo=>false)
  r.eval 'packages = installed.packages()[,1]'
  packages = r.pull 'packages'
  packages.include?(package)
end

See also this comment.

Configure R installation for user driven install.packages

Installing via chef-solo(client?) means that a user can encounter the following:

install.packages(c('parallel'))
Installing package(s) into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
Warning in install.packages(c("parallel")) :
  'lib = "/usr/local/lib/R/site-library"' is not writable
Would you like to use a personal library instead?  (y/n) n

This will likely require another recipe.
I am working on it.
Question is:
Which should be the default recipe?

  • system install (as above)
  • user install (pending pull request)

Can you please tag your releases

I tie down the version of all cookbooks used.
Using this cookbook makes it hard.
You are currently on version 0.3.0 metadata.rb but it is not tagged

Avoid redundant package upgrades

Using the :upgrade action with the package provider in this cookbook results in excessive re-installation of packages because install_package is invoked unconditionally.

R will replace the installed package even if a newer version is unavailable, and this can cause problems for any jobs that attempt to make use of the package while it is being re-installed. Since Chef runs every half hour, this can happen frequently on a busy server.

I've written a short Ruby method to generate a bash command that returns true if the package needs to be updated. It does this by comparing the PACKAGES manifest against the DESCRIPTION of the package in the site-library.

def r_package_needs_update(package_name)
  available_packages_file = "/opt/R/src/contrib/PACKAGES"
  installed_package_manifest = "/usr/local/lib/R/site-library/#{package_name}/DESCRIPTION"
  sh_available_version = "awk '/^Package: #{package_name}/ {P=1} P==1 && /^Version:/ {print $2; exit}' #{available_packages_file}"
  sh_installed_version = "awk '/^Version/ {print $2}' #{installed_package_manifest}"
  "[ $(#{sh_available_version}) != $(#{sh_installed_version}) ]"
end

This seems to work, but would need to be generalized instead of hard-coding the paths. The check executes very quickly (~0.01s) compared to calling into R (~0.50s) but I'm not sure if this is a durable approach for checking package versions.

No version specified, and no candidate version available for gcc-gfortran

When installing R with the source install_method i got the following error. I am using ubuntu 12.04.4

[2015-03-06T10:59:32-08:00] DEBUG: package[gcc-gfortran] checking package status for gcc-gfortran

* No version specified, and no candidate version available for gcc-gfortran
================================================================================
Error executing action `install` on resource 'package[gcc-gfortran]'
================================================================================

Chef::Exceptions::Package
-------------------------
No version specified, and no candidate version available for gcc-gfortran

Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/r/recipes/install_source.rb

 28: package "gcc-gfortran"
 29: 

Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/r/recipes/install_source.rb:28:in `from_file'

package("gcc-gfortran") do
  action :install
  retries 0
  retry_delay 2
  guard_interpreter :default
  package_name "gcc-gfortran"
  timeout 900
  cookbook_name "r"
  recipe_name "install_source"
end

[2015-03-06T10:59:33-08:00] INFO: Running queued delayed notifications before re-raising exception

Souce package downloaded to /tmp

The source installation method currently downloads the source tarball to /tmp.

/tmp may be mounted as a tmpfs, making it ill-suited for large files.

Can't Install Old Version of R

I set the version of R using the following attribute
node['r']['version'] = '3.2.0-1precise'

However, this gives me a converge error, the gist of it being:

The following packages have unmet dependencies:
r-base : Depends: r-recommended (= 3.2.0-1precise) but 3.2.0-4precise0 is to be installed
Recommends: r-base-html but it is not going to be installed
STDERR: E: Unable to correct problems, you have held broken packages.
---- End output of apt-get -q -y install r-base=3.2.0-1precise ----
Ran apt-get -q -y install r-base=3.2.0-1precise returned 100

I tried to install via the command line with the following command but got the same error

sudo apt-get install r-base=3.2.0-1precise

Installation succeeded with the following command instead:

sudo apt-get install r-base=3.2.0-1precise r-recommended=3.2.0-1precise

Combine/collaborate on rstudio cookbook?

Hey @stevendanna,

I'm the author of the rstudio cookbook. I was wondering if it might make sense to either coordinate or combine our efforts. I'm currently working on an update that includes better APT support and a recipe for the Shiny server. I was going to fork and use the r_package LWRP or copy it, but instead have this set as a dependency. I think the only place our cookbooks overlap is the installation of r-base.

Just thought I'd say hello and get your thoughts. It might not make sense to combine them, but I think it makes sense to combine efforts on r-base and to ensure my usage of r_package is solid.

Cheers,

--Joe

Naming consistency: r, R, r-project

All trivial points. Nonetheless:

Could the cookbook adopt a single name r? At the moment we have:

  • r-project as the community site name.
  • r as the github site name
  • r-project as the recipe name
  • R as the node key

Ruby convention suggests that
R_package should be r_package

Would you accept a pull request that made this uniform?
Would you accept r (assuming there is no cookbook named r that predates/has priority), or something else?
I am not aware of child dependencies, but this sort of change should justify a minor version bump.

r_package fails to report install failure

I got an issue while installing 'biom' package. It has been removed from the CRAN repository, so the r_package resource fails to install it and does not report any kind of error.

For example: r_package 'biom'

This converges successfully , however the r package is not installed. The expected behaviour would be for this to fail as the package cannot be found.

Thank you.

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.