From your question you say you need to invoke the Python script without using the InvokeScriptedProcessor
or ExecuteScript
processors because you can’t use Jython. Given that requirement, you should still be able to accomplish your goal. While it requires some familiarity with the framework, all of this information is from the ExecuteStreamCommand
documentation.
Your “I currently don’t understand” section:
-
How to call the python script (from the ExecuteStreamCommand Processor)
-
In your
ExecuteStreamCommand
processor, configure the Command Arguments and Command Path properties with the following:- Command Arguments:
any flags or args, delimited by ;
(i.e./path/to/my_script.py
) - Command Path:
/path/to/python3
- Command Arguments:
-
-
How to load up the FlowFile from within Python
- The flowfile content will be passed via STDIN, so in your Python script, process that data the same way you would normally process STDIN.
- How to update or create a new FlowFile from within Python
- NiFi handles the flowfile creation in the framework. Any data passed by your Python script to STDOUT will be populated into the content of the resulting flowfile passed to the output stream relationship of the
ExecuteStreamCommand
processor. Your script does not need to have any awareness of “flowfiles” in this instance. If you were instead using theISP
orES
processors, you could use the NiFi scripting API which is automatically injected into the scripts to create or update the flowfile object.
- NiFi handles the flowfile creation in the framework. Any data passed by your Python script to STDOUT will be populated into the content of the resulting flowfile passed to the output stream relationship of the
- How to output the updated FlowFile from Python back to NiFi.
- Again, simply write the desired flowfile content to STDOUT from your script, and (given a return status code of
0
) NiFi will generate a new flowfile with that content. If you set the Output Destination Attribute property ofESC
to a non-null value, NiFi will instead update the existing flowfile with a new attribute of the same name containing the output of the script.
- Again, simply write the desired flowfile content to STDOUT from your script, and (given a return status code of