Skip to content

Local development

Run Tasks-Scheduler Luigi tasks on your laptop without Docker.

Run news_fetch

export ENVIRONMENT=local
cd Tasks-Scheduler
PYTHONPATH="." .venv/bin/python -m luigi \
  --module pipes.tasks.alerts.news_fetch NewsFetchScheduler \
  --workers 1 \
  --log-level DEBUG

NewsFetchScheduler reads enabled news_fetch rows from MySQL (cron_settings) and spawns a NewsFetcher task per alert whose cron window matches.

With production MySQL

export ENVIRONMENT=local
export LOCAL_PROD_DB=1
PYTHONPATH="." .venv/bin/python -m luigi \
  --module pipes.tasks.alerts.news_fetch NewsFetchScheduler \
  --workers 1 --log-level DEBUG

IDE run configuration

Field Value
Module luigi
Parameters --module pipes.tasks.alerts.news_fetch NewsFetchScheduler --workers 1 --log-level DEBUG
Working directory Repository root
Env vars ENVIRONMENT=local;PYTHONPATH=.

Use the debugger on pipes/tasks/alerts/news_fetch.py, pipes/libs/model.py, or config/cfg.py.

Useful environment overrides

Variable Effect
IMAGE_FALLBACK_ENABLED=0 Skip slow curl_cffi image fetches (see Image fallback)
NEWS_FETCH_CRON_WINDOW_MIN Widen/narrow cron match window in eval_cron() (default 5 min)
LOCAL_PROD_DB=1 Prod MySQL, staging everything else

Tests (no AWS)

PYTHONPATH="." .venv/bin/python -m pytest tests/ -q

Active test modules:

  • test_news_fetch_http.py — HTTP retry / 429 handling
  • test_country_map.py — config/country_map.json aliases

Legacy tests for removed campaign-sync helpers may fail without spapi; focus on news_fetch tests for CI parity.

Luigi flags

Flag Purpose
--workers 1 Single worker while debugging
--log-level DEBUG Verbose Luigi output
--local-scheduler Skip luigid (typical locally)

Common issues

Symptom Fix
No module named 'config' Set PYTHONPATH=. and cwd to repo root
NoCredentialsError Refresh aws sso login / check IDE inherits shell creds
Access denied on /prd/... Drop LOCAL_PROD_DB or get IAM grant
Slow image downloads IMAGE_FALLBACK_ENABLED=0 for local iteration

Production entry (reference)

On EC2, cron invokes:

/srv/tasks-scheduler/execute.sh pipes.tasks.alerts.news_fetch NewsFetchScheduler 1

See Deploy & cron.