Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Akka actors to invoke or pass messages to Python code

I've a some analysis code that's written in Python. Currently I'm using Storm to process streams. Because Storm allows invocation of python code using message serialization I an invoke Python code from Java/Scala in my Storm bolts.

I found Pykka which is a Python implementation of the actor model. I was wondering if there is a way to invoke Python code from Akka actors? For example, is it possible to pass message from Akka actors to Pykka actors ?

like image 759
Soumya Simanta Avatar asked Apr 02 '14 03:04

Soumya Simanta


1 Answers

I doubt that the wire protocols for the two remote actor model implementations could be easily bridged, but you could use 0MQ between the Scala code and a Python app. Akka allows message passing over 0MQ, so after some setup the Scala code could deal with the Python app just like any other actor, although I'm not sure what that would mean on the Python side.

Another possibility worth considering is to run your Python analysis code on the JVM using Jython. You could have a Scala actor call a Jython function/method. But if your Python code makes use of C extension modules, you'd have to find alternatives.

Yet another possibility (also assuming you aren't using C extension modules) is to give the converter py2scala a try; for data analysis code it might do a decent job. Presumably this would give you the most performant solution.

like image 100
AmigoNico Avatar answered Sep 18 '22 15:09

AmigoNico