all_nodes is a visual programming node editor designed to be used in the most flexible way possible. It also aims to prevent re-duplication and re-writing of code inside of a project, as well as making debugging easier with its one-node-at-a-time approach to execution.
Install from PyPI with:
pip install all-nodes
And then run with
all-nodes
β
Drag and drop creation of nodes |
β Class search |
![]() |
![]() |
β Visual feedback of execution | β Execution in separate thread |
![]() |
![]() |
β Preview of images and other elements | β Attribute editor |
![]() |
![]() |
β Deactivation of nodes | β Annotations |
![]() |
![]() |
The places where all_nodes will search for node classes, scenes, etc is defined by the environment variable ALL_NODES_LIB_PATH
Example of organization of a folder, that contains two libraries
Folder structure | Classes representation | Scenes |
---|---|---|
![]() |
![]() |
![]() |
This folder has:
A *node_lib
named folder with node libraries, in this case 2 libraries: lib_1
and lib_2
. Inside each library we can have:
py
modules as needed styles.yml
file to define default styles for these modules (default colors, icons...)icons
folder for the classes contained in the modulesA *scene_lib
named folder with scenes saved in yaml format
Inside each module, nodes/classes can be defined as easy as this:
class GetEnvVariable(GeneralLogicNode):
NICE_NAME = "Get env variable"
HELP = "Get the value of an environment variable, with possibility of a fallback" \
"value if the variable is not defined"
INPUTS_DICT = {
"env_variable_name": {"type": str},
"fallback_value": {"type": str, "optional": True},
}
OUTPUTS_DICT = {"env_variable_value": {"type": str}}
def run(self):
import os
env_variable_name = self.get_attribute_value("env_variable_name")
fallback_value = self.get_attribute_value("fallback_value")
env_var_value = os.getenv(env_variable_name)
if env_var_value is None:
if fallback_value:
env_var_value = fallback_value
else:
self.fail(
"No environment variable '{}' found".format(env_variable_name)
)
return
self.set_output("env_variable_value", env_var_value)
Key elements that a node MUST have:
run
methodKey elements that a node CAN have:
NICE_NAME
attribute, for this node to be displayed more readableHELP
attribute to explain how the node worksINPUTS_DICT
dictionary, if the node needs inputsOUTPUTS_DICT
dictionary, if the node needs outputsINTERNALS_DICT
dictionary, if the node needs inputs/previews through GUIOther considerations:
import
statements are kept inside the run method, so no ImportError is met when editing nodes outside the software they are meant for.A context is a "node of nodes", or a node that contains a scene inside itself. To define it, just two ingredients are needed:
Once "inside" the context, its input attributes can be "grabbed" and its output attributes set by making use of the special ctx nodes:
Defining a scene is very easy, it is a simple and readable yaml file.
To look for scenes, all_nodes will:
Example of scene:
# SCENE environ_to_yaml
# ---------------------
# Description: Simple scene to write the environ out to a yaml file
# Nodes section: overall list of nodes to be created
nodes:
- EnvironToYmlCtx_1:
class_name: EnvironToYmlCtx
x_pos: -904
y_pos: -284
- StartFile_1:
class_name: StartFile
x_pos: -611
y_pos: -304
# Connections section: connections to be done between nodes
connections:
- EnvironToYmlCtx_1.yaml_filepath -> StartFile_1.file_path
# Scene created at: 2023-01-24 23:13:10.371378
# Created by: jaime.rvq
The scene just needs two keys:
Note how the ->
symbol is used to make the connections section more easily readable.
Any .yml scene file can be executed in batch mode without the need to open the graphic editor.
This can be done by launching the main file and making use of the -f
flag.
Example: main.py -f D:/scene_examples/my_scene.yml
Also, when a scene belongs to a repo/folder that has been defined in the ALL_NODES_LIB_PATH variable, it can be found just by its "alias". This alias is just the file name, with no need for the complete path or the ,yml extension.
Example: main.py -f environ_to_yaml
Finally, we can use the -s
argument to set all the attributes we want to change in the scene prior to running. This flag accepts as many arguments as we need. Here is an example setting one node's attribute prior to running:
Example: main.py -f environ_to_yaml -s OPEN_FILE.internal_bool true
In a scene, the execution starts from nodes that are recognized as "starting nodes". Those are nodes that:
In these example nodes, none of them have any incoming connections. Also, the only input attribute they all have is the START attribute, but since it is an optional attribute, the node can start executing even if it is not set.
Another example:
The node has a non-optional input. It is not connected, but a value has been defined to it, so the node can start executing.
When a start node is executed, and it is successful, the nodes connected to its outputs will try to execute as well. Have a look at this example:
What will happen is:
However, changing the scene a little bit, makes things more complex:
For simple setups and tests, node networks can be created and run at the same time in a python script.
π Example:
from all_nodes.logic.logic_scene import LogicScene
# Create a scene
logic_scene = LogicScene()
# Create a node and set one of its attributes
n_1 = logic_scene.add_node_by_name("GetEnvVariable")
n_1["env_variable_name"].set_value("USER")
# Create another node
n_2 = logic_scene.add_node_by_name("PrintToConsole")
# Connect the nodes
n_1["env_variable_value"].connect_to_other(n_2["in_object_0"])
# Run!
logic_scene.run_all_nodes()
Automatically generated once a month
(For personal use, they are not gathered from any other user)