lablup / lablup/backend.ai

Add usage ratio calculation against total_resource_slots

Open
#9,731 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
670
Forks
183
Avg merge
17h 7m
Merged PRs (30d)
358

Description

Extend active resource overview to include usage ratio (occupied / total) per slot.

DomainRow and GroupRow both have total_resource_slots: ResourceSlot field representing the configured resource limit. This story adds a ratio calculation comparing current active allocation against these limits.

## Scope

### data (data/resource_slot/types.py)
- Extend or add ActiveResourceOverviewWithRatio:
- slots: list[SlotQuantity] (occupied)
- total_slots: list[SlotQuantity] (from total_resource_slots)
- usage_ratios: list[SlotUsageRatio] (slot_name, occupied, total, ratio)
- session_count: int

### service (services/resource_slot/service.py)
- get_domain_resource_overview_with_ratio: fetches both active overview + domain's total_resource_slots
- get_project_resource_overview_with_ratio: fetches both active overview + project's total_resource_slots
- Computes ratio = occupied / total per slot (None if total is 0 or slot not in total)

### GQL + REST
- Add optional include_ratio parameter or separate field
- Extend response types with usage_ratio entries

## Success Criteria
- [ ] usage_ratio correctly computes occupied/total for each slot present in both occupied and total
- [ ] slots in occupied but not in total show ratio as null
- [ ] slots with total=0 show ratio as null (no division by zero)
- [ ] total_slots reflects domain/project total_resource_slots accurately
- [ ] pants check passes for affected packages

JIRA Issue: BA-4918

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.