gendesign/backend/app/services/forecasting
Light1YT 31c5974c72
All checks were successful
CI / changes (push) Successful in 7s
CI / frontend-tests (push) Has been skipped
CI / changes (pull_request) Successful in 7s
CI / frontend-tests (pull_request) Has been skipped
CI / backend-tests (push) Successful in 6m26s
CI / backend-tests (pull_request) Successful in 6m22s
Deploy / build-backend (push) Successful in 1m45s
Deploy / changes (push) Successful in 6s
Deploy / build-frontend (push) Has been skipped
Deploy / build-worker (push) Successful in 2m42s
Deploy / deploy (push) Successful in 1m12s
fix(forecasting): нормализовать dict-district в build_site_finder_report (#1130 follow-up)
`analyze["district"]` в этой кодовой базе — dict вида
{"district_name": "Верх-Исетский", "dist_to_center": 0.0, "median_price_per_m2": ...}.
Штатный caller (`workers/tasks/forecast.py:123`) явно извлекает `district_name`:
`district = row.district or analyze["district"]["district_name"]`. Но новые callers
(тесты, расширения чата, ad-hoc эндпоинты) легко передают сырой dict без знания этой
конвенции — тогда внутри §9.x-слоёв compute_market_metrics(district=<dict>) падает
с TypeError: unhashable type: 'dict' в forecast_request_cache.wrapper,
`_safe_call` это проглатывает → секции future_market.forecasts_by_horizon=[] и
scenarios.by_scenario={} тихо остаются пустыми (silent degrade, не 500).

Добавлен `_normalize_district(district)` — pure-нормализация на входе оркестратора:
  - str → как есть;
  - None → None;
  - dict с district_name (непустая строка) → извлекаем;
  - dict без district_name / с пустым / неподдерживаемый тип → None + logger.warning.

7 unit-тестов в test_orchestrator.py::TestNormalizeDistrict (все варианты входов).
Не меняет поведение штатного caller'а (str → str), только защищает от случайных
dict-callers.

Discovered through: #1130 Phase A (мой первый тестовый скрипт со скормленным
сырым `analyze["district"]` dict выдал forecasts.n_horizons=0 + 15 TypeError'ов
в _safe_call). Закрывает чип task_4a4aa3bb.

Refs #1130
2026-06-13 09:24:55 +05:00
..
__init__.py feat(forecasting): §13 report assembler (#988, 955-A2) (#1021) 2026-06-03 08:51:23 +00:00
affordability.py fix(affordability): calibrate key_rate->market mortgage spread to 4.5pp 2026-06-04 17:21:29 +05:00
confidence_engine.py feat(forecasting): §15 confidence engine v2 (#990, 955-A4) (#1020) 2026-06-03 08:41:07 +00:00
demand_normalization.py perf(forecast): per-request memoization cache for §22 cold build (#1129) 2026-06-08 05:26:27 +00:00
demand_supply_forecast.py feat(forecasting): add months-of-inventory (MOI) to §9.8 demand-supply forecast 2026-06-05 07:36:59 +05:00
macro_coefficient.py feat(macro): CBR inflation (ИПЦ YoY) -> macro_indicator + activate §9.5 channel (#946) 2026-06-08 11:41:14 +05:00
macro_series.py feat(macro): CBR inflation (ИПЦ YoY) -> macro_indicator + activate §9.5 channel (#946) 2026-06-08 11:41:14 +05:00
normalize.py feat(forecasting): seasonal (month-of-year) demand normalization (#979) 2026-06-04 11:19:50 +05:00
orchestrator.py fix(forecasting): нормализовать dict-district в build_site_finder_report (#1130 follow-up) 2026-06-13 09:24:55 +05:00
product_scoring.py feat(forecasting): wire Almon-ADL rate estimator into §9.6 consumers (#978) 2026-06-04 10:33:31 +00:00
rate_sensitivity.py feat(forecasting): seasonal (month-of-year) demand normalization (#979) 2026-06-04 11:19:50 +05:00
recommendation.py fix(forecasting): honest USP gate (di>0) + unit-explicit coverage fraction 2026-06-04 13:25:25 +05:00
regression.py perf(forecast): per-request memoization cache for §22 cold build (#1129) 2026-06-08 05:26:27 +00:00
report.py feat(forecasting): §13 SiteFinderReport object (#987, 955-A1) (#1019) 2026-06-03 08:33:01 +00:00
report_assembler.py feat(forecasting): add months-of-inventory (MOI) to §9.8 demand-supply forecast 2026-06-05 07:36:59 +05:00
sales_series.py perf(forecast): per-request memoization cache for §22 cold build (#1129) 2026-06-08 05:26:27 +00:00
scenarios.py feat(forecasting): §11 macro-scenarios (#984, 954-A) (#1016) 2026-06-03 07:59:22 +00:00
special_indices.py feat(forecasting): activate §25.3 cannibalization unit-mix axis (4/4), gated (#1169) 2026-06-09 16:09:29 +05:00
what_to_build.py feat(forecasting): what-to-build ranker + MAI proxy (#981, 952-B) (#1013) 2026-06-03 07:07:17 +00:00