-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
60 lines (44 loc) · 1.83 KB
/
Copy pathrun.py
File metadata and controls
60 lines (44 loc) · 1.83 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
"""데이터 품질 클리닉 실행기.
python run.py
브라우저에서 http://127.0.0.1:8000 을 열면 됩니다.
"""
from __future__ import annotations
import sys
import webbrowser
from threading import Timer
HOST = "127.0.0.1"
PORT = 8000
def _fix_console_encoding() -> None:
"""Windows 콘솔에서 한글이 깨지지 않게 출력 인코딩을 UTF-8 로 맞춘다."""
for stream in (sys.stdout, sys.stderr):
try:
stream.reconfigure(encoding="utf-8") # type: ignore[union-attr]
except (AttributeError, OSError):
pass # 인코딩을 못 바꿔도 프로그램은 돌아가야 한다
def main() -> int:
_fix_console_encoding()
try:
import uvicorn
except ImportError:
print("uvicorn 이 없습니다. 먼저 아래 명령을 실행해 주세요.")
print(" pip install -r requirements.txt")
return 1
from app import config
from app.samples import SAMPLES, path_of
missing = [s.title_ko for s in SAMPLES if not path_of(s).exists()]
if missing:
print("[알림] 샘플 데이터가 없습니다: " + ", ".join(missing))
print(" python -m app.fetch_samples 를 실행하면 내려받습니다.\n")
if config.llm_enabled():
print(f"[AI] OpenAI 처방 사용 가능 (모델: {config.openai_model()})")
else:
print("[AI] .env 에 OPEN_AI_API 키가 없어 규칙 기반으로만 동작합니다.")
url = f"http://{HOST}:{PORT}"
print(f"\n 데이터 품질 클리닉이 열렸습니다 -> {url}")
print(" 종료하려면 Ctrl+C 를 누르세요.\n")
if "--no-browser" not in sys.argv:
Timer(1.2, lambda: webbrowser.open(url)).start()
uvicorn.run("app.main:app", host=HOST, port=PORT, log_level="warning")
return 0
if __name__ == "__main__":
sys.exit(main())