support more example folders (#7836)
* support more example folders * add warning message
This commit is contained in:
parent
45503f6499
commit
5c5457a4ef
@ -93,16 +93,20 @@ class CustomNodeManager:
|
|||||||
|
|
||||||
def add_routes(self, routes, webapp, loadedModules):
|
def add_routes(self, routes, webapp, loadedModules):
|
||||||
|
|
||||||
|
example_workflow_folder_names = ["example_workflows", "example", "examples", "workflow", "workflows"]
|
||||||
|
|
||||||
@routes.get("/workflow_templates")
|
@routes.get("/workflow_templates")
|
||||||
async def get_workflow_templates(request):
|
async def get_workflow_templates(request):
|
||||||
"""Returns a web response that contains the map of custom_nodes names and their associated workflow templates. The ones without templates are omitted."""
|
"""Returns a web response that contains the map of custom_nodes names and their associated workflow templates. The ones without templates are omitted."""
|
||||||
files = [
|
|
||||||
file
|
files = []
|
||||||
for folder in folder_paths.get_folder_paths("custom_nodes")
|
|
||||||
for file in glob.glob(
|
for folder in folder_paths.get_folder_paths("custom_nodes"):
|
||||||
os.path.join(folder, "*/example_workflows/*.json")
|
for folder_name in example_workflow_folder_names:
|
||||||
)
|
pattern = os.path.join(folder, f"*/{folder_name}/*.json")
|
||||||
]
|
matched_files = glob.glob(pattern)
|
||||||
|
files.extend(matched_files)
|
||||||
|
|
||||||
workflow_templates_dict = (
|
workflow_templates_dict = (
|
||||||
{}
|
{}
|
||||||
) # custom_nodes folder name -> example workflow names
|
) # custom_nodes folder name -> example workflow names
|
||||||
@ -118,8 +122,15 @@ class CustomNodeManager:
|
|||||||
|
|
||||||
# Serve workflow templates from custom nodes.
|
# Serve workflow templates from custom nodes.
|
||||||
for module_name, module_dir in loadedModules:
|
for module_name, module_dir in loadedModules:
|
||||||
workflows_dir = os.path.join(module_dir, "example_workflows")
|
for folder_name in example_workflow_folder_names:
|
||||||
|
workflows_dir = os.path.join(module_dir, folder_name)
|
||||||
|
|
||||||
if os.path.exists(workflows_dir):
|
if os.path.exists(workflows_dir):
|
||||||
|
if folder_name != "example_workflows":
|
||||||
|
logging.warning(
|
||||||
|
"WARNING: Found example workflow folder '%s' for custom node '%s', consider renaming it to 'example_workflows'",
|
||||||
|
folder_name, module_name)
|
||||||
|
|
||||||
webapp.add_routes(
|
webapp.add_routes(
|
||||||
[
|
[
|
||||||
web.static(
|
web.static(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user