FIX 修复Comfy-cli问题
This commit is contained in:
parent
015cdc4ca9
commit
8ac18fb0fe
Binary file not shown.
|
|
@ -19,7 +19,13 @@ image = ( # build up a Modal Image to run ComfyUI, step by step
|
|||
.apt_install("gcc")
|
||||
.apt_install("libportaudio2")
|
||||
.pip_install("fastapi[standard]==0.115.4") # install web dependencies
|
||||
.pip_install("comfy-cli==1.3.5") # install comfy-cli
|
||||
.apt_install("software-properties-common")
|
||||
.apt_install("wget")
|
||||
.run_commands("add-apt-repository -y contrib")
|
||||
.run_commands("wget https://developer.download.nvidia.com/compute/cuda/repos/debian12/x86_64/cuda-keyring_1.1-1_all.deb&&dpkg -i cuda-keyring_1.1-1_all.deb")
|
||||
.apt_install("cuda-toolkit")
|
||||
.add_local_file("comfy_cli-0.0.0-py3-none-any.whl","/root/comfy_cli-0.0.0-py3-none-any.whl", copy=True)
|
||||
.pip_install("/root/comfy_cli-0.0.0-py3-none-any.whl") # install modified-comfy-cli
|
||||
.pip_install("cos-python-sdk-v5")
|
||||
.pip_install("sqlalchemy")
|
||||
.pip_install("ultralytics")
|
||||
|
|
@ -54,10 +60,10 @@ image = (
|
|||
.run_commands("comfy node install https://github.com/rgthree/rgthree-comfy")
|
||||
.run_commands("comfy node install https://github.com/cubiq/ComfyUI_essentials")
|
||||
.run_commands("comfy node install https://github.com/melMass/comfy_mtb")
|
||||
.run_commands("echo 3 && comfy node install https://e.coding.net/g-ldyi2063/dev/ComfyUI_SparkTTS.git")
|
||||
.run_commands("comfy node install https://e.coding.net/g-ldyi2063/dev/ComfyUI_SparkTTS.git")
|
||||
.run_commands("comfy node install https://e.coding.net/g-ldyi2063/dev/ComfyUI-CustomNode.git")
|
||||
.run_commands("echo 04111 && comfy node install https://e.coding.net/g-ldyi2063/dev/cosyvoice_comfyui.git")
|
||||
.run_commands("echo 4 && comfy node install https://e.coding.net/g-ldyi2063/dev/ComfyUI-LatentSync-Node.git")
|
||||
.run_commands("comfy node install https://e.coding.net/g-ldyi2063/dev/cosyvoice_comfyui.git")
|
||||
.run_commands("comfy node install https://e.coding.net/g-ldyi2063/dev/ComfyUI-LatentSync-Node.git")
|
||||
.run_commands(
|
||||
"mkdir -p /root/comfy/ComfyUI/models/ComfyUI-CustomNode/model && rm -rf /root/comfy/ComfyUI/custom_nodes/ComfyUI-CustomNode/model && ln -s /root/comfy/ComfyUI/models/ComfyUI-CustomNode/model /root/comfy/ComfyUI/custom_nodes/ComfyUI-CustomNode/model"
|
||||
).run_commands(
|
||||
|
|
@ -125,7 +131,7 @@ class ComfyUI:
|
|||
def launch_comfy_background(self):
|
||||
# starts the ComfyUI server in the background exactly once when the first input is received
|
||||
self.session_id = str(uuid.uuid4())
|
||||
cmd = "echo client_uuid: {}&&rm -rf /root/comfy/ComfyUI/user&&mkdir -p /root/comfy/ComfyUI/output_s3/logs/{}&&ln -s /root/comfy/ComfyUI/output_s3/logs/{} /root/comfy/ComfyUI/user && comfy launch --background".format(self.session_id,self.session_id, self.session_id)
|
||||
cmd = "echo client_uuid: {}&& mkdir -p /root/comfy/ComfyUI/output_s3/logs/{}/ &&comfy launch --background".format(self.session_id,self.session_id, self.session_id)
|
||||
subprocess.run(cmd, shell=True, check=True)
|
||||
|
||||
@modal.method()
|
||||
|
|
@ -161,15 +167,16 @@ class ComfyUI:
|
|||
with open(f"/root/{self.prompt_uuid}.json", "w", encoding="utf-8") as fi:
|
||||
fi.write(json.dumps(workflow, ensure_ascii=False))
|
||||
cmd = f"comfy run --workflow /root/{self.prompt_uuid}.json --wait --timeout 890 --verbose"
|
||||
subprocess.run(cmd, shell=True, check=True, timeout=895)
|
||||
|
||||
# looks up the name of the output image file based on the workflow
|
||||
file_prefix = [
|
||||
self.file_prefix = [
|
||||
node.get("inputs")
|
||||
for node in workflow.values()
|
||||
if node.get("class_type") == "VHS_VideoCombine"
|
||||
][0]["filename_prefix"]
|
||||
|
||||
subprocess.run(cmd, shell=True, check=True, timeout=895)
|
||||
|
||||
|
||||
# returns the image as bytes
|
||||
file_list = os.listdir(output_dir)
|
||||
# 获取按照文件时间创建排序的列表,默认是按时间升序
|
||||
|
|
@ -177,7 +184,7 @@ class ComfyUI:
|
|||
reverse=True)
|
||||
# print("file_list", new_file_list)
|
||||
for f in new_file_list:
|
||||
if f.startswith(file_prefix):
|
||||
if f.startswith(self.file_prefix):
|
||||
os.makedirs(os.path.dirname(os.path.join(output_dir.replace("output", "output_s3"), f)), exist_ok=True)
|
||||
try:
|
||||
shutil.copy(os.path.join(output_dir, f), os.path.join(output_dir.replace("output", "output_s3"), f))
|
||||
|
|
@ -225,6 +232,19 @@ class ComfyUI:
|
|||
subprocess.run(cmd, shell=True, check=True)
|
||||
except:
|
||||
pass
|
||||
print("Summary Logs")
|
||||
try:
|
||||
with open("/root/comfy/ComfyUI/user/comfyui.log", "r", encoding="utf-8") as f:
|
||||
log_text = f"\n-----------{self.file_prefix}------------\n"+f.read()+"\n"
|
||||
if os.path.exists(f"/root/comfy/ComfyUI/output_s3/logs/{self.session_id}/full.txt"):
|
||||
with open(f"/root/comfy/ComfyUI/output_s3/logs/{self.session_id}/full.txt", "r", encoding="utf-8") as f:
|
||||
log_text = f.read() + log_text
|
||||
with open(f"/root/comfy/ComfyUI/output_s3/logs/{self.session_id}/full.txt", "w", encoding="utf-8") as f:
|
||||
f.write(log_text)
|
||||
if os.path.exists(f"/root/comfy/ComfyUI/user/ffmpeg.txt"):
|
||||
shutil.copy("/root/comfy/ComfyUI/user/ffmpeg.txt", f"/root/comfy/ComfyUI/output_s3/logs/{self.session_id}/ffmpeg.txt")
|
||||
except Exception as e:
|
||||
print(f"Summary Logs Failed: {e}")
|
||||
cmd = "comfy launch --background"
|
||||
try:
|
||||
subprocess.run(cmd, shell=True, check=True)
|
||||
|
|
|
|||
|
|
@ -21,7 +21,13 @@ image = ( # build up a Modal Image to run ComfyUI, step by step
|
|||
.apt_install("gcc")
|
||||
.apt_install("libportaudio2")
|
||||
.pip_install("fastapi[standard]==0.115.4") # install web dependencies
|
||||
.pip_install("comfy-cli==1.3.5") # install comfy-cli
|
||||
.apt_install("software-properties-common")
|
||||
.apt_install("wget")
|
||||
.run_commands("add-apt-repository -y contrib")
|
||||
.run_commands("wget https://developer.download.nvidia.com/compute/cuda/repos/debian12/x86_64/cuda-keyring_1.1-1_all.deb&&dpkg -i cuda-keyring_1.1-1_all.deb")
|
||||
.apt_install("cuda-toolkit")
|
||||
.add_local_file("comfy_cli-0.0.0-py3-none-any.whl","/root/comfy_cli-0.0.0-py3-none-any.whl", copy=True)
|
||||
.pip_install("/root/comfy_cli-0.0.0-py3-none-any.whl") # install modified-comfy-cli
|
||||
.pip_install("cos-python-sdk-v5")
|
||||
.pip_install("sqlalchemy")
|
||||
.pip_install("ultralytics")
|
||||
|
|
@ -127,7 +133,7 @@ class ComfyUI:
|
|||
def launch_comfy_background(self):
|
||||
# starts the ComfyUI server in the background exactly once when the first input is received
|
||||
self.session_id = str(uuid.uuid4())
|
||||
cmd = "echo client_uuid: {}&&rm -rf /root/comfy/ComfyUI/user&&mkdir -p /root/comfy/ComfyUI/output_s3/logs/{}&&ln -s /root/comfy/ComfyUI/output_s3/logs/{} /root/comfy/ComfyUI/user && comfy launch --background".format(self.session_id,self.session_id, self.session_id)
|
||||
cmd = "echo client_uuid: {}&& mkdir -p /root/comfy/ComfyUI/output_s3/logs/{}/ &&comfy launch --background".format(self.session_id,self.session_id, self.session_id)
|
||||
subprocess.run(cmd, shell=True, check=True)
|
||||
|
||||
@modal.method()
|
||||
|
|
@ -163,15 +169,16 @@ class ComfyUI:
|
|||
with open(f"/root/{self.prompt_uuid}.json", "w", encoding="utf-8") as fi:
|
||||
fi.write(json.dumps(workflow, ensure_ascii=False))
|
||||
cmd = f"comfy run --workflow /root/{self.prompt_uuid}.json --wait --timeout 890 --verbose"
|
||||
subprocess.run(cmd, shell=True, check=True, timeout=895)
|
||||
|
||||
# looks up the name of the output image file based on the workflow
|
||||
file_prefix = [
|
||||
self.file_prefix = [
|
||||
node.get("inputs")
|
||||
for node in workflow.values()
|
||||
if node.get("class_type") == "VHS_VideoCombine"
|
||||
][0]["filename_prefix"]
|
||||
|
||||
subprocess.run(cmd, shell=True, check=True, timeout=895)
|
||||
|
||||
# returns the image as bytes
|
||||
file_list = os.listdir(output_dir)
|
||||
# 获取按照文件时间创建排序的列表,默认是按时间升序
|
||||
|
|
@ -179,7 +186,7 @@ class ComfyUI:
|
|||
reverse=True)
|
||||
# print("file_list", new_file_list)
|
||||
for f in new_file_list:
|
||||
if f.startswith(file_prefix):
|
||||
if f.startswith(self.file_prefix):
|
||||
os.makedirs(os.path.dirname(os.path.join(output_dir.replace("output", "output_s3"), f)), exist_ok=True)
|
||||
try:
|
||||
shutil.copy(os.path.join(output_dir, f), os.path.join(output_dir.replace("output", "output_s3"), f))
|
||||
|
|
@ -229,14 +236,18 @@ class ComfyUI:
|
|||
except:
|
||||
pass
|
||||
print("Summary Logs")
|
||||
logs = glob.glob("/root/comfy/ComfyUI/user/*.log")
|
||||
log_text = ""
|
||||
for l in logs:
|
||||
if l.endswith("log"):
|
||||
with open(l, "r", encoding="utf-8") as f:
|
||||
log_text += f.read()+"\n-----------------------\n"
|
||||
with open(f"/root/comfy/ComfyUI/output_s3/logs/{self.session_id}/full.txt", "w", encoding="utf-8") as f:
|
||||
f.write(log_text)
|
||||
try:
|
||||
with open("/root/comfy/ComfyUI/user/comfyui.log", "r", encoding="utf-8") as f:
|
||||
log_text = f"\n-----------{self.file_prefix}------------\n"+f.read()+"\n"
|
||||
if os.path.exists(f"/root/comfy/ComfyUI/output_s3/logs/{self.session_id}/full.txt"):
|
||||
with open(f"/root/comfy/ComfyUI/output_s3/logs/{self.session_id}/full.txt", "r", encoding="utf-8") as f:
|
||||
log_text = f.read() + log_text
|
||||
with open(f"/root/comfy/ComfyUI/output_s3/logs/{self.session_id}/full.txt", "w", encoding="utf-8") as f:
|
||||
f.write(log_text)
|
||||
if os.path.exists(f"/root/comfy/ComfyUI/user/ffmpeg.txt"):
|
||||
shutil.copy("/root/comfy/ComfyUI/user/ffmpeg.txt", f"/root/comfy/ComfyUI/output_s3/logs/{self.session_id}/ffmpeg.txt")
|
||||
except Exception as e:
|
||||
print(f"Summary Logs Failed: {e}")
|
||||
cmd = "comfy launch --background"
|
||||
try:
|
||||
subprocess.run(cmd, shell=True, check=True)
|
||||
|
|
|
|||
Loading…
Reference in New Issue