feat(tradein/scraper-kit): migrate backfill/enrichment tasks to kit (#2310) #2333

Merged
lekss361 merged 2 commits from feat/tradein-migrate-backfill-tasks-kit into main 2026-07-03 22:28:11 +00:00
Owner

Closes #2310 (Group C эпика #2277 — scraper_kit migration, крупнейшая оставшаяся группа).

Что сделано

Мигрировано на scraper_kit.*: house_imv_backfill.py, app/tasks/avito_detail_backfill.py,
app/tasks/cian_history_backfill.py (только listings-блок), app/tasks/ekb_geoportal_ingest.py,
app/tasks/yandex_detail_backfill.py.

Намеренно НЕ мигрировано

  • app/tasks/newbuilding_enrich_backfill.py, app/tasks/yandex_newbuilding_sweep.py — упираются
    в уже известный баг #2322 (kit newbuilding providers без endpoint=). Оставлены на legacy,
    только пояснительные комментарии.
  • cian_history_backfill.py's houses-блок (cian_newbuilding, тот же #2322) и valuations-блок
    (cian_valuation, вне scope — это #2308) — legacy.
  • avito build_warmed_session/_AVITO_WARM_SEARCH_URL в avito_detail_backfill.py — новый
    найденный баг: kit-версия не выставляет config вообще, миграция тихо уронила бы sticky-proxy
    на прод-дефолтном пути (avito_detail_backfill_use_curl=True). Заведён issue #2330.

Config-footgun фиксы (паттерн из #2306)

  • avito fetch_detail's backconnect-retry-on-403 отключается без config= → передан
    config=RealScraperConfig()
  • kit AvitoScraper.__init__ требует ScraperConfig позиционно (legacy — нет) →
    AvitoScraper(RealScraperConfig())
  • Оба закрыты call-site regression-тестами (не только library-level) — доказано вручную: убрал
    config= → тест упал на нужном assert → вернул → прошёл

Проверено

  • Новый parity-файл tests/test_scraper_kit_group_c_backfill_kit_parity.py — 8 тестов
  • 2 pre-existing теста в test_avito_detail_backfill.py обновлены под новую реальность
    (import-пути исключений, усиленный BrowserFetcher-assert, config-kwarg в fake fetch)
  • Полный backend suite: 3208 passed / 6 skipped / 1 pre-existing unrelated failure
  • ruff check + format — чисто
  • Code-review: APPROVE (глубокая верификация всех claims — #2322/#2330 gating, config-фиксы,
    cian_history_backfill scope-split, test fixes — всё подтверждено чтением реального кода)

Дальше

Остаются Group E (#2308, core valuation, максимальный риск) и Group F (#2309, широкий рефактор
providers/*).

Closes #2310 (Group C эпика #2277 — scraper_kit migration, крупнейшая оставшаяся группа). ## Что сделано Мигрировано на `scraper_kit.*`: `house_imv_backfill.py`, `app/tasks/avito_detail_backfill.py`, `app/tasks/cian_history_backfill.py` (только listings-блок), `app/tasks/ekb_geoportal_ingest.py`, `app/tasks/yandex_detail_backfill.py`. ## Намеренно НЕ мигрировано - `app/tasks/newbuilding_enrich_backfill.py`, `app/tasks/yandex_newbuilding_sweep.py` — упираются в уже известный баг #2322 (kit newbuilding providers без `endpoint=`). Оставлены на legacy, только пояснительные комментарии. - `cian_history_backfill.py`'s houses-блок (`cian_newbuilding`, тот же #2322) и valuations-блок (`cian_valuation`, вне scope — это #2308) — legacy. - avito `build_warmed_session`/`_AVITO_WARM_SEARCH_URL` в `avito_detail_backfill.py` — новый найденный баг: kit-версия не выставляет `config` вообще, миграция тихо уронила бы sticky-proxy на **прод-дефолтном** пути (`avito_detail_backfill_use_curl=True`). Заведён issue #2330. ## Config-footgun фиксы (паттерн из #2306) - avito `fetch_detail`'s backconnect-retry-on-403 отключается без `config=` → передан `config=RealScraperConfig()` - kit `AvitoScraper.__init__` требует `ScraperConfig` позиционно (legacy — нет) → `AvitoScraper(RealScraperConfig())` - Оба закрыты call-site regression-тестами (не только library-level) — доказано вручную: убрал `config=` → тест упал на нужном assert → вернул → прошёл ## Проверено - Новый parity-файл `tests/test_scraper_kit_group_c_backfill_kit_parity.py` — 8 тестов - 2 pre-existing теста в `test_avito_detail_backfill.py` обновлены под новую реальность (import-пути исключений, усиленный `BrowserFetcher`-assert, config-kwarg в fake fetch) - Полный backend suite: 3208 passed / 6 skipped / 1 pre-existing unrelated failure - ruff check + format — чисто - Code-review: ✅ APPROVE (глубокая верификация всех claims — #2322/#2330 gating, config-фиксы, cian_history_backfill scope-split, test fixes — всё подтверждено чтением реального кода) ## Дальше Остаются Group E (#2308, core valuation, максимальный риск) и Group F (#2309, широкий рефактор providers/*).
lekss361 added 2 commits 2026-07-03 22:23:30 +00:00
Migrates legacy app.services.scrapers.* imports to scraper_kit equivalents for
house_imv_backfill.py, avito_detail_backfill.py, cian_history_backfill.py,
ekb_geoportal_ingest.py, and yandex_detail_backfill.py, proving parity via
tests/support/parity.assert_parity per the epic's gate (#2304).

newbuilding_enrich_backfill.py and yandex_newbuilding_sweep.py are left fully
on legacy imports: both call into scraper_kit.providers.{cian,yandex}.newbuilding,
which construct BrowserFetcher(source=...) without the now-mandatory endpoint=
kwarg (issue #2322, verified still open against the actual provider source, not
just issue status) -- no caller-side fix is possible, matching Group A's (#2305)
precedent for the same bug in admin.py.

Config-gated kit function footguns found and fixed (Group B #2306 pattern):
  - avito fetch_detail's backconnect-on-403 retry silently drops when config=
    is omitted -- now passes config=RealScraperConfig() explicitly, with a
    regression test proving the gate.
  - kit AvitoScraper's constructor now requires ScraperConfig positionally --
    wired via RealScraperConfig(), which _rotate_ip() reads for
    avito_proxy_rotate_url.
  - BrowserFetcher(source=...) call sites (house_imv_backfill, avito/cian
    detail backfills) now pass the mandatory endpoint=settings.browser_http_endpoint.

New footgun discovered (NOT #2322, flagged for follow-up): kit's
build_warmed_session() builds its curl_cffi session via _build_detail_session()
with no config parameter at all, unlike fetch_detail -- migrating it would
silently drop the sticky MGTS-proxy egress on avito_detail_backfill's
warm-batch path (the prod default). Left build_warmed_session/
_AVITO_WARM_SEARCH_URL on legacy imports, documented inline.

Refs #2310
test(tradein/scraper-kit): assert config= at avito_detail_backfill call sites (#2310)
All checks were successful
CI / changes (pull_request) Successful in 9s
CI Trade-In / changes (pull_request) Successful in 10s
CI Trade-In / frontend-checks (pull_request) Has been skipped
CI / backend-tests (pull_request) Has been skipped
CI / frontend-tests (pull_request) Has been skipped
CI / openapi-codegen-check (pull_request) Has been skipped
CI Trade-In / backend-tests (pull_request) Successful in 1m39s
116cd10046
Code-review follow-up: the Group C regression tests for the fetch_detail
backconnect footgun and AvitoScraper's config requirement proved the KIT
LIBRARY behavior in isolation, but nothing asserted the actual call sites in
avito_detail_backfill.py still pass config=RealScraperConfig() at fetch_detail
and AvitoScraper construction. Mirrors #2306's test_backfill_wave2.py:282-286
pattern -- isinstance-checks the captured call_args instead of a bare
assert_called().

Verified the new assertions actually catch the regression: temporarily
removed both config=RealScraperConfig() call-site args from
avito_detail_backfill.py, confirmed test_backfill_processes_snapshot_to_completion
fails exactly on the new assertion line, then restored (git diff was empty
afterward).

Refs #2310
lekss361 merged commit f41ca530c5 into main 2026-07-03 22:28:11 +00:00
lekss361 deleted branch feat/tradein-migrate-backfill-tasks-kit 2026-07-03 22:28:11 +00: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: lekss361/gendesign#2333
No description provided.