Fixed /api/nodes functionality.
This commit is contained in:
parent
cffad033fa
commit
9216cbfcc5
@ -2,6 +2,7 @@ from flask import Flask, send_from_directory, jsonify, request, abort
|
|||||||
import os
|
import os
|
||||||
import importlib
|
import importlib
|
||||||
import inspect
|
import inspect
|
||||||
|
from OdenGraphQt import BaseNode
|
||||||
|
|
||||||
# Determine the absolute path for the React build folder
|
# Determine the absolute path for the React build folder
|
||||||
build_folder = os.path.join(os.getcwd(), "web-interface", "build")
|
build_folder = os.path.join(os.getcwd(), "web-interface", "build")
|
||||||
@ -20,10 +21,6 @@ workflow_data = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def import_nodes_from_folder(package_name):
|
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 = {}
|
nodes_by_category = {}
|
||||||
package = importlib.import_module(package_name)
|
package = importlib.import_module(package_name)
|
||||||
package_path = package.__path__[0]
|
package_path = package.__path__[0]
|
||||||
@ -39,7 +36,9 @@ def import_nodes_from_folder(package_name):
|
|||||||
try:
|
try:
|
||||||
module = importlib.import_module(module_name)
|
module = importlib.import_module(module_name)
|
||||||
for name, obj in inspect.getmembers(module, inspect.isclass):
|
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:
|
if category_name not in nodes_by_category:
|
||||||
nodes_by_category[category_name] = []
|
nodes_by_category[category_name] = []
|
||||||
nodes_by_category[category_name].append(obj.NODE_NAME)
|
nodes_by_category[category_name].append(obj.NODE_NAME)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user