refactor: 优化代码结构,合并参数设置,提升可读性

This commit is contained in:
iHeyTang 2025-08-19 15:19:31 +08:00
parent c2fe3585d5
commit 2556191eee
1 changed files with 6 additions and 15 deletions

View File

@ -3,33 +3,24 @@ from dotenv import dotenv_values
from workflow_service.main import web_app
fastapi_image = (
modal.Image
.debian_slim(python_version="3.11")
modal.Image.debian_slim(python_version="3.11")
.pip_install_from_requirements("./workflow_service/requirements.txt")
.env(dotenv_values(".env"))
.add_local_python_source("workflow_service")
)
app = modal.App(image=fastapi_image, name="waas-demo")
vol = modal.Volume.from_name("comfy_model", environment_name="dev", create_if_missing=True)
vol = modal.Volume.from_name(
"comfy_model", environment_name="dev", create_if_missing=True
)
secret = modal.Secret.from_name("aws-s3-secret", environment_name="dev")
with fastapi_image.imports():
@app.function(
cpu=(0.125, 8),
memory=(128, 4096),
scaledown_window=1200,
volumes={
"/db": vol,
"/waas": modal.CloudBucketMount(
bucket_name="modal-media-cache",
secret=secret,
key_prefix="waas/"
),
}
cpu=(0.125, 8), memory=(128, 4096), scaledown_window=1200, volumes={"/db": vol}
)
@modal.concurrent(max_inputs=100)
@modal.asgi_app()
def fastapi_webapp():
return web_app
return web_app