0

I'm trying to execute python code in the executestreamcommand processor, and trying to read/write flow files in the code, for that i have to use certain libraries for example

  • from org.apache.commons.io import IOUtils
  • from java.nio.charset import StandardCharsets
  • from org.apache.nifi.processor.io import StreamCallback

in libraries for example But I'm getting error in executeStreamCommand that No Module found. anyone knows the reason ?

1 Answers1

2

ExecuteStreamCommand is used to execute shell commands (scripts, utilities, etc.) on the command-line (a.k.a. terminal). The NiFi internal libraries are not available to scripts running in that context unless you explicitly bundle and import them in those scripts. The interaction with NiFi is limited to flowfile content being streamed via STDIN and STDOUT in that case. See this answer for more details.

If you want to use a Python script to read directly from NiFi flowfile attributes and content and implement a custom StreamCallback, you should use ExecuteScript or InvokeScriptedProcessor. This allows more tightly-coupled integration with NiFi concepts, but for Python specifically, means that natively-compiled modules (Python modules written in C) are not available, because NiFi uses Jython (JSR-223 compatible).

Andy
  • 13,916
  • 1
  • 36
  • 78