pyiron / ironflow

Prototype of a graphical user interface for pyiron (unstable)
https://mybinder.org/v2/gh/pyiron/ironflow/HEAD?labpath=example.ipynb
BSD 3-Clause "New" or "Revised" License
19 stars 2 forks source link

Node editor #82

Open JNmpi opened 2 years ago

JNmpi commented 2 years ago

@liamhuber, I really like the latest changes and developments in the look and feel of ironflow. It is fun working with it. Also, the possibility to start my binder sessions also for subbranches is super useful and highly appreciated. A feature I am missing quite a bit to productively working with ironflow is a node editor, i.e. to quickly create and store user specific nodes. It would be great if we could add to the gui a basic node editor that allows to program and add nodes without having to leave ironflow.

liamhuber commented 2 years ago

Glad to hear it!

I've been thinking a bit about the node editor too. I actual refactored out the entire sub-widget for looking at the graph (#72) in anticipation of putting the whole thing in a tab and having other tabs for, e.g., node editing.

Looking towards ironflow being a sort of self-contained gui via Voila (or similar), I think for power users we will effectively want to embed and entire jupyter notebook inside the gui, sharing the same scope, and having all of jupyter's nice bells and whistles like tab completion. I haven't looked into this at all yet though, so it might be trivially easy to do this sort of embedding, or it might be hell.

I can also imagine a gui node editor that holds your hand a lot more, with buttons for adding input and output, e.g. guiding you through possible datatypes for the IO with dropdown menus, etc. I can imagine a sort of "hardocore editor" tab for the embedded notebook, and a "friendly editor" tab for such a gui style.

Both of these are pretty low priority for me, since for now we still just use a single cell inside a notebook for the gui and have access to other cells. Then you can use tools from the ironflow library like this:

from ironflow.ironflow import GUI, Node, NodeInputBP, NodeOutputBP, dtypes

class My_Node(Node):
    title = "MyUserNode"
    init_inputs = [
        NodeInputBP(dtype=dtypes.Integer(default=1), label="foo")
    ]
    init_outputs = [
       NodeOutputBP(label="bar")
    ]
    color = 'cyan'

    def update_event(self, inp=-1):
        self.set_output_val(0, self.input(0) + 42)

gui.register_user_node(My_Node)

The new node shows up immediately in the nodes dropdown menu under user.

The other thing I wanted to do was make it so you could register multiple nodes at once directly from a .py file, e.g. by calling gui.register_user_node on every class in the file that is named *_Node.

At the end I would look at it like this...

High priority

Low priority

JNmpi commented 2 years ago

Thanks @liamhuber for your thoughts and the new version which I like very much. A few thoughts and issues:

works nicely with two nodes.

A few suggestions for existing and future nodes: