feat: update queue item on session completion #6408
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
feat(app): update queue item's session on session completion
The session is never updated in the queue after it is first enqueued. As a result, the queue detail view in the frontend never never updates and the session itself doesn't show outputs, execution graph, etc.
We need a new method on the queue service to update a queue item's session, then call it before updating the queue item's status.
Queue item status may be updated via a session-type event or queue-type event. Adding the updated session to all these events is a hairy - simpler to just update the session before we do anything that could trigger a queue item status change event:
emit_session_complete
in the processor (handles session error, completed and cancel events and the corresponding queue events)cancel_queue_item
in the processor (handles another way queue items can be canceled, outside the session execution loop)When serializing the session, both in the new service method and the
get_queue_item
endpoint, we need to useexclude_none=True
to prevent unexpected validation errors.Related Issues / Discussions
Closes #5933
QA Instructions
main
, generate an image & wait for it to finishMerge Plan
This is based on #5748. I'll merge and update this PR as required after that one is merged.
Checklist