-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserve.py
More file actions
38 lines (28 loc) · 999 Bytes
/
serve.py
File metadata and controls
38 lines (28 loc) · 999 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python3
"""Run the HARRIER FastAPI service.
HARRIER_WEIGHTS=/path/to/best.pt HARRIER_BACKEND=cuda \\
python scripts/serve.py --host 0.0.0.0 --port 8010
"""
from __future__ import annotations
import argparse
import sys
from pathlib import Path
_REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(_REPO_ROOT / "src"))
def main(argv: list[str] | None = None) -> int: # pragma: no cover - runtime only
parser = argparse.ArgumentParser(prog="anima-harrier-serve")
parser.add_argument("--host", default="0.0.0.0")
parser.add_argument("--port", type=int, default=8010)
parser.add_argument("--workers", type=int, default=1)
args = parser.parse_args(argv)
import uvicorn # type: ignore
uvicorn.run(
"anima_harrier.serving.app:build_app",
host=args.host,
port=args.port,
workers=args.workers,
factory=True,
)
return 0
if __name__ == "__main__":
raise SystemExit(main())