0

I am using the R Script feature on the Bluemix DashDB service. I am able to generate plots and visualize the data on the dashdb console (launched from the Bluemix dashboard). I am wondering how can I make an external piece of code to invoke this R Script and consume the results.

The service is bound to a NodeRED application. It would be great to somehow make a flow that would use the "http" node to handle a request and invoke an R Script in the underlying dashdb service and provide the resulting plot as a result. Is it possible?

Is there any other way to run an R Script besides using the dashdb web console/dashboard? Thanks

===

Update on 2015/OCT/06. This is the flow I am using to invoke R (see some more comments on the flow editor):

[{"id":"e5480246.1ab8","type":"http in","name":"","url":"/rscript","method":"post","swaggerDoc":"","x":196,"y":541,"z":"c33d2d18.3cc2d","wires":[["e260a1e9.1d9f6"]]},{"id":"c0252e68.3fdad","type":"http response","name":"","x":848,"y":537,"z":"c33d2d18.3cc2d","wires":[]},{"id":"e260a1e9.1d9f6","type":"function","name":"","func":"msg.payload = \"cmd=RScriptRunScript&command=\"+msg.payload+\"&fileName=&profileName=BLUDB&userid=<YOUR_USER_HERE>\";\nmsg.headers = {\"content-type\": \"application/x-www-form-urlencoded\"};\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":538,"z":"c33d2d18.3cc2d","wires":[["3842660d.c7bd9a"]]},{"id":"3842660d.c7bd9a","type":"http request","name":"R Script","method":"POST","ret":"txt","url":"<YOUR_URL_HERE>:8443/console/blushiftservices/BluShiftHttp.do","x":632,"y":536,"z":"c33d2d18.3cc2d","wires":[["c0252e68.3fdad"]]},{"id":"34a821fc.cb57de","type":"comment","name":"Instructions","info":"\nGet your Connect Info from the DashDB Console (under Connect > Connection Information).\n\nYou'll have to put your USER ID it in the \"function\" node and also configure the \"http request\" node to use Basic Auth and enter your credentials there.\nAlso, make sure your URL is right according to the info presented on the DashDB Console.","x":529,"y":665,"z":"c33d2d18.3cc2d","wires":[]},{"id":"253f405e.dac0c","type":"inject","name":"","topic":"","payload":"","payloadType":"none","repeat":"","crontab":"","once":false,"x":213,"y":610,"z":"c33d2d18.3cc2d","wires":[["ba5fe664.45a018"]]},{"id":"68e07153.971f9","type":"http request","name":"R Script","method":"POST","ret":"txt","url":"<YOUR_URL_HERE>:8443/console/blushiftservices/BluShiftHttp.do","x":637,"y":615,"z":"c33d2d18.3cc2d","wires":[["2b62647.fd49d9c"]]},{"id":"2b62647.fd49d9c","type":"debug","name":"","active":true,"console":"false","complete":"false","x":848,"y":615,"z":"c33d2d18.3cc2d","wires":[]},{"id":"ba5fe664.45a018","type":"function","name":"","func":"msg.payload = \"cmd=RScriptRunScript&command=numbers <- c(4, 23, 15, 12, 43, 54, 34, 23, 65, 87)\\nsortedNumbers = sort(numbers)\\nprint(sortedNumbers)\\n&fileName=&profileName=BLUDB&userid=<YOUR_USER_HERE>\";\nmsg.headers = {\"content-type\": \"application/x-www-form-urlencoded\"};\nreturn msg;\n\n\n","outputs":1,"noerr":0,"x":419,"y":615,"z":"c33d2d18.3cc2d","wires":[["68e07153.971f9"]]}]
mnery
  • 1
  • 2
  • BTW: I've found this: [link (Anomaly App)](https://github.com/CDSLab/IDUG2015/tree/master/AnomalyApp). I was able to make a flow with an http request and run an RScript to get textual results back. Trying to generate a plot seems to work (I see a filename being generated and presented on the results message). Now, I need to find a way to be able to open/browse the file that is being generated. Any hints? Thanks. – mnery Oct 02 '15 at 18:12
  • Could you share your node-red flow that you developed so far? – Alex da Silva Oct 03 '15 at 17:47
  • @AlexdaSilva : Please, see my updated question (update on 2015/OCT/06) and let me know if you have any more questions. I'm still in trouble to be able to consume plots externally. I have access only to the RModelOutput (text). Thanks. – mnery Oct 06 '15 at 15:31

0 Answers0