stevendanna / cookbook-r Goto Github PK
View Code? Open in Web Editor NEWChef Cookbook for R
Chef Cookbook for R
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.
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.
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
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).
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
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.
Many thanks for this cookbook. Will it be uploaded to supermarket at some point?
Edit - Think I found it :-) https://supermarket.chef.io/cookbooks/r-project
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
Missing option to install packages from source URL. 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.
Example suggestion:
r_package "biom" do
action :install
tarball_base_uri :'https://cran.r-project.org/src/contrib/Archive/biom/biom_0.3.12.tar.gz'
end
Thank you.
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.
r_package won't halt convergence even when it fails to install a package. I submitted a fix in PR #36.
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.
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?
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 namer-project
as the recipe nameR
as the node keyRuby 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.
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
need support for repo installs of R for rhel based systems.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.