py-RED - WIP Python implementation of Node-RED

Hello,

So basically I just grabbed the editor-client, served it over Flask and started making things work.

NOTE: This is very early development and does nothing useful at the moment! I'm posting here for discussion purposes only. WIP - Work In Progress.

As of right now, I have two nodes working: inject and debug. The Inject node is like 50% working (inject button, inject after, and interval mode works) and the debug node is probably 90% working (print to UI, print to console, and print to node status works)

It's been a lot of fun, the readme on GitHub explains my motivation behind doing this.

Just wanting to get some input here while I'm still early on this journey. Input such as, what would you use this for if you were so inclined? And what would you like to see implemented?

For example, I want it to make tkinter UIs eventually, just making a button take dynamic arguments in Tk shouldn't be so hard!

1 Like

Hi

great idea and I hope something comes of if :+1: Btw I'm sure there have been many attempts before at this - I'm sure that are others here that could point out these efforts and the learnings from those attempts.

I had a similar idea but was put off by the effort involved in porting all those nodes to Python and instead I created the in-browser Node-RED implementation that attempts to simulate some nodes in the browser to have a working version of Node-RED running in the browser.

I took the same approach that you are, i.e., take the client as it is and then implement a backend that is able to work with that. It turns out that there isn't much that needs simulating (websocket + admin api are basically all).

All my extensions to the editor (to make the in-browser work) are encapsulated in a single file. I also made some changes to the base Node-RED javascript file but I attempt to keep those to a minimum.

Also what I found useful was to have a Node-RED instance that acts as a source for the client code and then have a script that retrieves all javascript code for the client. For that I created a shell script that retrieves everything that is need for the client. This allows me to change the instance and then update my standalone-serverless Node-RED codebase automagically. This makes updating the Node-RED instance possible.

What does cause issues are config nodes and node-specific API calls. That's what sort of put me off creating a Python backend. Recently I was thinking of creating an Erlang backend which would take advantage of Erlangs in-built concurrency ... if only there would be 48 hours in a day!

I hope you keep at it, I would be interested in using it once it's all done :wink:

Interesting project. Always thought that a Python tool similar to Node-RED would be really useful. If only because Python trends to have more comprehensive (or at least more mature) data manipulation libraries.

Never really got on with that myself. But I've far too many years experience with the HTML. To me, HTML/CSS/JS should be the standard for UI's.

@gregorius - I'll have to take a look at what you did, I've gone through that exercise before of isolating the client, it is very fun. Another backburner idea is a browser app that can make games that live as a standalone html file, I'm sure there'll be some crossover with this project.

One thing I could never figure out is how that final red.js file is generated from source. I know there's browser packaging tools but I can't tell which one is used, although I'm not that deep into webdev to expect to know.

@TotallyInformation - I like the idea of data manipulation, I know numpy, pandas, and matplotlib are all the rage, unfortunately I have maybe only used 5% of what I'm sure they offer. There's definitely value in doing complex math in a flow structure, can you imagine seeing plots in the debug river! that would be amazing!

It just is! I just take it as is and have the script retrieve it fresh each time something changes in Node-RED, i.e., new nodes are installed with new html/js code to be included in the red.js

The Python tools for that are generally AirFlow combined with Jupyter - so there is no real point in re-inventing the wheel for ETL + Data manipulation. There is a whole bunch of other Python helpers in that sector.

An emphasis on visually creating web flows sites (for example) would be something new for the Python would - at least I've never heard of a visual tool for modelling the flow of web requests in Python. A kind of visual interface to Flask would be something new, just as Node-RED can be a visual interface for Express.

Or simply the IoT tool for Python for modelling data flows from many devices!

1 Like

Agreed. I've played with Jupyter notebooks a fair bit, but the idea of a Python-RED is certainly interesting. :smile:

A Python driven UIBUILDER would be interesting for sure. :smile: