Skip to content

Commit 751f459

Browse files
committed
Refactor enum values in migration scripts to lowercase
- Updated enum values in multiple migration scripts to use lowercase for consistency with OpenAI API standards. - Adjusted `finish_reason`, `item_type`, `score_type`, `evaluation_status`, and `optimization_status` enums accordingly.
1 parent e0208fa commit 751f459

File tree

5 files changed

+97
-63
lines changed

5 files changed

+97
-63
lines changed

backend/migrations/versions/2ab7f18e5ff7_restructure_traces_to_match_openai_api.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
"""restructure_traces_to_match_openai_api
1+
"""Restructure traces to match OpenAI API.
22
33
Revision ID: 2ab7f18e5ff7
4-
Revises:
4+
Revises:
55
Create Date: 2025-10-17 15:28:15.330107
66
77
"""
@@ -19,27 +19,27 @@
1919

2020

2121
finish_reason_enum = postgresql.ENUM(
22-
"STOP",
23-
"LENGTH",
24-
"TOOL_CALLS",
25-
"CONTENT_FILTER",
26-
"FUNCTION_CALL",
27-
"ERROR",
22+
"stop",
23+
"length",
24+
"tool_calls",
25+
"content_filter",
26+
"function_call",
27+
"error",
2828
name="finish_reason",
2929
create_type=False,
3030
)
3131

3232
item_type_enum = postgresql.ENUM(
33-
"MESSAGE",
34-
"FUNCTION_CALL",
35-
"FUNCTION_RESULT",
36-
"TOOL_CALL",
37-
"TOOL_RESULT",
38-
"IMAGE",
39-
"VIDEO",
40-
"AUDIO",
41-
"MCP_TOOL_CALL",
42-
"MCP_TOOL_RESULT",
33+
"message",
34+
"function_call",
35+
"function_result",
36+
"tool_call",
37+
"tool_result",
38+
"image",
39+
"video",
40+
"audio",
41+
"mcp_tool_call",
42+
"mcp_tool_result",
4343
name="item_type",
4444
create_type=False,
4545
)

backend/migrations/versions/53914fdc7590_add_optimization_model.py

Lines changed: 67 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,54 +5,88 @@
55
Create Date: 2025-10-31 20:35:10.057534
66
77
"""
8-
from typing import Sequence, Union
8+
from collections.abc import Sequence
99

10-
from alembic import op
1110
import sqlalchemy as sa
11+
from alembic import op
1212
from sqlalchemy.dialects import postgresql
1313

1414
# revision identifiers, used by Alembic.
15-
revision: str = '53914fdc7590'
16-
down_revision: Union[str, Sequence[str], None] = '37309a4b1b2f'
17-
branch_labels: Union[str, Sequence[str], None] = None
18-
depends_on: Union[str, Sequence[str], None] = None
15+
revision: str = "53914fdc7590"
16+
down_revision: str | Sequence[str] | None = "37309a4b1b2f"
17+
branch_labels: str | Sequence[str] | None = None
18+
depends_on: str | Sequence[str] | None = None
19+
20+
21+
optimization_status_enum = postgresql.ENUM(
22+
"pending",
23+
"running",
24+
"completed",
25+
"failed",
26+
name="optimization_status",
27+
create_type=False,
28+
)
1929

2030

2131
def upgrade() -> None:
2232
"""Upgrade schema."""
2333
# ### commands auto generated by Alembic - please adjust! ###
24-
op.create_table('optimization',
25-
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
26-
sa.Column('task_id', sa.Integer(), nullable=False),
27-
sa.Column('status', sa.Enum('PENDING', 'RUNNING', 'COMPLETED', 'FAILED', name='optimization_status'), nullable=False),
28-
sa.Column('started_at', sa.DateTime(timezone=True), nullable=True),
29-
sa.Column('completed_at', sa.DateTime(timezone=True), nullable=True),
30-
sa.Column('error', sa.Text(), nullable=True),
31-
sa.Column('max_iterations', sa.Integer(), nullable=False),
32-
sa.Column('changeable_fields', sa.JSON().with_variant(postgresql.JSONB(astext_type=sa.Text()), 'postgresql'), nullable=False),
33-
sa.Column('max_consecutive_no_improvements', sa.Integer(), nullable=False),
34-
sa.Column('iterations_run', sa.Integer(), nullable=False),
35-
sa.Column('current_iteration', sa.Integer(), nullable=True),
36-
sa.Column('best_implementation_id', sa.Integer(), nullable=True),
37-
sa.Column('best_score', sa.Float(), nullable=True),
38-
sa.Column('iterations', sa.JSON().with_variant(postgresql.JSONB(astext_type=sa.Text()), 'postgresql'), nullable=False),
39-
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
40-
sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
41-
sa.ForeignKeyConstraint(['best_implementation_id'], ['implementation.id'], name=op.f('fk_optimization_best_implementation_id_implementation'), ondelete='SET NULL'),
42-
sa.ForeignKeyConstraint(['task_id'], ['task.id'], name=op.f('fk_optimization_task_id_task'), ondelete='CASCADE'),
43-
sa.PrimaryKeyConstraint('id', name=op.f('pk_optimization'))
34+
bind = op.get_bind()
35+
optimization_status_enum.create(bind, checkfirst=True)
36+
37+
op.create_table(
38+
"optimization",
39+
sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
40+
sa.Column("task_id", sa.Integer(), nullable=False),
41+
sa.Column("status", optimization_status_enum, nullable=False),
42+
sa.Column("started_at", sa.DateTime(timezone=True), nullable=True),
43+
sa.Column("completed_at", sa.DateTime(timezone=True), nullable=True),
44+
sa.Column("error", sa.Text(), nullable=True),
45+
sa.Column("max_iterations", sa.Integer(), nullable=False),
46+
sa.Column(
47+
"changeable_fields",
48+
sa.JSON().with_variant(postgresql.JSONB(astext_type=sa.Text()), "postgresql"),
49+
nullable=False,
50+
),
51+
sa.Column("max_consecutive_no_improvements", sa.Integer(), nullable=False),
52+
sa.Column("iterations_run", sa.Integer(), nullable=False),
53+
sa.Column("current_iteration", sa.Integer(), nullable=True),
54+
sa.Column("best_implementation_id", sa.Integer(), nullable=True),
55+
sa.Column("best_score", sa.Float(), nullable=True),
56+
sa.Column(
57+
"iterations",
58+
sa.JSON().with_variant(postgresql.JSONB(astext_type=sa.Text()), "postgresql"),
59+
nullable=False,
60+
),
61+
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
62+
sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
63+
sa.ForeignKeyConstraint(
64+
["best_implementation_id"],
65+
["implementation.id"],
66+
name=op.f("fk_optimization_best_implementation_id_implementation"),
67+
ondelete="SET NULL",
68+
),
69+
sa.ForeignKeyConstraint(
70+
["task_id"],
71+
["task.id"],
72+
name=op.f("fk_optimization_task_id_task"),
73+
ondelete="CASCADE",
74+
),
75+
sa.PrimaryKeyConstraint("id", name=op.f("pk_optimization")),
4476
)
45-
op.create_index('ix_optimization_started_at', 'optimization', ['started_at'], unique=False)
46-
op.create_index('ix_optimization_status', 'optimization', ['status'], unique=False)
47-
op.create_index('ix_optimization_task_id', 'optimization', ['task_id'], unique=False)
77+
op.create_index("ix_optimization_started_at", "optimization", ["started_at"], unique=False)
78+
op.create_index("ix_optimization_status", "optimization", ["status"], unique=False)
79+
op.create_index("ix_optimization_task_id", "optimization", ["task_id"], unique=False)
4880
# ### end Alembic commands ###
4981

5082

5183
def downgrade() -> None:
5284
"""Downgrade schema."""
5385
# ### commands auto generated by Alembic - please adjust! ###
54-
op.drop_index('ix_optimization_task_id', table_name='optimization')
55-
op.drop_index('ix_optimization_status', table_name='optimization')
56-
op.drop_index('ix_optimization_started_at', table_name='optimization')
57-
op.drop_table('optimization')
86+
op.drop_index("ix_optimization_task_id", table_name="optimization")
87+
op.drop_index("ix_optimization_status", table_name="optimization")
88+
op.drop_index("ix_optimization_started_at", table_name="optimization")
89+
op.drop_table("optimization")
90+
bind = op.get_bind()
91+
optimization_status_enum.drop(bind, checkfirst=True)
5892
# ### end Alembic commands ###

backend/migrations/versions/7a8b9c0d1e2f_add_execution_result_table.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
branch_labels: str | Sequence[str] | None = None
1818
depends_on: str | Sequence[str] | None = None
1919
finish_reason_enum = postgresql.ENUM(
20-
"STOP",
21-
"LENGTH",
22-
"TOOL_CALLS",
23-
"CONTENT_FILTER",
24-
"FUNCTION_CALL",
25-
"ERROR",
20+
"stop",
21+
"length",
22+
"tool_calls",
23+
"content_filter",
24+
"function_call",
25+
"error",
2626
name="finish_reason",
2727
create_type=False,
2828
)

backend/migrations/versions/cb5cec1b033d_add_grader_and_grade.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020

2121
score_type_enum = postgresql.ENUM(
22-
"FLOAT",
23-
"BOOLEAN",
22+
"float",
23+
"boolean",
2424
name="score_type",
2525
create_type=False,
2626
)

backend/migrations/versions/e85591d36b7d_evaluation_and_testing.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919

2020

2121
evaluation_status_enum = postgresql.ENUM(
22-
"PENDING",
23-
"RUNNING",
24-
"COMPLETED",
25-
"FAILED",
22+
"pending",
23+
"running",
24+
"completed",
25+
"failed",
2626
name="evaluation_status",
2727
create_type=False,
2828
)

0 commit comments

Comments
 (0)