Deploy R Code - 5Analytics Enterprise AI Platform

Deploying script code as a JSON Web-Service

Setting the scripting language of the 5Analytics Enterprise AI Platform

The 5Analytics Enterprise AI Platform offers a choice of scripting languages you can choose from to develop your web services. To set scripting language, you have to alter the main configuration file /opt/ada/etc/ada.xml. To add a scripting language

<engines>
	<engine factory="de.visionstec.R.RScriptEngineFactory" key="R">
		<extensions>R</extensions>
		<parameter id="LIBRARY_PATH">var/lib/R</parameter>
		<parameter id="WORKING_DIRECTORY">var/code</parameter>
	</engine>
	...
</engines>

In the example above, the R scripting environment is loaded. Currently, the following scripting environments are available:

The parameters that you can set for each engine are specific to that engine, please refer to the documentation of each engine.

Create a Web-Service in R

Creating a Web-Service is extremely easy. You just have to define a function and the 5Analytics Enterprise AI Platform will analyze your code and turn every function into a Web-Service with the same name.

For example, the following R script, lets call it hw.R

# a hello world web service
fafun_hello_world <- function() {
        return ("hello world");
} 

will be turned into the following web service.

http://localhost:5050/if/json/R/v1/fafun_hello_world&_token=test_token

Deploy the script

To actually deploy the script, you need to upload it to the 5Analytics Enterprise AI Platform. The AI Platform offers a WebDAV interface, which allows you to easily upload your files.

# upload file to server via webdav
> curl -u usr:pswd --digest -T hw.R 'http://localhost:5050/up/dav/'

Once you have uploaded the file the 5Analytics Enterprise AI Platform will load the code and establish the web service end point shown above. Now your Web-Service is ready to be queried.

> curl "http://localhost:5050/if/json/R/v1/fafun_hello_world?_token=test_token"
{
  "null": "hello world"
}
get_appWould you like to try the demo with your own data or with your own code?
Register for our Community Edition!
get_appGet our Community Edition
or visit our Homepage!