天道酬勤,学无止境

opencpu

Using OpenCPU to access custom R function

Question I have an R code which loads the RandomForest model, I am looking to create a function which load(model) randomforest_func = function(data) { data$pred = predict(model,data,type="prob") output = data.frame(data$customerid,data$pred[,2]) return(output) } I need to make this function enabled in webserver, where an external application feeds data and retrieves the output. The problem is, the model needs to be preloaded and cannot load into R env for each request. The function needs to support parallel connections. I tried installing opencpu in R. The above code should be running in R and

2021-11-21 04:41:26    分类:技术分享    javascript   r   api   opencpu

Need help for OpenCPU and igraph output format

Question My data Adjancy array is var g = [[10, 2], [15, 0], [18, 3], [19, 6], [20, 8.5], [25, 10], [30, 9], [35, 8], [40, 5], [45, 6], [50, 2.5]] and my OpenCPU code is ocpu.call("centralization.closeness", {graph: g}, function(res){ // console.log(ocpu.seturl(res.output[0])); $http.get("//public.opencpu.org/"+res.output[0]+"/json").success(function(data) { console.log(data); }); }); this is giving error OpenCPU error HTTP 400 Not a graph object In call: centralization.closeness(graph = g) Answer1 centralization.closeness takes a graph object and not an array Suggestion: convert the array to

2021-11-13 14:47:18    分类:技术分享    javascript   angularjs   r   opencpu

OpenCPU error HTTP 400 Not a graph object

Question I m using Angularjs and OpenCPU to calculate some data through Igraph R Package Graph is a adjacency matrix/Array generate by java script [[0,1,1,0,1,1,0,0,0,1,1,1,1,1],[1,0,1,1,1,1,1,1,1,1,0,1,1,1],[1,1,0,1,0,1,1,1,1,1,1,1,1,1],[0,1,1,0,1,0,0,0,0,1,0,1,0,0],[1,1,0,1,0,1,0,0,0,1,1,0,1,0],[1,1,1,0,1,0,0,1,0,1,1,1,1,1],[0,1,1,0,0,0,0,1,0,0,1,1,1,1],[0,1,1,0,0,1,1,1,1,1,0,1,0,1],[0,1,1,0,0,0,0,1,0,1,1,0,0,0],[1,1,1,1,1,1,0,1,1,0,0,0,0,1],[1,0,1,0,1,1,1,0,1,0,0,0,1,1],[1,1,1,1,0,1,1,1,0,0,0,0,1,1],[1,1,1,0,1,1,1,0,0,0,1,1,0,0],[1,1,1,0,0,1,1,1,0,1,1,1,0,0]] My code is ocpu.call("graph

2021-11-13 14:43:11    分类:技术分享    angularjs   r   igraph   opencpu

Test R app via openCPU localy

Question I wrote an R package and now I want to provide let's say a small demo fronted as a webapplication. For this I already wrote a index.html file which I saved to the <pkgRoot>/inst/www/ folder. I also installed the opencpu package which works fine wehen I use it via the localhost:<portNum>/ocpu/test/ "Interface", where I already can see my Package and use the Ajax POST and GET requests in order to see the package is doing what it's ment to do. But now im stuck in a sense that I do not know how to test my own app (index.html) localy. localhost:<portNum>/ocpu/<pkgName>/www/index.html does

2021-10-23 10:03:46    分类:技术分享    r   opencpu

rJava fails while invoking RJDBC library from OpenCPU API

Question Goal : To use RJDBC with OpenCPU AJAX Post call. Use case : I need to connect with Apache phoenix database and get some data. And on that data I am supposed to do analytics. So to connect with Phoenix i am using rjdbc(phoenix doesn't support any other option to connect). Environment : public.opencpu.org Here is what I am trying: html <textarea> library(RJDBC) .. do some data fetching and then r statistics </textarea> <br /> <button id="submitbutton" >Execute</button> <br /> <br /> <div id="output"> </div> javascript <script type="text/javascript"> //When Document is Ready $(function (

2021-10-20 04:04:48    分类:技术分享    r   rjava   opencpu   rjdbc

Rmpi, OpenCPU, and Apparmor: DENIED request for "/"

Question I have an R package that sends out a job to the OpenMPI cluster I have running by means of the Rmpi package. All works as expected within an R session run from the console. However, when I try to execute the relevant function with from my OpenCPU server like this (details changed to protect the innocent): curl -XPOST http://99.999.999.99/ocpu/library/MyPackage/R/my_cluster_function I get this error: R call failed: process died. (Other, non-cluster calling functions within the package work as expected via OpenCPU). I noticed in /var/log/kern.log a variety of requests being DENIED by

2021-10-19 12:01:05    分类:技术分享    r   mpi   openmpi   opencpu   apparmor

OpenCPU admin opencpu.demo

Question I am recieveing an error when I run the admin app on my OpenCPU Server Error Message : Not Found The requested URL /Radmin/call/opencpu.demo/install.opencpu/json was not found on this server. I have the R folder of the opencpu repo and the package installed yet I dont know where the install.opencpu function file is Answer1 I'm not sure where you found the /Radmin/ url, but that feature never made it into opencpu. Try to stick with the stuff from the manual page: www.opencpu.org.

2021-09-30 14:17:26    分类:技术分享    r   opencpu

Is there a mechanism to persist/record data from requests to an OpenCPU server?

Question Firstly, I appreciate there are many good reasons NOT to do this, but for interest, my question is: is there a recommended (or tolerated) method to persist information from an http request to the R session which is running the server? As an example, a trigger in an external system fires an http request on update, which contains basic information (time of update). What is the best way to make that (now-updated) time variable available in R? As an example below, I tried using the ..\identity API to write a simple .csv file. I got a result which didn't appear to be a failure, but the

2021-09-24 06:31:50    分类:技术分享    r   opencpu

How to start/stop/flush OpenCPU on CentOS6?

Question I've successfully built and installed OpenCPU and RStudio Server on a CentOS6. Everything is working as expected, and I do get successful GET/POST responses for my local R packages. A couple of things that don't seem to work however: I can't figure a clean way to start/stop/flush OpenCPU. I'm currently using apachectl restart but I'm not even sure that does reload R packages as expected. I tried Jeroen's bash scripts at /usr/lib/opencpu/scripts but they seem to require quite a bit of tweaking to work on CentOS. (maybe related to above) I am using load() and readRDS() in /etc/opencpu

2021-09-15 08:44:16    分类:技术分享    r   centos6   opencpu

Accessing objects in opencpu sessions

Question How do I access a specific object in an opencpu "session" in a subsequent function call? Given a request, say to /ocpu/library/base/R/eval with parameter expr = "x <- 10; y <- 20" Which gives /ocpu/tmp/x08dfddafe3/R/.val /ocpu/tmp/x08dfddafe3/R/x /ocpu/tmp/x08dfddafe3/R/y /ocpu/tmp/x08dfddafe3/stdout /ocpu/tmp/x08dfddafe3/source /ocpu/tmp/x08dfddafe3/console /ocpu/tmp/x08dfddafe3/info Now .val has the value 20. Suppose I wanted to pass x to ocpu/library/stats/R/rnorm Is there a quick way to that, something like n = x08dfddafe3/R/x in "pseudo"... Answer1 Great question. Starting

2021-09-01 02:46:09    分类:技术分享    r   opencpu