Thursday, June 18, 2015

Execute your parallel workflows through a simple REST API

Coming versions of ProActive Workflows & Scheduling will offer a feature that will make the integration between its API and your business software an even simpler task, specially if you care only about your business and its parallelization.
We observed from some of our clients the need to maintain a clear isolation between the workflow development process, and the workflow execution process. It is just that users that deal with the core of the business often care (almost exclusively) about the workflow execution and its results. They usually submit the same workflow again and again, simply changing their inputs.
Our scheduler has been adapted for such use cases. Now you can create the workflow once (see how easy it is with our ProActive Studio after you created a free account here), and execute it with parameters through an intuitive API. No need to have the workflow on you, no need to even know there is a workflow that parallelizes the execution.

How to use such API?

So simple… Use our REST API as follows to execute workflows available in the Studio templates.
Using bash and curl, first you need to log in:
# Log in and keep the session ID somewhere
$ sessionid=`curl -k -d "username=admin&password=admin" http://localhost:8080/rest/scheduler/login`
Using the session ID, you can now list all the available templates on the server (same can be done to obtain the list of private workflows, but using /rest/studio/workflows instead of /rest/studio/templates):
# List all available templates (the ones created with the ProActive Studio will be available too)
$ curl -X GET -H "sessionid:$sessionid" http://localhost:8080/rest/studio/templates/
       "id": 2,
       "metadata": "...",
       "name": "Variable Propagation",
       "xml": "..."
       "id": 1,
       "metadata": "...",
       "name": "Pre-Post-Clean Scripts",
       "xml": "..."
Now, let’s say we are interested in submitting our template 1, you can get more details about it by doing the following:
# Choose one template and get information about it
curl -X GET -H "sessionid:$sessionid" http://localhost:8080/rest/studio/templates/1
Or even get its XML content:
# Choose one template and get its xml content
curl -X GET -H "sessionid:$sessionid" http://localhost:8080/rest/studio/templates/1/xml
Now you can execute the workflow from the scheduler providing through the header “Link” the workflow URL we have been using:
# Submit the workflow to the scheduler
curl -X POST -H "Link: http://localhost:8080/rest/studio/workflows/1/content" -H "sessionid:$sessionid" http://localhost:8080/rest/scheduler/jobs/
And that is all!!!
I know, it is just so simple.
Hope you use it!

Wednesday, June 3, 2015

Using ProActive Scheduler from a Python application

For a collaborative project we are involved in, we had to integrate with a Python application. Fortunately this is made easy by the REST API of ProActive Scheduler.
We hope this piece of code will prove useful in integrating your Python application with ProActive!

In Python, it turns out the requests library is very to use to build HTTP requests. For instance here is how to retrieve the version of the Scheduler:

import requests
r = requests.get("")

which outputs { "scheduler" : "6.1.0", "rest" : "6.1.0"}.
It is also very easy to manipulate JSON data with r.json() that returns a dictionary.

We put together a small project that should be considered more as an example rather than a full client for the Scheduler. It is available on Github:
  • shows various interactions with the Scheduler API, logging in, submitting a job and waiting for it to finish.
  • contains the code to query the REST API

You can also take a look at our REST API documentation to see how it would be possible to implement more features in this small client.