Extract from Steven Luke’s article “Python on the Nuix Engine Part 2: Integrating Nuix Into Your Python Application”
In Part 1 of this series, we discussed a few ways you could use Python inside the Nuix Engine. Most commonly, customers use Worker Side Scripts to execute relatively simple code during processing but we focused on integrating a larger external Python application by either calling it as an external command line application or by calling into a microservice. In both cases, Nuix Workstation or the Nuix Engine is the driving application and you are integrating Python into your Nuix workflow. This time we will investigate two methods of integrating the Nuix Engine into your Python environment or application:
- Using the Engine Java API to call directly into the Nuix Engine
- Using the Nuix Engine RESTful Interface.
These approaches let you integrate Nuix into existing applications and automation workflows, minimizing the changes to your existing workflows and doing away with most manual steps needed to get data in or out of Nuix.
You can access the code repository for this blog post from our GitHub.
Using the Java API
It is relatively easy and common to run Python code inside a Java virtual machine – Nuix takes advantage of Jython to do that, and a large part of Part 1 of this series used this feature. But you can also do the opposite: run Java application code in your Python code base. There are several tools available to do this, but for this blog post I will use the pyjnius module. You can find pyjnius at kivy/pyjnius: Access Java classes from Python (github.com) and install it on Python 3 using pip.
The example presented here will be a sort of “hello world” for the Nuix Engine – starting the engine and getting a license. To understand how to use the Nuix Engine’s Java API you should read the Java Docs found online here: Java API (Engine API 9.6.10) (nuix.com) (and if you have the Nuix Engine installed, the docs are also found locally in the engine’s docs subfolder). You can find the code for this part of the post in the engine_in
package in the provided GitHub repository and its usage in the repository’s ReadMe.