fix bug on import workflow

This commit is contained in:
numz
2024-10-14 13:34:58 +02:00
parent fece12895f
commit a33bbe326b
2 changed files with 19 additions and 3 deletions
+2 -1
View File
@@ -55,7 +55,8 @@ async def workflow(request):
else:
file_name = json_path[-1]
json_path = folder_paths.user_directory + "/" + user + "/workflows/api/" + file_name
shutil.copy(original_path, json_path)
if os.path.exists(original_path):
shutil.copy(original_path, json_path)
if os.path.exists(json_path):
with open(json_path, "r", encoding="utf-8") as f:
json_content = json.load(f)
+17 -2
View File
@@ -583,7 +583,16 @@ app.registerExtension({
//console.log('Workflow:', workflow);
if (data.error == "none"){
const combo = this.widgets.find(w => w.name === "workflows");
combo.options.values.push(data.file_name);
if(combo.options.values.includes("No file in worflows/api folder")){
//remove a values from combo.options.values
const index = combo.options.values.indexOf("No file in worflows/api folder");
if (index > -1) {
combo.options.values.splice(index, 1);
}
}
if (!combo.options.values.includes(data.file_name)){
combo.options.values.push(data.file_name);
}
const nodes_input = Object.fromEntries(
Object.entries(workflow).filter(([k, v]) => v.class_type == "WorkflowInput")
);
@@ -591,7 +600,13 @@ app.registerExtension({
const nodes_output = Object.fromEntries(
Object.entries(workflow).filter(([k, v]) => v.class_type == "WorkflowOutput")
);
//remove a values from app.lipsync_studio
if (data.file_name in app.lipsync_studio){
delete app.lipsync_studio[data.file_name];
}
if ("No file in worflows/api folder" in app.lipsync_studio){
delete app.lipsync_studio["No file in worflows/api folder"];
}
app.lipsync_studio[data.file_name] = {inputs: nodes_input, outputs: nodes_output};
combo.value = data.file_name;
importWorkflow(this, data.file_name, app)