PERF 去除上传配置文件

This commit is contained in:
kyj@bowong.ai 2025-05-19 11:57:26 +08:00
parent bb9ee2cd5d
commit b4029107a2
2 changed files with 32 additions and 26 deletions

View File

@ -11,8 +11,7 @@ comfyui_image = (
.run_commands("add-apt-repository -y contrib " .run_commands("add-apt-repository -y contrib "
"&& 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") "&& 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("git", "gcc", "libportaudio2", "cuda-toolkit", "ffmpeg") .apt_install("git", "gcc", "libportaudio2", "cuda-toolkit", "ffmpeg")
.add_local_file("../whl/comfy_cli-0.0.0-py3-none-any.whl", "/root/comfy_cli-0.0.0-py3-none-any.whl",copy=True) .pip_install("comfy_cli==0.0.0", index_url="https://packages-1747622887395:0ee15474ccd7b27b57ca63a9306327678e6c2631@g-ldyi2063-pypi.pkg.coding.net/dev/packages/simple")
.pip_install("/root/comfy_cli-0.0.0-py3-none-any.whl")
.run_commands("comfy --skip-prompt install --nvidia --version 0.3.10") .run_commands("comfy --skip-prompt install --nvidia --version 0.3.10")
.env(dotenv_values("../.runtime.env")) .env(dotenv_values("../.runtime.env"))
.workdir("/root/comfy") .workdir("/root/comfy")
@ -50,8 +49,6 @@ comfyui_image = (
).run_commands( ).run_commands(
"rm -rf /root/comfy/ComfyUI/models" "rm -rf /root/comfy/ComfyUI/models"
) )
.add_local_file("../config/config.yaml", "/root/comfy/ComfyUI/custom_nodes/ComfyUI-CustomNode/config.yaml",copy=True)
.add_local_file("../config/config.py","/root/comfy/ComfyUI/custom_nodes/cosyvoice_comfyui/pretrained_models/tools/config.py",copy=True)
.add_local_file("BowongModalFunctions/template/template_v1.json", "/root/src/BowongModalFunctions/template/template_v1.json", copy=True) .add_local_file("BowongModalFunctions/template/template_v1.json", "/root/src/BowongModalFunctions/template/template_v1.json", copy=True)
.add_local_python_source('BowongModalFunctions') .add_local_python_source('BowongModalFunctions')
.add_local_python_source('cluster') .add_local_python_source('cluster')
@ -90,6 +87,7 @@ with comfyui_image.imports():
config = WorkerConfig() config = WorkerConfig()
vol = modal.Volume.from_name("comfyui-model", create_if_missing=True, environment_name=config.modal_environment) vol = modal.Volume.from_name("comfyui-model", create_if_missing=True, environment_name=config.modal_environment)
secret = modal.Secret.from_name("aws-s3-secret", environment_name=config.modal_environment) secret = modal.Secret.from_name("aws-s3-secret", environment_name=config.modal_environment)
custom_secret = modal.Secret.from_name("comfyui-custom-secret", environment_name=config.modal_environment)
output_dir = "/root/comfy/ComfyUI/output" output_dir = "/root/comfy/ComfyUI/output"
sentry_sdk.init( sentry_sdk.init(
@ -124,7 +122,7 @@ with comfyui_image.imports():
cpu=(2, 64), cpu=(2, 64),
memory=(20480, 131072), memory=(20480, 131072),
enable_memory_snapshot=False, enable_memory_snapshot=False,
secrets=[secret], secrets=[secret, custom_secret],
volumes={ volumes={
"/root/comfy/ComfyUI/models": vol, "/root/comfy/ComfyUI/models": vol,
"/root/comfy/ComfyUI/input_s3": modal.CloudBucketMount( "/root/comfy/ComfyUI/input_s3": modal.CloudBucketMount(
@ -163,8 +161,7 @@ with comfyui_image.imports():
async def infer(workflow: Dict): async def infer(workflow: Dict):
self.poll_server_health() self.poll_server_health()
self.prompt_uuid = str(uuid.uuid4()) self.prompt_uuid = str(uuid.uuid4())
print("Workflow JSON:") loguru.logger.info(f"Workflow JSON: \n{json.dumps(workflow, indent=4, ensure_ascii=False)}")
print(json.dumps(workflow, indent=4, ensure_ascii=False))
for node in workflow.values(): for node in workflow.values():
if node.get("class_type") == "ComfyUIDeployExternalText": if node.get("class_type") == "ComfyUIDeployExternalText":
if node.get("inputs").get("input_id") == "file_path": if node.get("inputs").get("input_id") == "file_path":
@ -179,9 +176,12 @@ with comfyui_image.imports():
# S3 Fallback # S3 Fallback
import boto3 import boto3
import yaml import yaml
with open("/root/comfy/ComfyUI/custom_nodes/ComfyUI-CustomNode/config.yaml", if "aws_key_id" in list(os.environ.keys()):
encoding="utf-8", mode="r+") as myconfig: yaml_config = os.environ
yaml_config = yaml.load(myconfig, Loader=yaml.FullLoader) else:
with open("/root/comfy/ComfyUI/custom_nodes/ComfyUI-CustomNode/config.yaml",
encoding="utf-8", mode="r+") as myconfig:
yaml_config = yaml.load(myconfig, Loader=yaml.FullLoader)
awss3 = boto3.resource('s3', aws_access_key_id=yaml_config["aws_key_id"], awss3 = boto3.resource('s3', aws_access_key_id=yaml_config["aws_key_id"],
aws_secret_access_key=yaml_config["aws_access_key"]) aws_secret_access_key=yaml_config["aws_access_key"])
awss3.meta.client.download_file(config.S3_bucket_name, awss3.meta.client.download_file(config.S3_bucket_name,
@ -220,9 +220,12 @@ with comfyui_image.imports():
# S3 Fallback # S3 Fallback
import boto3 import boto3
import yaml import yaml
with open("/root/comfy/ComfyUI/custom_nodes/ComfyUI-CustomNode/config.yaml", if "aws_key_id" in list(os.environ.keys()):
encoding="utf-8", mode="r+") as myconfig: yaml_config = os.environ
yaml_config = yaml.load(myconfig, Loader=yaml.FullLoader) else:
with open("/root/comfy/ComfyUI/custom_nodes/ComfyUI-CustomNode/config.yaml",
encoding="utf-8", mode="r+") as myconfig:
yaml_config = yaml.load(myconfig, Loader=yaml.FullLoader)
awss3 = boto3.resource('s3', aws_access_key_id=yaml_config["aws_key_id"], awss3 = boto3.resource('s3', aws_access_key_id=yaml_config["aws_key_id"],
aws_secret_access_key=yaml_config["aws_access_key"]) aws_secret_access_key=yaml_config["aws_access_key"])
awss3.meta.client.upload_file(os.path.join(output_dir, f), config.S3_bucket_name, awss3.meta.client.upload_file(os.path.join(output_dir, f), config.S3_bucket_name,

View File

@ -11,8 +11,7 @@ comfyui_latentsync_1_5_image = (
.run_commands("add-apt-repository -y contrib " .run_commands("add-apt-repository -y contrib "
"&& 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") "&& 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("git", "gcc", "libportaudio2", "cuda-toolkit", "ffmpeg") .apt_install("git", "gcc", "libportaudio2", "cuda-toolkit", "ffmpeg")
.add_local_file("../whl/comfy_cli-0.0.0-py3-none-any.whl", "/root/comfy_cli-0.0.0-py3-none-any.whl", copy=True) .pip_install("comfy_cli==0.0.0", index_url="https://packages-1747622887395:0ee15474ccd7b27b57ca63a9306327678e6c2631@g-ldyi2063-pypi.pkg.coding.net/dev/packages/simple")
.pip_install("/root/comfy_cli-0.0.0-py3-none-any.whl")
.run_commands("comfy --skip-prompt install --nvidia --version 0.3.10") .run_commands("comfy --skip-prompt install --nvidia --version 0.3.10")
.env(dotenv_values("../.runtime.env")) .env(dotenv_values("../.runtime.env"))
.workdir("/root/comfy") .workdir("/root/comfy")
@ -50,8 +49,6 @@ comfyui_latentsync_1_5_image = (
).run_commands( ).run_commands(
"rm -rf /root/comfy/ComfyUI/models" "rm -rf /root/comfy/ComfyUI/models"
) )
.add_local_file("../config/config.yaml", "/root/comfy/ComfyUI/custom_nodes/ComfyUI-CustomNode/config.yaml", copy=True)
.add_local_file("../config/config.py", "/root/comfy/ComfyUI/custom_nodes/cosyvoice_comfyui/pretrained_models/tools/config.py", copy=True)
.add_local_file("BowongModalFunctions/template/template_v2.json", "/root/src/BowongModalFunctions/template/template_v2.json", copy=True) .add_local_file("BowongModalFunctions/template/template_v2.json", "/root/src/BowongModalFunctions/template/template_v2.json", copy=True)
.add_local_python_source('cluster') .add_local_python_source('cluster')
.add_local_python_source('BowongModalFunctions') .add_local_python_source('BowongModalFunctions')
@ -84,6 +81,7 @@ with comfyui_latentsync_1_5_image.imports():
config = WorkerConfig() config = WorkerConfig()
vol = modal.Volume.from_name("comfyui-model", create_if_missing=True, environment_name=config.modal_environment) vol = modal.Volume.from_name("comfyui-model", create_if_missing=True, environment_name=config.modal_environment)
secret = modal.Secret.from_name("aws-s3-secret", environment_name=config.modal_environment) secret = modal.Secret.from_name("aws-s3-secret", environment_name=config.modal_environment)
custom_secret = modal.Secret.from_name("comfyui-custom-secret", environment_name=config.modal_environment)
output_dir = "/root/comfy/ComfyUI/output" output_dir = "/root/comfy/ComfyUI/output"
sentry_sdk.init( sentry_sdk.init(
@ -116,7 +114,7 @@ with comfyui_latentsync_1_5_image.imports():
cpu=(2,64), cpu=(2,64),
memory=(20480,131072), memory=(20480,131072),
enable_memory_snapshot=False, enable_memory_snapshot=False,
secrets=[secret], secrets=[secret, custom_secret],
volumes={ volumes={
"/root/comfy/ComfyUI/models": vol, "/root/comfy/ComfyUI/models": vol,
"/root/comfy/ComfyUI/input_s3": modal.CloudBucketMount( "/root/comfy/ComfyUI/input_s3": modal.CloudBucketMount(
@ -154,8 +152,7 @@ with comfyui_latentsync_1_5_image.imports():
async def infer(workflow: Dict): async def infer(workflow: Dict):
self.poll_server_health() self.poll_server_health()
self.prompt_uuid = str(uuid.uuid4()) self.prompt_uuid = str(uuid.uuid4())
print("Workflow JSON:") loguru.logger.info(f"Workflow JSON: \n{json.dumps(workflow, indent=4, ensure_ascii=False)}")
print(json.dumps(workflow, indent=4, ensure_ascii=False))
for node in workflow.values(): for node in workflow.values():
if node.get("class_type") == "ComfyUIDeployExternalText": if node.get("class_type") == "ComfyUIDeployExternalText":
if node.get("inputs").get("input_id") == "file_path": if node.get("inputs").get("input_id") == "file_path":
@ -170,9 +167,12 @@ with comfyui_latentsync_1_5_image.imports():
# S3 Fallback # S3 Fallback
import boto3 import boto3
import yaml import yaml
with open("/root/comfy/ComfyUI/custom_nodes/ComfyUI-CustomNode/config.yaml", if "aws_key_id" in list(os.environ.keys()):
encoding="utf-8", mode="r+") as myconfig: yaml_config = os.environ
yaml_config = yaml.load(myconfig, Loader=yaml.FullLoader) else:
with open("/root/comfy/ComfyUI/custom_nodes/ComfyUI-CustomNode/config.yaml",
encoding="utf-8", mode="r+") as myconfig:
yaml_config = yaml.load(myconfig, Loader=yaml.FullLoader)
awss3 = boto3.resource('s3', aws_access_key_id=yaml_config["aws_key_id"], awss3 = boto3.resource('s3', aws_access_key_id=yaml_config["aws_key_id"],
aws_secret_access_key=yaml_config["aws_access_key"]) aws_secret_access_key=yaml_config["aws_access_key"])
awss3.meta.client.download_file(config.S3_bucket_name, awss3.meta.client.download_file(config.S3_bucket_name,
@ -212,9 +212,12 @@ with comfyui_latentsync_1_5_image.imports():
# S3 Fallback # S3 Fallback
import boto3 import boto3
import yaml import yaml
with open("/root/comfy/ComfyUI/custom_nodes/ComfyUI-CustomNode/config.yaml", if "aws_key_id" in list(os.environ.keys()):
encoding="utf-8", mode="r+") as myconfig: yaml_config = os.environ
yaml_config = yaml.load(myconfig, Loader=yaml.FullLoader) else:
with open("/root/comfy/ComfyUI/custom_nodes/ComfyUI-CustomNode/config.yaml",
encoding="utf-8", mode="r+") as myconfig:
yaml_config = yaml.load(myconfig, Loader=yaml.FullLoader)
awss3 = boto3.resource('s3', aws_access_key_id=yaml_config["aws_key_id"], awss3 = boto3.resource('s3', aws_access_key_id=yaml_config["aws_key_id"],
aws_secret_access_key=yaml_config["aws_access_key"]) aws_secret_access_key=yaml_config["aws_access_key"])
awss3.meta.client.upload_file(os.path.join(output_dir, f), config.S3_bucket_name, awss3.meta.client.upload_file(os.path.join(output_dir, f), config.S3_bucket_name,