-
Notifications
You must be signed in to change notification settings - Fork 7
job_queue: set completed_at for terminal status and return job copies #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
job_queue: set completed_at for terminal status and return job copies #13
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Sets completed_at for all terminal job statuses (completed, failed, cancelled) and returns shallow copies from job accessors to prevent external mutation of internal state.
- Set completed_at consistently for all terminal statuses.
- Clear _active_job on any terminal status.
- Return shallow copies from get_job, get_active_job, and get_pipeline_history.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
Hi @Ujjansh05, great catch! Before merging, please ensure you've merged the latest changes from the develop branch. Also, consider adding unit tests to cover this scenario, which will help prevent future regressions. This is excellent work! |
Job Queue Tests: Terminal Status & Copy SafetySummaryAdded unit tests to verify correct handling of terminal job statuses and protection against unintended state mutations. New Tests
|
|
Nice job! I will take a look asap. I'll merge and close this PR. Feel free to open new issues and contribute! |
|
Thanks for the feedback and for reviewing the PR. Iβll keep an eye out for any follow-up comments or future contributions. |
|
We can merge! Nice job. |
fix: job_queue β set
completed_atfor terminal statuses and return job copiesπ Description
This PR fixes two issues in
job_queue.py:completed_atis set when a job reaches any terminal status ("completed","failed", or"cancelled").get_job,get_active_job, andget_pipeline_historyto avoid exposing internal job dictionaries to callers β preventing accidental external mutation after the lock is released.Motivation
Previously:
update_job(..., status="cancelled")did not setcompleted_at(onlycancel_jobdid).β This left cancelled jobs without a completion timestamp.
π§ Changes
completed_atfor all terminal statuses inupdate_job._active_jobwhen a terminal status is set.dict.copy()from:get_jobget_active_jobget_pipeline_historyRelated Issue
_No existing issue; this is a small bugfix and safety improvement.
Testing
pytest-asyncio(ModuleNotFoundError).Details
job_queue.pychanges are minimal and logically covered by existing unit tests.β Checklist
make formatpassesmake lintpassesmake typecheckpassesmake testpassesNotes
This fix improves reliability and safety in job lifecycle management by ensuring proper completion timestamps and protecting internal state integrity.