调用dashdb R Script并从外部获取结果

时间:2015-10-02 14:41:07

标签: r ibm-cloud node-red dashdb

我在Bluemix DashDB服务上使用R Script功能。我能够生成绘图并在dashdb控制台上显示数据(从Bluemix仪表板启动)。我想知道如何创建一个外部代码来调用此R脚本并使用结果。

该服务绑定到NodeRED应用程序。以某种方式创建一个流将使用“http”节点处理请求并在底层dashdb服务中调用R脚本并提供结果绘图作为结果将是很好的。有可能吗?

除了使用dashdb Web控制台/仪表板之外,还有其他方法可以运行R脚本吗?感谢

===

2015年/ OCT / 06更新。这是我用来调用R的流程(请参阅流编辑器上的更多注释):

[{"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"]]}]

0 个答案:

没有答案