Skip to content
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

Remove 'clean' param from graphToPrompt #2665

Merged
merged 1 commit into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/scripts/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1227,9 +1227,8 @@ export class ComfyApp {
return graph.serialize({ sortNodes })
}

async graphToPrompt(graph = this.graph, clean = true) {
async graphToPrompt(graph = this.graph) {
return graphToPrompt(graph, {
clean,
sortNodes: useSettingStore().get('Comfy.Workflow.SortNodeIdOnSave')
})
}
Expand Down
22 changes: 10 additions & 12 deletions src/utils/executionUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import type { ComfyApiWorkflow, ComfyWorkflowJSON } from '@/types/comfyWorkflow'
*/
export const graphToPrompt = async (
graph: LGraph,
options: { clean?: boolean; sortNodes?: boolean } = {}
options: { sortNodes?: boolean } = {}
): Promise<{ workflow: ComfyWorkflowJSON; output: ComfyApiWorkflow }> => {
const { clean = true, sortNodes = false } = options
const { sortNodes = false } = options

for (const outerNode of graph.computeExecutionOrder(false)) {
if (outerNode.widgets) {
Expand Down Expand Up @@ -165,16 +165,14 @@ export const graphToPrompt = async (
}

// Remove inputs connected to removed nodes
if (clean) {
for (const o in output) {
for (const i in output[o].inputs) {
if (
Array.isArray(output[o].inputs[i]) &&
output[o].inputs[i].length === 2 &&
!output[output[o].inputs[i][0]]
) {
delete output[o].inputs[i]
}
for (const o in output) {
for (const i in output[o].inputs) {
if (
Array.isArray(output[o].inputs[i]) &&
output[o].inputs[i].length === 2 &&
!output[output[o].inputs[i][0]]
) {
delete output[o].inputs[i]
}
}
}
Expand Down