lablup / lablup/backend.ai

Add AttachedDeviceEntry and DeviceCapacityEntry models with legacy-map projection

Open
#13,448 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

Add typed entry models for kernel attached devices under manager/data/kernel/types.py, following the ResourceSlotEntry precedent (common/types.py): a list-friendly typed form of a legacy map-shaped structure with a projection helper.

Scope:
- DeviceCapacityEntry: name (open key set: smp, mem, cores, ...) + value as a decimal string (ResourceSlotEntry.quantity precedent). Values are constrained to numerics per the declared ComputedDeviceCapacity contract; non-numeric values are handled leniently (skipped or stringified) without raising.
- AttachedDeviceEntry: device_name (top-level map key such as cuda or cpu), device_id, model_name, capacities (list of DeviceCapacityEntry projected from the raw data map).
- Projection classmethod from_attached_devices(raw) that flattens the legacy nested shape (device_name to list of DeviceModelInfo) into a flat entry list; entries without device_id are skipped.
- KernelCreationInfo.get_attached_devices() in data/sokovan/lifecycle.py returning the entry list, following the get_resource_allocations precedent.

No reverse converter (entries back to the legacy map) is needed: the dual-write path keeps writing the original payload as-is.

Success Criteria
- [ ] projecting a cuda-shaped payload (smp, mem) yields entries with capacities named smp and mem
- [ ] projecting a cpu-shaped payload (cores) and an empty data map both work
- [ ] non-numeric capacity values are handled leniently without raising
- [ ] device entries missing device_id are skipped
- [ ] pants test passes for affected packages

JIRA Issue: BA-7177

Contributor guide

Open the contributing guide

Research direction

Start with manager/data/kernel/types.py and compare ResourceSlotEntry in common/types.py, then inspect KernelCreationInfo.get_resource_allocations() in data/sokovan/lifecycle.py. Use the stated CUDA, CPU, empty-map, non-numeric, and missing-device_id cases to guide the projection behavior, and run pants tests for the affected packages to verify completion.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.