Skip to content

Commit

Permalink
revive batch_timeout column to avoid confusion between timeout column
Browse files Browse the repository at this point in the history
  • Loading branch information
fregataa committed Nov 11, 2024
1 parent 6e65412 commit 6511022
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""add sessions batch_timeout column
Revision ID: d4c174934fd0
Revises: e9e574a6e22d
Create Date: 2024-11-11 16:47:05.150825
"""

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "d4c174934fd0"
down_revision = "e9e574a6e22d"
branch_labels = None
depends_on = None


def upgrade() -> None:
op.add_column("sessions", sa.Column("batch_timeout", sa.BigInteger(), nullable=True))


def downgrade() -> None:
op.drop_column("sessions", "batch_timeout")
7 changes: 4 additions & 3 deletions src/ai/backend/manager/models/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,9 +705,10 @@ class SessionRow(Base):
use_host_network = sa.Column("use_host_network", sa.Boolean(), default=False, nullable=False)

# Lifecycle
timeout = sa.Column(
"timeout", sa.BigInteger(), nullable=True
) # Used to set timeout of batch session
timeout = sa.Column("timeout", sa.BigInteger(), nullable=True)
batch_timeout = sa.Column(
"batch_timeout", sa.BigInteger(), nullable=True
) # Used to set timeout of batch sessions
created_at = sa.Column(
"created_at", sa.DateTime(timezone=True), server_default=sa.func.now(), index=True
)
Expand Down
6 changes: 4 additions & 2 deletions src/ai/backend/manager/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,9 @@ async def enqueue_session(
"access_key": access_key,
"tag": session_tag,
"starts_at": starts_at,
"timeout": int(batch_timeout.total_seconds()) if batch_timeout is not None else None,
"batch_timeout": int(batch_timeout.total_seconds())
if batch_timeout is not None
else None,
"callback_url": callback_url,
"occupying_slots": ResourceSlot(),
"vfolder_mounts": vfolder_mounts,
Expand Down Expand Up @@ -2732,7 +2734,7 @@ async def trigger_batch_execution(
str(session.id),
str(session.main_kernel.id),
session.main_kernel.startup_command or "",
session.timeout,
session.batch_timeout,
)

async def interrupt_session(
Expand Down

0 comments on commit 6511022

Please sign in to comment.