https://github.com/mcejp/graphexec
Execute litegraph.js graphs server-side
https://github.com/mcejp/graphexec
node-graph nodes
Last synced: 6 months ago
JSON representation
Execute litegraph.js graphs server-side
- Host: GitHub
- URL: https://github.com/mcejp/graphexec
- Owner: mcejp
- License: mit
- Created: 2022-02-23T17:09:52.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-03-26T12:48:39.000Z (almost 4 years ago)
- Last Synced: 2024-10-13T11:14:03.212Z (about 1 year ago)
- Topics: node-graph, nodes
- Language: Python
- Homepage:
- Size: 202 KB
- Stars: 25
- Watchers: 2
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# GraphExec
GraphExec is a tool for executing [litegraph.js](https://github.com/jagenjo/litegraph.js) graphs on a server, with node operations implemented as Python functions.
Slot types can be any Python types, including [NumPy](https://numpy.org/) arrays and custom, opaque classes.
It runs as a REST back-end for litegraph.js with some aftermarket modifications, or as a command-line tool. Generating JavaScript code for client-side _stub nodes_ (with slots, properties and widgets, but no business logic) is also possible, based on decorators added to the node implementation.
For each node, server-side code can return image results (including [Matplotlib](https://matplotlib.org/) figures).
The project is in an alpha development stage; for example, litegraph.js built-in nodes are not implemented, and there is no support for the REST back-end in the upstream library.

---
## Usage
With my_node_types.py:
```python
from graphexec import node_type
from .my_implementation import _perlin_noise
@node_type.define("my_package/perlin_noise", "Perlin noise")
@node_type.input("width", "number")
@node_type.input("height", "number")
@node_type.output("map", "numpy.ndarray")
def perlin_noise(width, height):
return dict(map=_perlin_noise(int(width), int(height)))
NODE_TYPES = [
perlin_noise,
]
```
graphexec-generate-js-module -o ../litegraph/src/nodes/my-package-generated.js my_node_types
env PYTHONPATH=. graphexec-server --wwwroot ../litegraph -m my_node_types
## Format check
black --diff **.py
## Type check
mypy graphexec