(job_id: str, **updates: Any)
| 54 | |
| 55 | |
| 56 | def update_job(job_id: str, **updates: Any) -> Job | None: |
| 57 | job = get_job(job_id) |
| 58 | if job is None: |
| 59 | return None |
| 60 | |
| 61 | now = time.time() |
| 62 | if updates.get("status") == "running" and job.started_at is None: |
| 63 | updates.setdefault("started_at", now) |
| 64 | if updates.get("status") in {"completed", "failed"}: |
| 65 | updates.setdefault("completed_at", now) |
| 66 | |
| 67 | updated = job.model_copy(update=updates) |
| 68 | r.set(JOB_KEY.format(job_id), updated.model_dump_json()) |
| 69 | return updated |
| 70 | |
| 71 | |
| 72 | def clear_jobs() -> int: |
no test coverage detected