In this post, we explain how to install and use the Py4J plugin for Warp 10. This plugin allows Python scripts to interact with the WarpScript language.

The Py4J plugin allows a Python script to interact with a Warp 10 instance through the Py4J protocol.
- 1. Installation
- 2. Basic example
- 3. Configuration options
- 4. Without a running Warp 10 instance
- Conclusion
1. Installation
(Outdated: now you can simply use WarpFleet to install this plugin)
First, clone the GitHub repository of the plugin.
Then, compile and place the produced jar in the lib
folder of your Warp 10 platform.
Next, declare the Py4J plugin in the Warp 10 configuration file.
Then, if you want to be able to fetch data stored in Warp 10 from Python, set the following property to true in <Warp10_home>/etc/conf.d/10-egress.conf
:
After that, restart your Warp 10 instance for the plugin to be taken into account.
Congratulations, you can now interact with Warp 10 from a Python script!
If the latter is not installed, you can install it with pip install py4j
(or conda install py4j
if you use conda).
Also, in the log file <Warp10_home>/logs/warp10.log
, the following line should have appeared:
If it is not the case, it is probably because the log configuration file is not properly set up (per default, that was the case if the initial revision of Warp 10 you installed was between version 2.0.3 and 2.4).
To fix it, append the following lines to the file <Warp10_home>/etc/log4j.properties
then restart the platform.
2. Basic example
The Py4J plugin launches a gateway in the same JVM running Warp 10. Instances of Java objects are accessible from Python through this gateway. By default, the gateway address is 127.0.0.1
and its port is 25333
.
The following example shows how to connect to the running gateway:
The plugin allows to create WarpScript stack instances through the gateway like below:
In addition, the stack can be accessed and its methods invoked from Python. For example:
10
["checkBalanced", "clear", "define", "depth", "drop", "dropn", "dump", "dup", "dupn", "equals", "exec", "execMulti", "find", "forget", "get", "getAttribute", "getClass", "getCounter", "getDefined", "getDirectoryClient", "getGeoDirectoryClient", "getStoreClient", "getSubStack", "getSymbolTable", "getUUID", "hashCode", "inMultiline", "incOps", "isAuthenticated", "load", "maxLimits", "notify", "notifyAll", "peek", "peekn", "pick", "pop", "popn", "progress", "push", "reset", "restore", "roll", "rolld", "rot", "run", "save", "setAttribute", "store", "swap", "toString", "wait"]
3. Configuration options
When the Py4J plugin is used, it adds these additional configuration properties to Warp 10 (values given are the defaults):
As already mentioned, if you want to be able to fetch data from a stack created through a gateway, you must modify the Warp 10 configuration property egress.clients.expose
and set it to true
.
4. Without a running Warp 10 instance
You can also use WarpScript from Python without the need to have a running Warp 10 instance (however, you won't be able to use the functions FETCH
, FIND
, or FINDSTATS
).
To do that, the Py4j library provides the function launch_gateway
that starts a gateway server in a JVM from Python.
Then, you will be able to instanciate an entry point to a WarpScript stack and call the method newStack like in the previous example.
Conclusion
From now on, you should be able to launch a WarpScript stack from Python, and to go back and forth between Python and WarpScript functions.
The WarpScript reference is available on the Warp 10 website.
For more information on the possibilities of Py4J, you can see their website.
In the next blog post, we will see how to efficiently use WarpScript in Jupyter.
Read more
Archiving Time Series Data into Amazon S3
Protecting your Macros and Functions with Capabilities
2022 review of the Warp 10 platform

Machine Learning Engineer