Creating Custom nodes using python

Hi everyone, I would like to ask a question that is related to the way one needs to follow in order to create a custom node in node-red. I would like to create a custom node that will be able to run an explainability algorithm (or a causal inference algorithm). For this reason, I was wondering if there is a way to use python instead of javascript to define the functionality that the node will have (because apparently there are some related libraries in python). Is there a feasible way to do that?

You can run a python script using the Exec node.

1 Like

Hi, thank you very much for the reply. My intention is to deliver a dockerized node-red app with some custom nodes, that some of them have to be able to get input (a pre-trained machine learning model and its predictions) and to use some python code to do explainability. Is this feasible to be done with the Exec node? Thank you in advance!

Yes - as long as you also install python and all the required libraries into your container image. You may well nee to start with something like a standard ubuntu container and then build everything on top of that - rather than start with the default Node-RED one which is built on Alpine.

1 Like

Without knowing the steps to create nodes I would be surprised if you could not let your node in some way communicate with an external service. Like you can do in Node-RED already. As mentioned, running a Python script using the Exec node and get the results returned back or communicate via MQTT, communicating with the Python script also supporting MQTT. I do this a lot myself, in this way having the best of brands (in my case using yolo for object detection in video streams, all done in Python and the result including the annotated images returned back to Node-RED)

1 Like

Nice, thank you very much

Cool, most probably I will need to do the same, thanks

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.