-
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
serve workflow templates from custom_nodes #6193
Conversation
server.py
Outdated
@@ -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 comment
The 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 app/custom_node_manager.py
?
server.py
Outdated
|
||
@routes.get("/workflow_templates") | ||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can just call folder_paths.get_folder_paths("custom_nodes")
here instead of adding a new global variable in folder_paths
.
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.
LGTM with nit.
folder_paths.py
Outdated
temp_directory = os.path.join(os.path.dirname(os.path.realpath(__file__)), "temp") | ||
input_directory = os.path.join(os.path.dirname(os.path.realpath(__file__)), "input") | ||
user_directory = os.path.join(os.path.dirname(os.path.realpath(__file__)), "user") | ||
output_directory = os.path.join(base_path, "output") |
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.
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.
LGTM with nit.
Note: test failure is due to python 3.8, which is fixed in 160ca08 @bezo97 Can you rebase the PR? @comfyanonymous PTAL |
app/custom_node_manager.py
Outdated
@routes.get("/workflow_templates") | ||
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.""" | ||
files = glob.glob(os.path.join(folder_paths.get_folder_paths("custom_nodes")[0], '*/example_workflows/*.json')) |
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.
This only seems to take into account the first custom node path?
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.
Sorry didn't realize the logic that there could be more, fixed now
…m/bezo97/ComfyUI into feature/custom_workflow_templates
This PR prepares the following feature request: Comfy-Org/ComfyUI_frontend#1008
Related frontend PR: Comfy-Org/ComfyUI_frontend#2032
Implementation details:
@routes.get("/workflow_templates")
- This endpoint returns a map of custom_nodes names and their associated workflow template files. The ones without templates are omitted. Example:LOADED_MODULE_DIRS
where we keep track of all successfully loaded custom_nodes and their directories (even when there is no class mapping and web directory)custom_nodes/*/example_workflows/*
Question to reviewers:
/example_workflows
folders sufficient or shall we support existing folder structures of popular custom_node repos by allowing/examples
,/workflows
, etc.?