Running the Application
Wallaroo uses an embedded Python runtime wrapped with a C API around it that lets Wallaroo execute Python code and read Python variables. So when
machida --application-module my_application is run,
machida (the binary we previously compiled), loads up the
my_application.py module inside of its embedded Python runtime and executes its
application_setup() function to retrieve the application topology it needs to construct in order to run the application.
machida3 does the same, but with an embedded Python 3 runtime instead of Python 2.7.
Generally, in order to build a Wallaroo Python application, the following steps should be followed:
- Build the
machida3 binary (this only needs to be done once)
import wallaroo in the Python application’s
- Create classes that provide the correct Wallaroo Python interfaces (more on this later)
- Define an
application_setup function that uses the
ApplicationBuilder from the
wallaroo module to construct the application topology.
machida3 with the application module as the
Once loaded, Wallaroo executes
application_setup(), constructs the appropriate topology, and enters a
ready state where it awaits incoming data to process.
A Note About PYTHONPATH
Machida uses the
PYTHONPATH environment variable to find modules that are imported by the application. You will have at least two modules in your
PYTHONPATH: the application module and the
wallaroo module. If you have installed Wallaroo as instructed and follow the Starting a new shell for Wallaroo instructions each time you start a new shell, the
wallaroo module and any application modules in your current directory will be automatically added to the
If the Python module you want is in a different directory than your current, like:
$HOME/wallaroo-tutorial/wallaroo-0.6.1/examples/python/alerts_stateless/alerts.py, in order to use the module you would export the
PYTHONPATH like this:
To try running an example, go to the Alerts example application and follow its instructions.
To learn how to write your own Wallaroo Python application, continue to Writing Your Own Application
To find out more detail on the command line arguments and other aspects of running Wallaroo application, see the Running Wallaroo section.