feat: 新增代码
This commit is contained in:
48
video_worker/scripts/smoke_test.py
Normal file
48
video_worker/scripts/smoke_test.py
Normal file
@@ -0,0 +1,48 @@
|
||||
import json
|
||||
import sys
|
||||
import time
|
||||
|
||||
import requests
|
||||
|
||||
BASE_URL = sys.argv[1] if len(sys.argv) > 1 else "http://127.0.0.1:8000"
|
||||
|
||||
|
||||
def main() -> None:
|
||||
health = requests.get(f"{BASE_URL}/health", timeout=15)
|
||||
health.raise_for_status()
|
||||
print("[health]", json.dumps(health.json(), ensure_ascii=False))
|
||||
|
||||
payload = {
|
||||
"prompt": "a lonely man walking in a rainy neon street, cinematic, handheld camera",
|
||||
"negative_prompt": "blurry, deformed face, extra limbs, flicker",
|
||||
"quality_mode": "preview",
|
||||
"duration_sec": 1,
|
||||
"width": 320,
|
||||
"height": 240,
|
||||
"fps": 8,
|
||||
"steps": 8,
|
||||
"seed": 123456,
|
||||
}
|
||||
|
||||
created = requests.post(f"{BASE_URL}/generate", json=payload, timeout=30)
|
||||
created.raise_for_status()
|
||||
created_data = created.json()
|
||||
task_id = created_data["task_id"]
|
||||
print("[create]", json.dumps(created_data, ensure_ascii=False))
|
||||
|
||||
while True:
|
||||
status = requests.get(f"{BASE_URL}/tasks/{task_id}", timeout=15)
|
||||
status.raise_for_status()
|
||||
status_data = status.json()
|
||||
print("[status]", json.dumps(status_data, ensure_ascii=False))
|
||||
if status_data["status"] in {"SUCCEEDED", "FAILED"}:
|
||||
break
|
||||
time.sleep(2)
|
||||
|
||||
result = requests.get(f"{BASE_URL}/tasks/{task_id}/result", timeout=15)
|
||||
result.raise_for_status()
|
||||
print("[result]", json.dumps(result.json(), ensure_ascii=False, indent=2))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user