Giter Club home page Giter Club logo

warp10-plugin-py4j's Introduction

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
...

warp10-plugin-py4j's People

Contributors

ftence avatar giwi avatar hbs avatar randomboolean avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.