feat: APScheduler 정기 수집 (#5) #31

Merged
xhh merged 2 commits from issue-5-apscheduler into main 2026-04-22 03:21:09 +09:00
Owner

Summary

  • BackgroundScheduler (KST) 로 collect_daily / insider / margin_debt 정기 자동 수집
  • SCHEDULER_ENABLED 환경변수로 on/off (테스트 기본 off)
  • FastAPI lifespan 으로 start/shutdown 훅
  • 6 신규 테스트 (구성 / subprocess mock / 예외 삼킴 / lifespan start+shutdown)
  • 총 47 테스트 통과 (41 → 47)

Closes #5

## Summary - BackgroundScheduler (KST) 로 collect_daily / insider / margin_debt 정기 자동 수집 - SCHEDULER_ENABLED 환경변수로 on/off (테스트 기본 off) - FastAPI lifespan 으로 start/shutdown 훅 - 6 신규 테스트 (구성 / subprocess mock / 예외 삼킴 / lifespan start+shutdown) - 총 47 테스트 통과 (41 → 47) Closes #5
feat: APScheduler 정기 수집 (#5)
Some checks failed
Tests (PR) / pytest (pull_request) Failing after 26s
2fd81fb0f9
- `scheduler/jobs.py`: subprocess 로 scripts/*.py 를 호출하는 얇은 래퍼 3종
  (collect_daily / collect_insider --days 7 / collect_margin_debt). 예외는
  삼키고 로깅만 해서 스케줄러 자체가 죽지 않도록.
- `scheduler/scheduler.py::build_scheduler()`: CronTrigger KST 기반
  - collect_daily: 매일 09:00
  - collect_insider: 매주 월 09:30
  - collect_margin_debt: 매월 3주차 화 10:00 (day=15-21, dow=tue)
  - SCHEDULER_ENABLED=0 이면 None 반환 → 테스트/수동 실행 환경 보호
- `api/main.py`: FastAPI `lifespan` 에서 스케줄러 start/shutdown 훅
- `tests/conftest.py`: SCHEDULER_ENABLED=0 기본 주입
- `tests/api/test_scheduler.py`: 6 case (구성/subprocess mock/예외 삼킴/
  lifespan 훅 start+shutdown)

47 tests pass (41 → 47).

Closes #5

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
fix: tzdata 패키지 추가 — Runner 컨테이너 Asia/Seoul 타임존 해결
All checks were successful
Tests (PR) / pytest (pull_request) Successful in 25s
12250bb190
CI 실패 로그 (test-pytest-32.log):
  zoneinfo._common.ZoneInfoNotFoundError: 'No time zone found with key Asia/Seoul'

Forgejo Runner 는 alpine 기반 슬림 이미지라 시스템 tzdata 가 없음.
APScheduler CronTrigger(timezone='Asia/Seoul') 이 zoneinfo lookup 을
하면서 실패. 순수 Python tzdata 패키지를 추가해 OS 의존 제거.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
xhh merged commit c3aa5a8c03 into main 2026-04-22 03:21:09 +09:00
xhh referenced this pull request from a commit 2026-04-22 03:24:24 +09:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
xhh/financial-data-platform!31
No description provided.