Open JNmpi opened 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
ironflow
(instead of ironflow.ironflow
) and can be imported alongside GUI
.py
files so power users can boot up their own set of custom nodes easily, maybe like from ironflow import GUI; gui = GUI('my_session', node_files=['fenics.py', '../../tools/matdig.py'])
Low priority
Thanks @liamhuber for your thoughts and the new version which I like very much. A few thoughts and issues:
gui.register_user_node works for me only for a single node. If I try to add a second node I does not work (the second node is not shown in the list of available nodes in the gui). The second option you provide in the notebook
gui2 = GUI("example_with_custom_node", extra_nodes_packages=[[My_Node, My_Node2]]
works nicely with two nodes.
To create new nodes it would be nice to show the code of existing nodes in the gui. For example, the box where the input and Global_ID are shown could also show a button which on a click shows the code of the corresponding node in the output window (right). This could be achieved e.g. by the following code snippet:
node =gui.nodes_dictionary['built_in']['val'] import inspect print (inspect.getsource(node))
A few suggestions for existing and future nodes:
The bulkstructure node does not need a project input. We could simply set internally pr = Project('.')
It would be nice to have a calc_MD node. For this we probably need an additional input for the Lammps node (calculator). Since the calc_MD node should be generic it would be also a good best practice example of how to implement generic nodes.
@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.