nifi/nifi-nar-bundles/nifi-py4j-bundle
mr1716 70c756ff78
NIFI-11953 Upgraded download-maven-plugin from 1.6.8 to 1.7.1
This closes #7613

Signed-off-by: David Handermann <exceptionfactory@apache.org>
2023-08-16 21:03:41 -05:00
..
nifi-py4j-bridge NIFI-11793 Added Python debugging properties and documentation 2023-07-24 13:23:19 -05:00
nifi-py4j-integration-tests NIFI-11793 Added Python debugging properties and documentation 2023-07-24 13:23:19 -05:00
nifi-py4j-nar NIFI-11241 Initial implementation of Python-based Processor API with Py4J 2023-04-14 15:03:34 -05:00
nifi-python-extension-api NIFI-11243: Implemented Dependent Properties on the Python side 2023-06-22 13:03:43 -05:00
nifi-python-framework NIFI-11953 Upgraded download-maven-plugin from 1.6.8 to 1.7.1 2023-08-16 21:03:41 -05:00
nifi-python-framework-api NIFI-11793 Added Python debugging properties and documentation 2023-07-24 13:23:19 -05:00
nifi-python-test-extensions NIFI-11793 Added Python debugging properties and documentation 2023-07-24 13:23:19 -05:00
README.md NIFI-11793 Added Python debugging properties and documentation 2023-07-24 13:23:19 -05:00
pom.xml NIFI-11241 Initial implementation of Python-based Processor API with Py4J 2023-04-14 15:03:34 -05:00

README.md

nifi-py4j-bundle module

The NiFi Py4J Bundle provides a linkage between NiFi's Java Process and Python. Py4J is the library used in order to launch an RPG server that can be used to communicate between the Java and Python Processes.

See the NiFi Python Developer's Guide for more information about how to build Processors in Python.

Debugging

There are times when it's helpful to enable remote debugging of the Python code. Because NiFi is responsible for launching the Python process, how to enable this may not be as straight-forward as when launching a Python process yourself. However, NiFi can be told to enable remote debugging when launching the Python process.

The manner in which you connect to the Python Process differs by IDE. Here, we will examine how to use VSCode's DebugPy.

Debugging Framework

The method for debugging the framework and debugging Processors is different. Typically, when performing debugging on the Framework itself, it is easiest to have NiFi enable a DebugPy listener when launching the Python process that hosts the Controller.

To enable remote debugging, NiFi will use pip to install the debugpy module into the environment used by the main Python process. This process is used to discover available Processors and to create Processors. It is not used by Processors themselves.

Listen for Incoming Connections (Controller)

The following properties may be added to nifi.properties in order to enable remote debugging of the Controller process:

nifi.python.controller.debugpy.enable : Indicates whether or not DebugPy should be used when launching hte Controller. Defaults to false. If set to true, the Python process that is responsible for discovering and creating Processors will be launched using DebugPy.

nifi.python.controller.debugpy.port : The local port to use. Defaults to 5678.

nifi.python.controller.debugpy.host : The hostname to listen on. Defaults to localhost.

nifi.python.controller.debugpy.logs.directory : The directory to write DebugPy logs to. Defaults to ./logs

Note that these properties do not exist in the nifi.properties by default. This is intentional and is due to the fact that during any normal operations, this should not be used. This should be used only by developers wanting to debug the NiFi application itself.

Connecting to the Python Process

It is important, however, to note the host and port that the debugger is using. When establishing a connection to the remote debugger, the VSCode may be configured with both the local directory to use for Python source files, as well as the remote debugger.

Generally, the local directory should point to ${NIFI_SOURCE_DIRECTORY}/nifi-nar-bundles/nifi-py4j-bundle/nifi-python-framework/src/main/python/framework. The remote directory, which defaults to . should be specified as ./python/framework.

Debugging Processors

It is also important to enable remote debugging for Processors. We expect Processor developers to be able to do this, not just those who are maintaining the NiFi codebase. As a result, instructions for enabling remote debugging of Processors has been added to the NiFi Python Developer's Guide.