Fix build error
Browse files- app.py +2 -2
- tests/test_render_api.py +15 -0
app.py
CHANGED
|
@@ -3,7 +3,7 @@ import json
|
|
| 3 |
import shutil
|
| 4 |
import socket
|
| 5 |
from pathlib import Path
|
| 6 |
-
from typing import Any, Dict, List, Optional
|
| 7 |
|
| 8 |
from fastapi.responses import FileResponse, HTMLResponse, JSONResponse
|
| 9 |
from fastapi.staticfiles import StaticFiles
|
|
@@ -122,7 +122,7 @@ def start_render_api(
|
|
| 122 |
voice_config: Dict[str, Any],
|
| 123 |
diffusion_steps: int = 32,
|
| 124 |
speed: float = 1.0,
|
| 125 |
-
):
|
| 126 |
job = pipeline.get_job(session_id)
|
| 127 |
if job.status == "running":
|
| 128 |
raise ValueError("A render is already active for this session")
|
|
|
|
| 3 |
import shutil
|
| 4 |
import socket
|
| 5 |
from pathlib import Path
|
| 6 |
+
from typing import Any, Dict, Generator, List, Optional
|
| 7 |
|
| 8 |
from fastapi.responses import FileResponse, HTMLResponse, JSONResponse
|
| 9 |
from fastapi.staticfiles import StaticFiles
|
|
|
|
| 122 |
voice_config: Dict[str, Any],
|
| 123 |
diffusion_steps: int = 32,
|
| 124 |
speed: float = 1.0,
|
| 125 |
+
) -> Generator[Dict[str, Any], None, None]:
|
| 126 |
job = pipeline.get_job(session_id)
|
| 127 |
if job.status == "running":
|
| 128 |
raise ValueError("A render is already active for this session")
|
tests/test_render_api.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import importlib
|
| 2 |
+
import sys
|
| 3 |
+
|
| 4 |
+
import gradio as gr
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
def test_start_render_api_registers_one_streamed_output() -> None:
|
| 8 |
+
sys.modules.pop("app", None)
|
| 9 |
+
module = importlib.import_module("app")
|
| 10 |
+
|
| 11 |
+
with gr.Blocks() as demo:
|
| 12 |
+
dependency = gr.api(module.start_render_api, api_name="start_render")
|
| 13 |
+
|
| 14 |
+
assert dependency.get("outputs")
|
| 15 |
+
assert len(dependency["outputs"]) == 1
|