lablup / lablup/backend.ai

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

Open
#11,336 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
670
Forks
183
Avg merge
15h 13m
Merged PRs (30d)
368

Description

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

Contributor guide

Open the contributing guide

Research direction

Start by reading src/ai/backend/manager/exceptions.py:ErrorDetail and the existing DTO exports under src/ai/backend/common/dto/manager/v2/, then inspect tests/common/dto/manager/v2/ for round-trip conventions. Done means the model is importable, parses all four branches and both error shapes, the representative tests pass, and Pants quality gates pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend-api-design, testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
62/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.