Skip to content

Commit f6bd077

Browse files
jopemachineclaude
andcommitted
fix(BA-6887): reference the real from_status/to_status columns in kernel history conditions
KernelSchedulingHistoryConditions.by_from_phase/by_to_phase referenced KernelSchedulingHistoryRow.from_phase and .to_phase. Those columns exist under different names: the table defines from_status and to_status, so either factory would have raised AttributeError once its condition was evaluated. The names drifted from an incomplete rename. BA-3061 first created kernel_scheduling_history with from_phase/to_phase columns. BA-3062 then renamed them to from_status/to_status by editing that not-yet-released migration in place, but the query conditions added in the same change kept the old names. The stale reference later survived the move from repositories/scheduling_history/options.py into this module (BA-5127). Two things kept it hidden: nothing calls either factory yet, so the closure was never evaluated; and the cast() wrapper kept the bad attribute access away from the type checker. Rename to by_from_status/by_to_status to match both the column names and the equivalent session factories, and drop the now-unneeded cast(). Renaming outright is safe as there are no callers. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 5c2b415 commit f6bd077

2 files changed

Lines changed: 5 additions & 10 deletions

File tree

changes/12857.fix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Point the kernel scheduling-history query conditions at the `from_status` / `to_status` columns the table actually defines, instead of the pre-rename `from_phase` / `to_phase` names.

src/ai/backend/manager/models/scheduling_history/conditions.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -422,22 +422,16 @@ def inner() -> sa.sql.expression.ColumnElement[bool]:
422422
return inner
423423

424424
@staticmethod
425-
def by_from_phase(phase: KernelSchedulingPhase) -> QueryCondition:
425+
def by_from_status(phase: KernelSchedulingPhase) -> QueryCondition:
426426
def inner() -> sa.sql.expression.ColumnElement[bool]:
427-
return cast(
428-
sa.sql.expression.ColumnElement[bool],
429-
KernelSchedulingHistoryRow.from_phase == str(phase),
430-
)
427+
return KernelSchedulingHistoryRow.from_status == str(phase)
431428

432429
return inner
433430

434431
@staticmethod
435-
def by_to_phase(phase: KernelSchedulingPhase) -> QueryCondition:
432+
def by_to_status(phase: KernelSchedulingPhase) -> QueryCondition:
436433
def inner() -> sa.sql.expression.ColumnElement[bool]:
437-
return cast(
438-
sa.sql.expression.ColumnElement[bool],
439-
KernelSchedulingHistoryRow.to_phase == str(phase),
440-
)
434+
return KernelSchedulingHistoryRow.to_status == str(phase)
441435

442436
return inner
443437

0 commit comments

Comments
 (0)