Switch usage/period reads to kernel_attached_devices and drop the kernels JSONB column
- Dominant language
- Python
- Stars
- 670
- Forks
- 183
- Avg merge
- 15h 13m
- Merged PRs (30d)
- 368
Description
Move the remaining JSONB consumers to the tables, then drop the source column.
Scope:
- models/resource_usage.py (device_type, smp, gpu_mem_allocated aggregation) and repositories/group/db_source/db_source.py: replace the nested nmget reads of data.smp / data.mem on kernels.attached_devices with reads from kernel_devices joined with devices (model_name from the entity table, capacity lookup by name via the entry models).
- Drop the kernels.attached_devices column in a follow-up migration once no readers remain.
- Optionally drop the dead sessions.attached_devices column in the same migration: it exists in the DB from the original session-table migration but is unmapped in SessionRow and has no readers.
Requires the backfill (from the tables task) so historical kernels are covered before the switch.
Success Criteria
- [ ] usage/period results (device_type, smp, gpu_mem_allocated) are unchanged for the same underlying data
- [ ] group usage aggregation returns the same results as before
- [ ] kernels.attached_devices is dropped and no code references remain
- [ ] pants test passes for affected packages
JIRA Issue: BA-7181
Contributor guide
Research direction
Start with models/resource_usage.py and repositories/group/db_source/db_source.py, then review the tables-task backfill and related migrations before changing the remaining nested reads. Run the affected package tests with Pants. Done means usage and group aggregation results are unchanged, historical data is covered, and no references to kernels.attached_devices remain after the migration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend, databases
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100