screencastgen

Jobs Router

Job CRUD operations and Celery task dispatch.

Source: web/backend/routers/jobs.py


Endpoints

POST /api/jobs

Create a job and dispatch it to the Celery worker.

Request body: JobCreateRequest

Process:

  1. Validate uploaded file exists for document pipelines
  2. Validate reference files exist (if provided)
  3. Build config_json from request
  4. Create Job record with pending status
  5. Call run_pipeline_task.delay(str(job.id))Pipeline Tasks
  6. Store celery_task_id on the job

Response: JobResponse

GET /api/jobs

List jobs with optional filtering and pagination.

Query parameters:

Param Type Default Description
status str None Filter by status
limit int 20 Results per page (1-100)
offset int 0 Pagination offset

Response: JobListResponse

GET /api/jobs/{job_id}

Get a single job by ID.

Response: JobResponse

DELETE /api/jobs/{job_id}

Delete a job and clean up its files.

Process:

  1. Delete job record from database
  2. Call delete_job_files() to remove output directory

POST /api/jobs/{job_id}/stop

Request an early stop for a running lip-sync job.

Validation:

After validation, the endpoint writes job:{id}:cancel to Redis with a 24-hour expiry and returns { "detail": "stop requested" }. The worker polls this flag via Progress Reporter and, for remote GPU work, forwards cancellation to the inference server. The frontend requires a separate inline confirmation before it calls this endpoint; the API itself remains suitable for programmatic clients.

GET /api/jobs/{job_id}/download

Download the job’s output file. The response type depends on the configured storage backend:

POST /api/jobs/{job_id}/export-epub

Trigger an on-demand text-and-narration EPUB export for a completed lip-sync reader job. The presenter is intentionally omitted because EPUB reading systems do not reliably synchronize video with Media Overlays. The task stores separate state in job.config_json:

GET /api/jobs/{job_id}/export-epub/status

Return the current EPUB export state using the common export_status, export_output, and export_error response keys.

GET /api/jobs/{job_id}/export-epub/download

Download the exported EPUB when epub_export_status == "done".


Dependencies

Jobs Router
├── Web Database       (async session)
├── DB Models          (Job, JobStatus, UploadedFile)
├── Schemas            (JobCreateRequest, JobResponse, JobListResponse)
├── Storage Service    (delete_job_files, get_download_response)
└── Pipeline Tasks     (main and EPUB-export tasks; lazy imports)

See Also