Compare commits
2 Commits
323061df02
...
bf898d78be
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf898d78be | ||
|
|
73593adb5c |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -20,6 +20,7 @@ build/
|
||||
# Models / artifacts (downloaded HF caches, trained LGBM)
|
||||
backend/artifacts/
|
||||
backend/.cache/
|
||||
backend/data/
|
||||
.huggingface/
|
||||
|
||||
# Node
|
||||
|
||||
@@ -46,11 +46,27 @@ def reseed_symbols() -> dict:
|
||||
|
||||
호출 예 (Windows cmd):
|
||||
curl -X POST http://localhost:8000/api/refresh/seed/symbols
|
||||
|
||||
KRX 가 주말/장 마감 시간에 비정상 응답을 줄 때도 SEED 10 종목은 항상 보장하므로
|
||||
엔드포인트는 200 을 돌려준다. 부분 성공 정보는 응답 body 에 담아 사용자가 판단.
|
||||
"""
|
||||
report = seed_symbols()
|
||||
return {
|
||||
"inserted": report.inserted,
|
||||
"updated": report.updated,
|
||||
"seed_marked": report.seed_marked,
|
||||
"markets": report.markets,
|
||||
}
|
||||
try:
|
||||
report = seed_symbols()
|
||||
return {
|
||||
"ok": True,
|
||||
"inserted": report.inserted,
|
||||
"updated": report.updated,
|
||||
"seed_marked": report.seed_marked,
|
||||
"markets": report.markets,
|
||||
}
|
||||
except Exception as e: # noqa: BLE001
|
||||
# seed_symbols 내부에서 다 잡지만, 만에 하나 외부로 새는 예외 (logger 포매터
|
||||
# 자체 버그 등) 도 200 으로 흡수해서 SEED 10 만이라도 살리는 게 UX 목표.
|
||||
return {
|
||||
"ok": False,
|
||||
"inserted": 0,
|
||||
"updated": 0,
|
||||
"seed_marked": 0,
|
||||
"markets": {},
|
||||
"error": repr(e)[:300],
|
||||
}
|
||||
|
||||
@@ -78,8 +78,11 @@ def seed_symbols() -> SeedReport:
|
||||
_upsert_seed_tickers()
|
||||
seed_marked = len(SEED_TICKERS)
|
||||
logger.info("seed_symbols: seed-tickers upserted (%d)", seed_marked)
|
||||
except Exception: # noqa: BLE001
|
||||
logger.exception("seed_symbols: seed-tickers upsert failed (critical)")
|
||||
except Exception as e: # noqa: BLE001
|
||||
# logger.exception 은 Python 3.11 의 traceback 포매터가 pykrx 소스의 한글 주석
|
||||
# 'df = 가...' 바이트를 만나면 UnicodeDecodeError 를 던지는 버그가 있어, 그 예외가
|
||||
# try 밖으로 escape 해서 500 을 만든다. 그래서 traceback 안 찍는다.
|
||||
logger.error("seed_symbols: seed-tickers upsert failed: %s", repr(e)[:300])
|
||||
seed_marked = 0
|
||||
|
||||
# 2) KRX 전 종목 — fetch 실패해도 부분 성공 허용
|
||||
@@ -92,8 +95,8 @@ def seed_symbols() -> SeedReport:
|
||||
for code, name in listing:
|
||||
all_rows.append((code, name, market))
|
||||
logger.info("seed_symbols: KRX %s fetched (%d)", market, len(listing))
|
||||
except Exception: # noqa: BLE001
|
||||
logger.exception("seed_symbols: KRX %s fetch failed — skip market", market)
|
||||
except Exception as e: # noqa: BLE001
|
||||
logger.error("seed_symbols: KRX %s fetch failed — skip market: %s", market, repr(e)[:300])
|
||||
market_counts[market] = 0
|
||||
|
||||
inserted = updated = 0
|
||||
@@ -122,8 +125,8 @@ def seed_symbols() -> SeedReport:
|
||||
inserted += 1
|
||||
else:
|
||||
updated += 1
|
||||
except Exception: # noqa: BLE001
|
||||
logger.exception("seed_symbols: KRX bulk upsert failed (transaction rolled back)")
|
||||
except Exception as e: # noqa: BLE001
|
||||
logger.error("seed_symbols: KRX bulk upsert failed (transaction rolled back): %s", repr(e)[:300])
|
||||
|
||||
logger.info(
|
||||
"seed_symbols done: inserted=%d updated=%d seed_marked=%d markets=%s",
|
||||
|
||||
Reference in New Issue
Block a user