Skip to content

Running tasks

Harvester work is expressed as Luigi tasks. Cron on EC2 invokes wrapper shell scripts; locally you call Luigi directly with the same module and class names.

Local Luigi invocation

export ENVIRONMENT=local
cd skynet-sources-harvester
PYTHONPATH="." env/bin/python -m luigi \
    --module pipes.tasks.cost_sync CostSync \
    --workers 1 \
    --log-level DEBUG

Replace --module and the task class for the pipeline you need. Wrapper tasks fan out per provider or site; leaf tasks do the actual sync.

Useful Luigi flags

Flag Purpose
--workers N Parallel worker processes (use 1 when debugging)
--log-level DEBUG Verbose Luigi + task logging
--data-date YYYY-MM-DD Backfill date (many sync tasks)
--providers TABOOLA,DFP Limit provider scope
--local-scheduler Run without luigid (typical for laptop one-offs)

Cron entry scripts (execute*.sh)

Production cron sources .env then runs Luigi from /srv/skynet-sources-harvester:

SKYNETPATH=/srv/skynet-sources-harvester
source $SKYNETPATH/.env          # ENVIRONMENT=stg|prd
cd $SKYNETPATH
PYTHONPATH='.' env/bin/python -m luigi --module $MODULE $TASK ...
Script Notable arguments
execute.sh --data-date $YESTERDAY
execute_providers.sh (+ _2days, _rt, _type, …) --providers, flock lock
execute_dfp_sync.sh --providers DFP --retro
execute_db_procedure.sh --per-site
execute_rt.sh --data-date $TODAY
execute_ml.sh --providers (no data-date)
execute_by_site.sh Site filter variants

Read the script header for the exact $MODULE and $TASK variables.

AI content actions

Scheduled via pipes/tasks/alerts/ai_content_actions.py:

  • AiScheduler / AiSchedulerSplit — pick pending actions from MySQL
  • AIActionExecutor / AIActionExecutorFarm — run step pipelines in pipes/tasks/ai_actions_logic/ (WordPress publish, image generation, etc.)

Run a single executor locally for debugging:

export ENVIRONMENT=local
PYTHONPATH="." env/bin/python -m luigi \
    --module pipes.tasks.alerts.ai_content_actions AIActionExecutor \
    --workers 1 --log-level DEBUG --local-scheduler

Pass task parameters documented in the alert's cron_settings JSON.

Luigi state

Task completion markers live under luigi/default/. Delete a marker to force a re-run during local debugging (use carefully on shared schedulers).

Observability

Failed Luigi tasks emit structured events through fs_obs (see pipes/observability.py). Correlation IDs are minted at task start. On EC2 the watchdog complements this with CPU and scheduler health signals — see Health watchdog.