Fixed /api/nodes functionality.

This commit is contained in:
Nicole Rappe 2025-03-20 03:08:10 -06:00
parent cffad033fa
commit 9216cbfcc5

View File

@ -2,6 +2,7 @@ from flask import Flask, send_from_directory, jsonify, request, abort
import os
import importlib
import inspect
from OdenGraphQt import BaseNode
# Determine the absolute path for the React build folder
build_folder = os.path.join(os.getcwd(), "web-interface", "build")
@ -20,10 +21,6 @@ workflow_data = {
}
def import_nodes_from_folder(package_name):
"""
Recursively import all modules from the given package.
Returns a dictionary where keys are subfolder names, and values are lists of node names.
"""
nodes_by_category = {}
package = importlib.import_module(package_name)
package_path = package.__path__[0]
@ -39,7 +36,9 @@ def import_nodes_from_folder(package_name):
try:
module = importlib.import_module(module_name)
for name, obj in inspect.getmembers(module, inspect.isclass):
if hasattr(obj, "NODE_NAME"):
# Filter out only actual node classes you define:
if (issubclass(obj, BaseNode)
and obj.__module__ == module.__name__):
if category_name not in nodes_by_category:
nodes_by_category[category_name] = []
nodes_by_category[category_name].append(obj.NODE_NAME)