-
Notifications
You must be signed in to change notification settings - Fork 6.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
serve workflow templates from custom_nodes #6193
Changes from 2 commits
b6e3bc2
547eb21
fc14655
e10cbad
f04ad04
f66d5cf
1ea319e
c1f588a
1f583d2
63dbf0c
86cbe13
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -250,6 +250,16 @@ async def get_extensions(request): | |
name) + "/" + os.path.relpath(f, dir).replace("\\", "/"), files))) | ||
|
||
return web.json_response(extensions) | ||
|
||
@routes.get("/workflow_templates") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We do have a plan to eventually move ComfyUI-Manager's custom node management features to core. Can we move this endpoint to a separate file |
||
async def get_workflow_templates(request): | ||
files = glob.glob(os.path.join(folder_paths.custom_nodes_directory, '*/example_workflows/*.json')) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you can just call |
||
workflow_templates_dict = {} # custom_nodes folder name -> example workflow names | ||
for file in files: | ||
custom_nodes_name = os.path.basename(os.path.dirname(os.path.dirname(file))) | ||
workflow_name = os.path.splitext(os.path.basename(file))[0] | ||
workflow_templates_dict.setdefault(custom_nodes_name, []).append(workflow_name) | ||
return web.json_response(workflow_templates_dict) | ||
|
||
def get_dir_by_type(dir_type): | ||
if dir_type is None: | ||
|
@@ -713,6 +723,13 @@ def add_routes(self): | |
self.app.add_routes(api_routes) | ||
self.app.add_routes(self.routes) | ||
|
||
# Add routes for workflow templates in custom nodes. | ||
for module_name, module_dir in nodes.LOADED_MODULE_DIRS.items(): | ||
workflows_dir = os.path.join(module_dir, 'example_workflows') | ||
if os.path.exists(workflows_dir): | ||
self.app.add_routes([web.static('/workflow_templates/' + module_name, workflows_dir)]) | ||
|
||
# Add routes from web extensions. | ||
for name, dir in nodes.EXTENSION_WEB_DIRS.items(): | ||
self.app.add_routes([web.static('/extensions/' + name, dir)]) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I don't think these changes are related to this PR although they seem to be good.
Let's revert them for now so that we are sure that this PR does not break anything related.