refactor: 优化代码结构,合并参数设置,提升可读性
This commit is contained in:
parent
c2fe3585d5
commit
2556191eee
|
|
@ -3,31 +3,22 @@ from dotenv import dotenv_values
|
||||||
from workflow_service.main import web_app
|
from workflow_service.main import web_app
|
||||||
|
|
||||||
fastapi_image = (
|
fastapi_image = (
|
||||||
modal.Image
|
modal.Image.debian_slim(python_version="3.11")
|
||||||
.debian_slim(python_version="3.11")
|
|
||||||
.pip_install_from_requirements("./workflow_service/requirements.txt")
|
.pip_install_from_requirements("./workflow_service/requirements.txt")
|
||||||
.env(dotenv_values(".env"))
|
.env(dotenv_values(".env"))
|
||||||
.add_local_python_source("workflow_service")
|
.add_local_python_source("workflow_service")
|
||||||
)
|
)
|
||||||
|
|
||||||
app = modal.App(image=fastapi_image, name="waas-demo")
|
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")
|
secret = modal.Secret.from_name("aws-s3-secret", environment_name="dev")
|
||||||
|
|
||||||
with fastapi_image.imports():
|
with fastapi_image.imports():
|
||||||
|
|
||||||
@app.function(
|
@app.function(
|
||||||
cpu=(0.125, 8),
|
cpu=(0.125, 8), memory=(128, 4096), scaledown_window=1200, volumes={"/db": vol}
|
||||||
memory=(128, 4096),
|
|
||||||
scaledown_window=1200,
|
|
||||||
volumes={
|
|
||||||
"/db": vol,
|
|
||||||
"/waas": modal.CloudBucketMount(
|
|
||||||
bucket_name="modal-media-cache",
|
|
||||||
secret=secret,
|
|
||||||
key_prefix="waas/"
|
|
||||||
),
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
@modal.concurrent(max_inputs=100)
|
@modal.concurrent(max_inputs=100)
|
||||||
@modal.asgi_app()
|
@modal.asgi_app()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue