Skip to content

Define KernelStatusData Pydantic model in common/dto/manager/v2/ #11336

@rapsealk

Description

@rapsealk

Sub-issue of #679.

Goal

Introduce a typed Pydantic model representing the unified shape of status_data for kernels and sessions, covering all four branches: kernel, session, scheduler, and error.

Scope

  • New file under src/ai/backend/common/dto/manager/v2/ (likely status_data.py or per-entity files in kernel/ and session/).
  • Pydantic v2 model(s):
    • KernelStatusBranch{exit_code: int}
    • SessionStatusBranch{status: str}
    • SchedulingPredicateModel{name: str, msg: str | None}
    • SchedulerStatusBranch{msg, retries, last_try, passed_predicates: list, failed_predicates: list}
    • ErrorDetailModel — typed error detail (mirror of manager/exceptions.py:ErrorDetail)
    • ErrorStatusBranch{errors: list[ErrorDetailModel]} (the normalized list shape; see #(step-2 sub-issue))
    • Top-level KernelStatusData aggregating all branches as optional fields.
  • Unit tests under tests/common/dto/manager/v2/ validating round-trip parse/serialize for representative payloads.

Non-goals

  • This issue does NOT change wire format on the producer side. That's the next sub-issue.
  • No changes to v2 REST/GraphQL DTOs to expose status_data yet.

Acceptance criteria

  • Pydantic model importable from ai.backend.common.dto.manager.v2.
  • Model parses both legacy single-error shape and new errors-list shape (tolerant reader).
  • Tests cover all four branches and both error shapes.
  • Pants quality gates pass.

JIRA Issue: BA-5864

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No fields configured for Story.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions