简体   繁体   中英

OpenCPU server requests

I'm developing a web application that should interact with some R scripts and I would very much like to use openCPU. However, I do not see if there is any way I can do other AJAX requests besides calling the R scripts or fetching their results.

I need to send R script descriptions and other stuff which can change so it has to be done in runtime by requests to server.

If anyone would be kind enough to briefly explain if this is possible, I would be very grateful.

I'm assuming when you say update descriptions that you mean the DESCRIPTION file that acts as the definition of the R package itself. When you change this or the contents of the R script, you will need to publish a new version to Open CPU. A few notes from my experience, which seems similar to yours:

  1. I have had some trouble having scripts running inside of OpenCPU install packages that are in CRAN but not available in the OpenCPU package list. OpenCPU can pull packages in from Github using the install_github function found in the devtools package. You might have to manually install in your R script using install.packages if your script is using an R function that the public OpenCPU doesn't have. This might be helpful if calling library or install.packages by itself doesn't work.

     library('devtools') install.packages("BIOMASS", repos = "https://cran.opencpu.org", method = "libcurl") library("BIOMASS") 

The list of installed packages on the public OpenCPU is here If you are using another package that is available on CRAN, you will need to add it as a dependency in your Imports section in the R package DESCRIPTION file. You can also use namespacing to avoid having to use PACKAGENAME::FUNCTIONNAME in your script.

  1. If you publish to the public OpenCPU, you can only update your package once every 24 hours .
  2. The pipeline I've found helpful is to develop my package, write some test code locally that uses it, and once I'm fairly confident, push it to my github repository. Here I have a webhook setup to publish the new package to the public OpenCPU instance. Depending on how you have your development environment setup, you might publish it manually instead. For example, if you are hosting your own OpenCPU instance, it would make more sense to publish it to your instance instead of the public one.
  3. The relevant section in the OpenCPU API documentation is where it talks about the R Package API . There's also documentation in the server manual about how to install packages if you are hosting your own OpenCPU.
  4. If you happen to be using Meteor, my experience was that it was best to make direct calls to the ReSTful / HTTP API in OpenCPU directly. The Javascript client package didn't work for me in Meteor and the HTTP API works just fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM