Switch prometheus_query_preset update DTO to Unset
- Dominant language
- Python
- Stars
- 670
- Forks
- 183
- Avg merge
- 15h 13m
- Merged PRs (30d)
- 368
Description
## Scope
|Target|Change|
|---|---|
|DTO|`common/dto/manager/v2/prometheus_query_preset/request.py` — 3 fields|
|Adapter|`manager/api/adapters/prometheus_query_preset/adapter.py` — 3 branches; `manager/api/adapters/idle_checker/adapter.py` — 1 branch|
## Note
- BA-7722 (#14312) migrated only the legacy `common/dto/manager/prometheus_query_preset/request.py`. The 3 fields in the DTO above remain.
## Common work
- DTO: `X | Sentinel | None = Field(default=SENTINEL)` → `X | None | Unset = Field(default=UNSET)`, importing from `ai.backend.common.tristate.unset`
- Adapter: `TriState.from_unset` for nullable columns, `OptionalState.from_unset` for non-nullable columns
- Unify `Field(description=...)` wording to "Omit to leave unchanged; null clears." (drop "null clears" for non-nullable fields)
- Tests: `SENTINEL` → `UNSET`, `Sentinel` → `Unset`
- News fragment `changes/.enhance.md`
## Done when
- Zero `Sentinel` / `SENTINEL` references remain in this domain
- Verified with `./bai admin prometheus-query-preset update`: field omitted → unchanged, `null` → cleared, value → updated
JIRA Issue: BA-7744
Contributor guide
Research direction
Start with common/dto/manager/v2/prometheus_query_preset/request.py, then trace the three update branches in manager/api/adapters/prometheus_query_preset/adapter.py and the related branch in manager/api/adapters/idle_checker/adapter.py. Use the existing tri-state patterns and verify ./bai admin prometheus-query-preset update for omitted, null, and value inputs; done means no Sentinel or SENTINEL references remain in this domain.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, backend
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100