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("http://try.activeeon.com/rest/scheduler/version")
print(r.text)

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:
  • example.py shows various interactions with the Scheduler API, logging in, submitting a job and waiting for it to finish.
  • scheduler.py 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.

No comments:

Post a Comment