I want to execute a R script every time an azure function is triggered. The R script executes perfectly on Azure machine learning Studio. But I am failing to execute through azure function.
Is there any way to execute it?
AFAIK you'll have to create your own Runtime as R isn't supported natively.
Have you already tried "Create a function on Linux using a custom container"? Interestingly they have given R as the example of custom runtime, so hopefully that answers your question.
Related
I'm new to R, and I'm invoking an R script from a NodeJS app. When the R Script is invoked, it takes a long time in producing output. I investigated and realized that the bulk of that overhead is when it loads the libraries and the model I'm using. Let me clarify that any optimization would work, taking into account that I'm running this code in a Raspberry Pi 2 b+.
My question is: Is there a way to preload all the libraries and the model on R and then trigger predictions on demand? So that I won't need to reload the libraries and the model every time I want a prediction.
No. Since you're just invoking a script the loading of everything it has to be done everytime the script is run; since nothing didn't exist in memory before you invoked it.
One workaround I would suggest is to instead run a R script have your R script running as a service and then query that service from nodejs.
I cannot help you with that since my expertise for R doesn't go very far away and I don't know if having an R server is even possible.
An alternative to that, if it is not too cumbersome, is to port your R project to python and mount a server of some kind (which with python is extremely easy to do) and then poke that server from nodejs. Since you would be running a server you can just cache the libraries at the server startup time and have everything in RAM for your next query.
I am trying to integrate R into an Azure Function.
Instead of just calling the R exe - I want to be able to try the R.NET library to make it easier to pass and collect data between .NET and R. For example, respond to an event.
It runs fine locally, but once deployed as an Azure function, I get various errors. The latest ": This engine is not running. You may have forgotten to call Initialize"
For anyone else wanting to try this, I had to force the Azure function to run as 64bit, and also install the R extension library to the function. at RDotNet.REngine.CheckEngineIsRunning()
Has anyone had any success? Is anyone with R.NET experience wanting to help getting to work as an Azure function environment?
Looking at the code in R.NET for the functions RDotNet.REngine.GetInstance(), RDotNet.REngine.CheckEngineIsRunning(), and RDotNet.REngine.Initialize(), it appears as though creating the engine instance via RDotNet.REngine.GetInstance() should help you avoid this issue, as after calling that the method should be running, and you should not be encountering this area.
It is possible that you are encountering some error in creating this instance. Looking at the code comments about usage in the above link, it looks like an environment variable needs to be set for PATH. It is possible that the code you used to set this up does not work in Azure Functions. You can manually set environment variables in Azure Functions by using App Settings.
I'm looking to build an Android app which calls an R script on clicking a button. I don't know how to get an R script to run using Android. I tried using openCPU but couldn't get ahead with it. Can anyone tell me how to call a custom R script using Android?
I have a vb.net program which processes some data and user input and then uses R.net to set this information into R objects and run R scripts on these objects.
My problem is that this is hard for me to debug, as the error messages that bubble back up through the Visual Studio debugger about the R scripts are often not helpful.
My latest solution to this is to add
engine.Evaluate("save.image('Scripts/debugging/image.RData')")
into my vb.net code just before the script that has an error. This allows me to load up the objects in my R IDE and check if everything is in the form I expect it to be.
I was wondering if there was a better way to do this? For instance I wonder is it possible to set up the R environment/engine to run a save.image() if an error is encountered automatically?
I would like to pass a PostgreSQL connection object (which is an RObject) to a batch process. Is this possible at all?
Why am I trying to do this?
I had trouble running a script that sources another script on R Studio Server. The script itself runs fine without the other script sourcing it. So this is clearly an R Studio Server Web Interface issue. However I am trying to circumvent the issue by just triggering a batch from R Studio server, after I used its nice .rs.askForPassword function that ships with Rstudio. I tried to following but couldn't get it to work cause to connection always ending up being expired when it was used from the batch.
# run file
save(con,file="conObj.Rdata")
system("R CMD batch.R") # also tried Rscript
batchfile looks like this
# batch file
load("conObj.Rdata")
#.... run some db query #
save("someObjFromDb","test.Rdata")
This breaks because of an expired connection object.