-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
43 lines (32 loc) · 1.04 KB
/
run.py
File metadata and controls
43 lines (32 loc) · 1.04 KB
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
39
40
41
42
43
#!/usr/bin/env python3
# drift-detector/run.py
"""
Entry point for Drift Detector.
Server mode (default):
python run.py
# or with uvicorn directly:
uvicorn dd.app:app --host 0.0.0.0 --port 8899 --reload
CLI mode:
python run.py compare --spec api.yaml --host-a http://localhost:8000 --host-b http://localhost:8001
"""
import sys
import uvicorn
# CLI subcommands that delegate to dd.cli
CLI_COMMANDS = {"compare"}
def start_server():
"""Start the uvicorn server."""
from dd.config import DB_DRIVER, DB_PATH, HOST, HOST_A, HOST_B, PORT
print("Drift Detector starting...")
print(f" HOST_A: {HOST_A}")
print(f" HOST_B: {HOST_B}")
print(f" DB_DRIVER: {DB_DRIVER}")
print(f" DB_PATH: {DB_PATH}")
print(f" Listen: {HOST}:{PORT}")
uvicorn.run("dd.app:app", host=HOST, port=PORT, reload=True)
if __name__ == "__main__":
# Check if first arg is a CLI command
if len(sys.argv) > 1 and sys.argv[1] in CLI_COMMANDS:
from dd.cli import main
main()
else:
start_server()