Skip to content
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

fix: session status_info not reflecting batch failures (#3085) #3093

Open
wants to merge 1 commit into
base: 23.09
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/3085.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix session `status_info` not being updated correctly when batch executions fail, ensuring failed batch execution states are properly reflected in the sessions table
2 changes: 1 addition & 1 deletion src/ai/backend/agent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -1650,7 +1650,7 @@ async def execute_batch(
if result["exitCode"] == 0:
await self.produce_event(
SessionSuccessEvent(
session_id, KernelLifecycleEventReason.TASK_DONE, 0
session_id, KernelLifecycleEventReason.TASK_FINISHED, 0
),
)
else:
Expand Down
1 change: 0 additions & 1 deletion src/ai/backend/common/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ class KernelLifecycleEventReason(str, enum.Enum):
RESTART_TIMEOUT = "restart-timeout"
RESUMING_AGENT_OPERATION = "resuming-agent-operation"
SELF_TERMINATED = "self-terminated"
TASK_DONE = "task-done"
TASK_FAILED = "task-failed"
TASK_TIMEOUT = "task-timeout"
TASK_CANCELLED = "task-cancelled"
Expand Down
11 changes: 6 additions & 5 deletions src/ai/backend/manager/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -3647,10 +3647,11 @@ async def handle_batch_result(
"""
Update the database according to the batch-job completion results
"""
if isinstance(event, SessionSuccessEvent):
await SessionRow.set_session_result(context.db, event.session_id, True, event.exit_code)
elif isinstance(event, SessionFailureEvent):
await SessionRow.set_session_result(context.db, event.session_id, False, event.exit_code)
match event:
case SessionSuccessEvent(session_id=session_id, reason=reason, exit_code=exit_code):
await SessionRow.set_session_result(context.db, session_id, True, exit_code)
case SessionFailureEvent(session_id=session_id, reason=reason, exit_code=exit_code):
await SessionRow.set_session_result(context.db, session_id, False, exit_code)
async with context.db.begin_session() as db_sess:
try:
session = await SessionRow.get_session(
Expand All @@ -3660,7 +3661,7 @@ async def handle_batch_result(
return
await context.destroy_session(
session,
reason=KernelLifecycleEventReason.TASK_FINISHED,
reason=reason,
)

await invoke_session_callback(context, source, event)
Expand Down
Loading