Skip to content

Example for learning a Python based system using LearnLib and Py4J

License

Notifications You must be signed in to change notification settings

mtf90/learnlib-py4j-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

learnlib-py4j-example

This example shows how to learn a python-based system under learning (SUL) using LearnLib.

This example is a python-first example, meaning the core of our setup is written in Python and we use Py4J in order to use the Java based LearnLib from our Python program.

If you want a java-first approach, you may look into technologies such as Jython which allows you to run Python programs on the JVM. If you want to go deeper down that rabbit hole, GraalVM may be worth a look as well.

Requirements

In order to run the Java side of the example you need to have a working JDK 8+ installation. OpenJDK should work just as well as OracleJDK. Furthermore, we use Maven in order to build our LearnLib-Py4J connector.


For the Python side of this example you need to have a working Python installation. The example has only been tested with Python3 - Python2 may or may not work. We strongly suggest to install the virtualenv tool in order to setup the Python side of Py4J without affecting your global Python installation - although technically you only need to have the python-py4j libraries installed somewhere.


In order to show the learned hypothesis automata, we suggest to install GraphVIZ. However, if GraphVIZ (more specifically, DOT) is not installed, LearnLib will fallback to the JUNG library, which is a fully Java-based visualization approach.

Preparing the example

First, we will build the Java side of this example, which will leave us with an executable JAR containing the LearnLib and Py4J code.

cd java
mvn package
cd ..

Then, we setup our virtual python environment and install the py4j libraries

virtualenv python/venv
source python/venv/bin/activate
pip install py4j==0.10.8.1

Running the example

To run the example, we first start our JVM process that listens for any calls performed by our Python programm (via the Py4J framework):

java -jar java/target/learnlib-py4j-example-1.0-SNAPSHOT.jar


Then, we simply run our Python program:

python python/Main.py


Once we are finished, the JVM process can be terminated by pressing Ctrl + C

About

Example for learning a Python based system using LearnLib and Py4J

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published