io.warp10:warp10-plugin-py4j

Installation

$ wf g -w /path/to/warp10 io.warp10 warp10-plugin-py4j

/path/to/warp10/ is where Warp 10 is physically located.

Readme

Warp 10™ Py4J plugin

This is a Warp 10 plugin that enables to use Python to interact with the platform.

You can get it with Warpfleet.

Make sure to set these configurations:

# register the plugin
warp10.plugin.py4j = io.warp10.plugins.py4j.Py4JWarp10Plugin
# register that there are dependencies to load if any
plugin.defaultcl.io.warp10.plugins.py4j.Py4JWarp10Plugin = true
# set to true to allow to find/fetch data through py4j
egress.clients.expose = true
# set a secret to use an authentication token (strongly advised)
py4j.authtoken = your-token

More details here.

Python example

from py4j.java_gateway import JavaGateway
from py4j.java_gateway import GatewayParameters

params = GatewayParameters('127.0.0.1', 25333, auto_convert=True, auth_token="your-token")
gateway = JavaGateway(gateway_parameters=params)
stack = gateway.entry_point.newStack()
stack.execMulti('"Hello Warp 10"')
print(stack.pop())

We also made a tutorial on how to use this plugin on our blog.

SSL/TLS example

Since revision 1.0.2 it is also possible to use SSL/TLS encryption.

You will need a key pair with certificate, for example, you can generate them with:

keytool -genkey -alias some-alias -keyalg RSA -storepass some-password -keystore path/to/keystore.jks

Then, set these configuration parameters:

py4j.use.ssl = true
# In case previous configuration is true, the following must be set
py4j.ssl.keystore.path = path/to/keystore.jks
py4j.ssl.keystore.password = some-password
py4j.ssl.cert.alias = some-alias

In python, you will then have to pass a ssl.SSLContext object to GatewayParameters:

import ssl

client_ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
client_ssl_context.check_hostname = False # you can set this to True if the client loads a certification chain and you specify a hostname in GatewayParameters
client_ssl_context.verify_mode = ssl.CERT_NONE # the client won't check the certification chain as we trust the server self-certificate since we generated it
params = GatewayParameters('127.0.0.1', 25333, auto_convert=True, auth_token="your-token", ssl_context=client_ssl_context)
gateway = JavaGateway(gateway_parameters=params)

# The communication is TLS encrypted
...
Author
Avatar

SenX

contact@senx.io

Version

1.0.2

Type

Plugin

Last published

2022-05-17

License

Apache-2.0

Downloads
Repository

Github

Dependency Classifier
net.sf.py4j:py4j:0.10.8.1

Configuration

#

register the Py4J plugin

warp10.plugin.py4j = io.warp10.plugins.py4j.Py4JWarp10Plugin
# #

set to true if the jar version is not an uberjar and needs an external dependency

plugin.defaultcl.io.warp10.plugins.py4j.Py4JWarp10Plugin = true
# #

set to true to allow to find/fetch data through py4j

(this configuration is to be modified in 10-egress.conf.template)

egress.clients.expose = false
# #

gateway creation parameters (same defaults as in py4j library)

py4j.host = 127.0.0.1

py4j.port = 2533

py4j.timeout.read = 0

py4j.timeout.connect = 0

# #

set a secret to use an authentication token (strongly advised)

py4j.authtoken = your-token

# #

set to true if communication must be SSL or TLS encrypted

py4j.use.ssl = false
# #

In case previous configuration is true, the following must be set

py4j.ssl.keystore.path = path/to/keystore.jks

py4j.ssl.keystore.password = some-password

py4j.ssl.cert.alias = some-alias

#

Optional keymanager configuration

py4j.ssl.keymanager.password =

#
Versions Published
1.0.2 2022-05-17
1.0.2-uberjar 2022-05-17
1.0.1 2021-10-08
1.0.0-uberjar 2019-11-26
1.0.0-3-g53d7306-uberjar 2019-11-26