chore: add 105 runtime and openhands ops tooling

This commit is contained in:
john
2026-06-29 07:01:26 +08:00
parent 65e8a3a5a8
commit d7cbf3cc96
22 changed files with 1263 additions and 50 deletions
+88
View File
@@ -0,0 +1,88 @@
"""Sync DB with Models
Revision ID: 002
Revises: 001
Create Date: 2025-10-05 11:28:41.772294
"""
from enum import Enum
from typing import Sequence
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision: str = '002'
down_revision: str | None = '001'
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None
class EventCallbackStatus(Enum):
ACTIVE = 'ACTIVE'
DISABLED = 'DISABLED'
COMPLETED = 'COMPLETED'
ERROR = 'ERROR'
def upgrade() -> None:
"""Upgrade schema."""
bind = op.get_bind()
event_callback_status = sa.Enum(
EventCallbackStatus,
name='eventcallbackstatus',
)
event_callback_status.create(bind, checkfirst=True)
op.add_column(
'event_callback',
sa.Column(
'status',
event_callback_status,
nullable=False,
server_default='ACTIVE',
),
)
op.add_column(
'event_callback',
sa.Column(
'updated_at', sa.DateTime, nullable=False, server_default=sa.func.now()
),
)
op.drop_index('ix_event_callback_result_event_id')
op.drop_column('event_callback_result', 'event_id')
op.add_column(
'event_callback_result', sa.Column('event_id', sa.String, nullable=True)
)
op.create_index(
op.f('ix_event_callback_result_event_id'),
'event_callback_result',
['event_id'],
unique=False,
)
def downgrade() -> None:
"""Downgrade schema."""
bind = op.get_bind()
event_callback_status = sa.Enum(
EventCallbackStatus,
name='eventcallbackstatus',
)
op.drop_column('event_callback', 'status')
op.drop_column('event_callback', 'updated_at')
op.drop_index('ix_event_callback_result_event_id')
op.drop_column('event_callback_result', 'event_id')
op.add_column(
'event_callback_result', sa.Column('event_id', sa.UUID, nullable=True)
)
op.create_index(
op.f('ix_event_callback_result_event_id'),
'event_callback_result',
['event_id'],
unique=False,
)
event_callback_status.drop(bind, checkfirst=True)
+34
View File
@@ -0,0 +1,34 @@
"""Add composite index on event_callback for execute_callbacks query
Revision ID: 010
Revises: 009
Create Date: 2026-06-03
"""
from typing import Sequence
from alembic import op
revision: str = '010'
down_revision: str | None = '009'
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None
def upgrade() -> None:
# Local PG validation uses an empty dev database, so a regular index keeps
# startup reliable without depending on autocommit behavior.
op.create_index(
'ix_event_callback_conversation_id_status_event_kind',
'event_callback',
['conversation_id', 'status', 'event_kind'],
if_not_exists=True,
)
def downgrade() -> None:
op.drop_index(
'ix_event_callback_conversation_id_status_event_kind',
table_name='event_callback',
if_exists=True,
)
+6
View File
@@ -0,0 +1,6 @@
FROM ghcr.io/openhands/openhands:latest
RUN /app/.venv/bin/pip install --no-cache-dir asyncpg
COPY 002.py /app/openhands/app_server/app_lifespan/alembic/versions/002.py
COPY 010.py /app/openhands/app_server/app_lifespan/alembic/versions/010.py