Support Questions

Find answers, ask questions, and share your expertise

Nifi 2.0 'Processor' is invalid because initializing runtime environment for the Processor

avatar
New Contributor

Hello everyone, 

I am facing issue with creating an custom python processor in Nifi 2.0.0. It is linux based server with installed java 22 and python 3.9.18. I also set the nifi.properties command to the python3.9.

PeterC_4-1733932110326.png


Currently I am just trying to get the simplest processor such as 

from nifiapi.flowfiletransform import FlowFileTransform, FlowFileTransformResult

class WriteHelloWorld(FlowFileTransform):
    class Java:
        implements = ['org.apache.nifi.python.processor.FlowFileTransform']
    class ProcessorDetails:
        version = '0.0.1-SNAPSHOT'

    def __init__(self, **kwargs):
        pass

    def transform(self, context, flowfile):
        return FlowFileTransformResult(relationship = "success", contents = "Hello World", attributes = {"greeting": "hello"})

This is picked up by nifi and it seems that successfuly but in the GUI the process still has the warning 'Processor' is invalid because initializing runtime environment for the Processor.

PeterC_0-1733930880467.png

From the logs I saw that there is mentioned /work/python/controller folder which is totally missing for me. When I change the __init__ to pass and manually copy the python interpreter to the /work/python/controller then the warning disappear but I get runtime error which can be seen in the log below

PeterC_1-1733931763019.png


I also verified that under the /work/python/extensions/WriteHelloWorld/0.0.1-SNAPSHOT I see correct files with dependency-download.complete with content True and empty env-creation-complete.txt

PeterC_2-1733931913821.png

In bin also I see all venv activate files created.  

PeterC_3-1733931975565.png

I also can manually enter the created venv using the activate.csh file. So the main problem seems to be with the communication between nifi and python. Nifi runs as admin. 

Any idea how to solve it or find the rootcause of this problem? I already did all the steps from Apache NiFi custom processor runtime environment e... - Cloudera Community - 390917

 

6 REPLIES 6

avatar
Super Guru

Hi @PeterC ,

I dont have experience creating python ext. processor under linux system but I would imagine it will work the same as under windows. I noticed however in python command you are using python9.3 , can you switch this to just python ? You should not be needing to manually creating the folder structure under ./work/python and all dependencies should be downloaded for your.

avatar
New Contributor

Hi @SAMSAL I have tried with python, python3 and python3.9. Same problem for all. Also could you confirm whether the /work/python/controller should be created and if yes what exactly should be there? 

avatar
Super Guru

What gets created is ".\work\python\extensions\[CustomProcessor]\2.0.0-SNAPSHOT".
it should have  all downloaded dependencies as specified in your processor code,  then venv files and folder, in case of windows it creates Script folder where all the venv files:

SAMSAL_0-1733939879242.png

 I think in Unix it store those files under Bin folder but it should not matters.

where you seeing any  error messages or warning initially before manually creating the folder? Also one thing you can try is use later python version than 3.9 , I know in my case 3.11 worked well for me.

avatar
New Contributor

PeterC_0-1734011661122.png

This is the warning I get without any manual creating folder. Meaning I just change the python.command to python add the .py and start nifi.

I upgraded the python to the python3.11 and set it as default but still same issue. Also maybe this can bring more information. This is the content of the pyvenv.cfg

PeterC_1-1734011819670.png

Also I change the logs from python to get some outputs in nifi-app.log file maybe this gives you more information. It seems that the connection is there and the python communicate with java

PeterC_2-1734013484998.png

 

 

 

avatar
Super Guru

So I took the cod you provided and created the python file and placed it unde:

.\python\extensions 

 

After that I launched nifi (Im still on 2.0.0 M4) , then I went and select the WriteHelloWorld Processor and initially without chaning or adding anything else I was getting the same warning messages you have posted in your last message, however once I added the upstream processor because it needs it , then I started to get different warning messages about not connecting success, failure & original relationships which indicates that the processor has loaded successfully. Once I terminated the failure & original relationships the warning disappeared and I can run the flow to generate the Hello World message:

SAMSAL_0-1734021314891.png

The flowfile in the success rel has the following output:

SAMSAL_1-1734021361053.png

The following files and directories have been generated under .\work\python\extensions:

\WriteHelloWorld\0.0.1-SNAPSHOT

Under 0.0.1-SNAPSHOT folder:

SAMSAL_2-1734021518598.png

Try to create the upstream processor. I know it should not make sense but maybe it needs it to complete the setup.

Hope that helps but at least it shows that there is nothing wrong with your code and its  just matter of setup and configuration against your environment.

 

 

 

avatar
Community Manager

@PeterC Has the reply helped resolve your issue? If so, please mark the appropriate reply as the solution, as it will make it easier for others to find the answer in the future. Thanks.


Regards,

Diana Torres,
Community Moderator


Was your question answered? Make sure to mark the answer as the accepted solution.
If you find a reply useful, say thanks by clicking on the thumbs up button.
Learn more about the Cloudera Community: