Merge branch 'main' into feature/examples-section

This commit is contained in:
Emmanuel Morales 2024-02-08 21:13:20 -06:00 committed by GitHub
commit 9834dc0b25
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 64 additions and 21 deletions

View File

@ -29,9 +29,7 @@ class ComfyUIDeployExternalText:
CATEGORY = "text"
def run(self, input_id, default_value=None):
if not input_id or len(input_id.strip()) == 0:
return [default_value]
return [input_id]
NODE_CLASS_MAPPINGS = {"ComfyUIDeployExternalText": ComfyUIDeployExternalText}

View File

@ -118,6 +118,8 @@ async def comfy_deploy_run(request):
"stack_trace": stack_trace
}
})
# When there are critical errors, the prompt is actually not run
await update_run(prompt_id, Status.FAILED)
return web.Response(status=500, reason=f"{error_type}: {e}, {stack_trace_short}")
status = 200
@ -358,6 +360,8 @@ async def send_json_override(self, event, data, sid=None):
if event == 'executing' and data.get('node') is not None:
node = data.get('node')
if 'prompt_id' in prompt_metadata:
if 'last_updated_node' in prompt_metadata[prompt_id] and prompt_metadata[prompt_id]['last_updated_node'] == node:
return
prompt_metadata[prompt_id]['last_updated_node'] = node
@ -511,7 +515,9 @@ async def upload_file(prompt_id, filename, subfolder=None, content_type="image/p
"Content-Length": str(len(data)),
}
response = requests.put(ok.get("url"), headers=headers, data=data)
print("upload file response", response.status_code)
async with aiohttp.ClientSession() as session:
async with session.put(ok.get("url"), headers=headers, data=data) as response:
print("upload file response", response.status)
def have_pending_upload(prompt_id):
if 'prompt_id' in prompt_metadata and 'uploading_nodes' in prompt_metadata[prompt_id] and len(prompt_metadata[prompt_id]['uploading_nodes']) > 0:

View File

@ -1,7 +1,7 @@
import { app } from "./app.js";
import { api } from "./api.js";
import { ComfyWidgets, LGraphNode } from "./widgets.js";
import { generateDependencyGraph } from "https://esm.sh/comfyui-json@0.1.8";
import { generateDependencyGraph } from "https://esm.sh/comfyui-json@0.1.14";
/** @typedef {import('../../../web/types/comfy.js').ComfyExtension} ComfyExtension*/
/** @type {ComfyExtension} */
@ -184,12 +184,28 @@ function createDynamicUIHtml(data) {
let html =
'<div style="max-width: 1024px; margin: 14px auto; display: flex; flex-direction: column; gap: 24px;">';
const bgcolor = "var(--comfy-input-bg)";
const evenBg = "var(--border-color)";
const textColor = "var(--input-text)";
// Custom Nodes
html += `<div style="background-color: ${bgcolor}; padding: 24px; border-radius: 8px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);">`;
html +=
'<h2 style="margin-top: 0px; font-size: 24px; font-weight: bold; margin-bottom: 16px;">Custom Nodes</h2>';
if (data.missing_nodes?.length > 0) {
html += `
<div style="border-bottom: 1px solid #e2e8f0; padding: 4px 12px; background-color: ${evenBg}">
<h3 style="font-size: 14px; font-weight: semibold; margin-bottom: 8px;">Missing Nodes</h3>
<p style="font-size: 12px;">These nodes are not found with any matching custom_nodes in the ComfyUI Manager Database</p>
${data.missing_nodes
.map((node) => {
return `<p style="font-size: 14px; color: #d69e2e;">${node}</p>`;
})
.join("")}
</div>
`;
}
Object.values(data.custom_nodes).forEach((node) => {
html += `
<div style="border-bottom: 1px solid #e2e8f0; padding-top: 16px;">
@ -227,6 +243,11 @@ function createDynamicUIHtml(data) {
});
html += "</div>";
// Models
html += `<div style="background-color: ${bgcolor}; padding: 24px; border-radius: 8px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);">`;
html +=
'<h2 style="margin-top: 0px; font-size: 24px; font-weight: bold; margin-bottom: 16px;">Files</h2>';
Object.entries(data.files).forEach(([section, items]) => {
html += `
<div style="border-bottom: 1px solid #e2e8f0; padding-top: 8px; padding-bottom: 8px;">
@ -341,10 +362,10 @@ function addButton() {
"Generating dependency graph",
"Please wait...",
);
deps = await generateDependencyGraph(
prompt.output,
snapshot,
async (file) => {
deps = await generateDependencyGraph({
workflow_api: prompt.output,
snapshot: snapshot,
computeFileHash: async (file) => {
console.log(file);
loadingDialog.showLoading("Generating hash", file);
const hash = await fetch(
@ -356,7 +377,7 @@ function addButton() {
console.log(hash);
return hash.file_hash;
},
async (file, hash, prevhash) => {
handleFileUpload: async (file, hash, prevhash) => {
console.log("Uploading ", file);
loadingDialog.showLoading("Uploading file", file);
try {
@ -383,8 +404,8 @@ function addButton() {
return undefined;
}
},
existing_workflow.dependencies,
);
existingDependencies: existing_workflow.dependencies,
});
loadingDialog.close();

View File

@ -29,6 +29,7 @@ export function Navbar() {
const { organization } = useOrganization();
const _isDesktop = useMediaQuery("(min-width: 1024px)");
const [isDesktop, setIsDesktop] = useState(true);
const [isSheetOpen, setSheetOpen] = useState(false);
useEffect(() => {
setIsDesktop(_isDesktop);
}, [_isDesktop]);
@ -36,7 +37,7 @@ export function Navbar() {
<>
<div className="flex flex-row items-center gap-4">
{!isDesktop && (
<Sheet>
<Sheet open={isSheetOpen} onOpenChange={(open) => setSheetOpen(open)}>
<SheetTrigger asChild>
<button className="flex items-center justify-center w-8 h-8 p-2">
<Menu />
@ -47,7 +48,10 @@ export function Navbar() {
<SheetTitle className="text-start">Comfy Deploy</SheetTitle>
</SheetHeader>
<div className="grid h-full grid-rows-[1fr_auto]">
<NavbarMenu className=" h-full" />
<NavbarMenu
className=" h-full"
closeSheet={() => setSheetOpen(false)}
/>
{/* <OrganizationSwitcher
appearance={{
elements: {

View File

@ -9,7 +9,13 @@ import { useRouter } from "next/navigation";
import { useEffect, useState } from "react";
import { useMediaQuery } from "usehooks-ts";
export function NavbarMenu({ className }: { className?: string; }) {
export function NavbarMenu({
className,
closeSheet,
}: {
className?: string;
closeSheet?: () => void;
}) {
const _isDesktop = useMediaQuery("(min-width: 1024px)");
const [isDesktop, setIsDesktop] = useState(true);
useEffect(() => {
@ -72,6 +78,9 @@ export function NavbarMenu({ className }: { className?: string; }) {
<Link
key={page.name}
href={page.path}
onClick={() => {
if (!!closeSheet) closeSheet();
}}
className="p-2 hover:bg-gray-100/20 hover:underline"
>
{page.name}

View File

@ -91,6 +91,11 @@ export const createRun = withServerPromise(
if (node.inputs["input_id"] === key) {
node.inputs["input_id"] = inputs[key];
}
// Fix for external text default value
if (node.class_type == "ComfyUIDeployExternalText") {
node.inputs["default_value"] = inputs[key];
}
});
}
}