FIX 旧分支保留heygem server 并修复

This commit is contained in:
kyj@bowong.ai 2025-07-30 11:11:15 +08:00
parent 651e3ec4c1
commit 8b3acd82b3
3 changed files with 17 additions and 21 deletions

View File

@ -1,4 +1,4 @@
import modal.cli.run
if __name__ == '__main__':
modal.cli.run.deploy(app_ref='.\\server_cluster\\app.py', name="server-bundle-deploy", tag="initialDeploy", env="main", use_module_mode=False)
modal.cli.run.deploy(app_ref='.\\server_cluster\\app.py', name="heygem-server", tag="initialDeploy", env="main", use_module_mode=False)

View File

@ -22,8 +22,7 @@ heygem_base_image = (
.run_commands("ln -s /usr/local/lib/python3.8/site-packages/nvidia/cuda_nvrtc/lib/libnvrtc.so.11.2 /usr/local/lib/python3.8/site-packages/nvidia/cuda_nvrtc/lib/libnvrtc.so")
.run_commands("python3.8 -m pip install https://github.com/pydata/numexpr/releases/download/v2.8.6/numexpr-2.8.6-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl")
.add_local_file("heygem.py", "/root/heygem.py", copy=True)
.add_local_file("../config/config.yaml", "/root/config.yaml", copy=True)
.pip_install("boto3").pip_install("PyYAML").pip_install("requests").workdir("/root").add_local_python_source("HeyGem_Base")
.pip_install("boto3").pip_install("requests").workdir("/root").add_local_python_source("HeyGem_Base")
)
heygem_base_app = modal.App(name="HeyGem-Base", image=heygem_base_image, include_source=False)
@ -43,12 +42,13 @@ with heygem_base_image.imports():
import httpx
import loguru
import requests
import starlette
from fastapi import Depends, HTTPException, status, UploadFile
from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
secret = modal.Secret.from_name("aws-s3-secret")
auth_scheme = HTTPBearer()
bucket_output = "bw-heygem-output"
bucket_output = "modal-media-cache"
@heygem_base_app.cls(
max_containers=25, # limit interactive session to 1 container
@ -66,13 +66,13 @@ bucket_output = "bw-heygem-output"
bucket_name=bucket_output,
# bucket_endpoint_url="https://s3.%s.amazonaws.com" % os.environ["AWS_REGION"],
secret=secret,
key_prefix="/"
key_prefix="/heygem/"
),
"/root/logs": modal.CloudBucketMount(
bucket_name=bucket_output,
# bucket_endpoint_url="https://s3.%s.amazonaws.com" % os.environ["AWS_REGION"],
secret=secret,
key_prefix="/logs/"
key_prefix="/heygem_logs/"
)
}, # mounts our cached models
)
@ -240,7 +240,7 @@ class HeyGemBase:
with open(path, 'wb') as f:
shutil.copyfileobj(r.raw, f)
@modal.fastapi_endpoint(method="POST")
@modal.fastapi_endpoint(method="POST", docs=True)
async def api(self, video_file: Optional[Union[UploadFile, str]], audio_file: Optional[Union[UploadFile, str]], token: HTTPAuthorizationCredentials = Depends(auth_scheme)):
if token.credentials != os.environ["AUTH_TOKEN"]:
raise HTTPException(
@ -250,7 +250,7 @@ class HeyGemBase:
)
code = str(uuid.uuid4())
try:
if isinstance(video_file, UploadFile):
if isinstance(video_file, starlette.datastructures.UploadFile):
video_path = "/root/%s" % video_file.filename
with open(video_path, "wb") as f:
data = await video_file.read()
@ -261,7 +261,7 @@ class HeyGemBase:
else:
return {"status": "fail", "msg": "video file save failed: Not a valid input"}
if isinstance(audio_file, UploadFile):
if isinstance(audio_file, starlette.datastructures.UploadFile):
audio_path = "/root/%s" % audio_file.filename
with open(audio_path, "wb") as f:
data = await audio_file.read()
@ -285,16 +285,12 @@ class HeyGemBase:
print("Try move file to S3 manually")
# S3 Fallback
import boto3
import yaml
with open("/root/config.yaml", encoding="utf-8",
mode="r+") as config:
yaml_config = yaml.load(config, Loader=yaml.FullLoader)
awss3 = boto3.resource('s3', aws_access_key_id=yaml_config["aws_key_id"],
aws_secret_access_key=yaml_config["aws_access_key"])
awss3 = boto3.resource('s3', aws_access_key_id=os.environ.get("AWS_ACCESS_KEY_ID"),
aws_secret_access_key=os.environ.get("AWS_SECRET_ACCESS_KEY"))
awss3.meta.client.upload_file(file_path, bucket_output, file_path.split(os.path.sep)[-1])
except:
return {"status": "fail", "msg": "Failed to move file to S3 manually: " + str(e)}
return {"status": "success", "msg":f"{file_path.split(os.path.sep)[-1]}"}
return {"status": "success", "url":f"https://cdn.roasmax.cn/heygem/{file_path.split(os.path.sep)[-1]}"}
except Exception as e:
traceback.print_exc()
return {"status": "fail", "msg": "Inference module failed: "+str(e)}

View File

@ -6,9 +6,9 @@ from ComfyUI_Auth_HeyGem.web.worker import comfyui_auth_heygem_app
from ComfyUI_Auth_LatentSync1_5.web.worker import comfyui_auth_latentsync_1_5_app
from HeyGem_Base.web.worker import heygem_base_app
app = modal.App(name="Server-Bundle")
app.include(comfyui_base_app)
app.include(comfyui_auth_app)
app.include(comfyui_auth_heygem_app)
app.include(comfyui_auth_latentsync_1_5_app)
app = modal.App(name="HeyGem-server")
# app.include(comfyui_base_app)
# app.include(comfyui_auth_app)
# app.include(comfyui_auth_heygem_app)
# app.include(comfyui_auth_latentsync_1_5_app)
app.include(heygem_base_app)