Remove watchdog and tqdm dependencies, replace with logging

- Remove watchdog (unused) and tqdm from pyproject.toml dependencies
- Replace tqdm.gather() with asyncio.gather() + logger.info() in
  image_fetcher, floorplan_detector, and route_calculator services
- Replace tqdm progress bar with logger.info() in listing_repository
- Remove tqdm from mypy ignore_missing_imports overrides
This commit is contained in:
Viktor Barzin 2026-02-21 19:39:49 +00:00
parent d488208a26
commit cde3540a1e
No known key found for this signature in database
GPG key ID: 0EB088298288D958
5 changed files with 19 additions and 13 deletions

View file

@ -8,7 +8,6 @@ authors = ["Kadir Tugan <git@k8n.dev>"]
python = ">3.11"
requests = "^2.31.0"
cachetools = "^5.3.2"
tqdm = "^4.66.2"
pillow = "^10.2.0"
numpy = "^1.26.4"
pytesseract = "^0.3.10"
@ -26,7 +25,6 @@ pyjwt = "^2.10.1"
cryptography = "^45.0.4"
celery = "^5.5.3"
redis = "^6.2.0"
watchdog = "^6.0.0"
apprise = "^1.9.3"
opentelemetry-api = "^1.36.0"
opentelemetry-sdk = "^1.36.0"
@ -83,5 +81,5 @@ strict_optional = true
plugins = ["pydantic.mypy"]
[[tool.mypy.overrides]]
module = ["pytesseract.*", "cv2.*", "celery.*", "tqdm.*", "aiohttp.*", "aiohttp_socks.*", "tenacity.*", "pandas.*", "numpy.*", "PIL.*", "sqlmodel.*", "sqlalchemy.*", "alembic.*", "apprise.*", "opentelemetry.*", "webauthn.*"]
module = ["pytesseract.*", "cv2.*", "celery.*", "aiohttp.*", "aiohttp_socks.*", "tenacity.*", "pandas.*", "numpy.*", "PIL.*", "sqlmodel.*", "sqlalchemy.*", "alembic.*", "apprise.*", "opentelemetry.*", "webauthn.*"]
ignore_missing_imports = true

View file

@ -12,7 +12,6 @@ from models.listing import (
)
from sqlalchemy import Engine, func, select as sa_select
from sqlmodel import Session, select
from tqdm import tqdm
logger = logging.getLogger("uvicorn.error")
@ -263,7 +262,8 @@ class ListingRepository:
models = []
failed_to_upsert = []
with Session(self.engine) as session:
for listing in tqdm(listings, desc="Upserting listings"):
logger.info("Upserting %d listings", len(listings))
for listing in listings:
# Convert legacy Listing to the appropriate SQLModel entity
try:
model_listing = await self._get_concrete_listing(listing)

View file

@ -1,10 +1,12 @@
"""Floorplan detector service - OCR-based square meter detection."""
import asyncio
import logging
from config.scraper_config import MAX_OCR_WORKERS
from models import Listing
from rec import floorplan
from repositories.listing_repository import ListingRepository
from tqdm.asyncio import tqdm
logger = logging.getLogger(__name__)
async def detect_floorplan(repository: ListingRepository) -> None:
@ -12,13 +14,15 @@ async def detect_floorplan(repository: ListingRepository) -> None:
listings = await repository.get_listings()
semaphore = asyncio.Semaphore(MAX_OCR_WORKERS)
logger.info("Detecting floorplans for %d listings", len(listings))
updated_listings = [
listing
for listing in await tqdm.gather(
for listing in await asyncio.gather(
*[_calculate_sqm_ocr(listing, semaphore) for listing in listings]
)
if listing is not None
]
logger.info("Finished floorplan detection, %d listings updated", len(updated_listings))
await repository.upsert_listings(updated_listings)

View file

@ -8,7 +8,6 @@ import aiohttp
from rec.exceptions import FloorplanDownloadError
from repositories import ListingRepository
from tenacity import retry, stop_after_attempt, wait_random
from tqdm.asyncio import tqdm
from models import Listing
@ -26,13 +25,15 @@ async def dump_images(
) -> None:
"""Download floorplan images for all listings."""
listings = await repository.get_listings()
logger.info("Downloading images for %d listings", len(listings))
async with aiohttp.ClientSession() as session:
updated_listings = await tqdm.gather(
updated_listings = await asyncio.gather(
*[
dump_images_for_listing(listing, image_base_path, session=session)
for listing in listings
]
)
logger.info("Finished downloading images for %d listings", len(listings))
await repository.upsert_listings(
[listing for listing in updated_listings if listing is not None]
)

View file

@ -1,10 +1,13 @@
"""Route calculator service - calculates transit routes using Google Maps API."""
import asyncio
import logging
from models.listing import DestinationMode, Route, RouteLegStep
from repositories.listing_repository import ListingRepository
from tqdm.asyncio import tqdm
from rec import routing
from models import Listing
logger = logging.getLogger(__name__)
def _parse_duration(duration_str: str) -> int:
"""Parse a duration string like '123s' to integer seconds."""
@ -24,11 +27,11 @@ async def calculate_route(
listings = listings[:limit]
destination_mode = DestinationMode(destination_address, travel_mode)
updated_listings = await tqdm.gather(
logger.info("Calculating routes for %d listings", len(listings))
updated_listings = await asyncio.gather(
*[update_routing_info(listing, destination_mode) for listing in listings],
total=len(listings),
desc="Updating routing info",
)
logger.info("Finished route calculation for %d listings", len(listings))
await repository.upsert_listings(
[listing for listing in updated_listings if listing is not None]
)