Skip to content

feat(DAH-2254): surface GPU splitting in lium CLI/SDK - #93

Open
fortunelucky777 wants to merge 2 commits into
mainfrom
feat/DAH-2254-sdk-widen-opt-in
Open

feat(DAH-2254): surface GPU splitting in lium CLI/SDK#93
fortunelucky777 wants to merge 2 commits into
mainfrom
feat/DAH-2254-sdk-widen-opt-in

Conversation

@fortunelucky777

Copy link
Copy Markdown
Collaborator

DAH-2254 — Surface GPU splitting in lium CLI/SDK

Summary

  • ExecutorInfo Pydantic model gains min_gpu_count_for_rental: int | None and available_gpu_count: int | None. Both pre-existing on the backend payload — this PR just deserializes them.
  • Client.ls(widen_for_splitting: bool = False) — opt-in widen. When True with gpu_count=N set, also returns splittable nodes where min_gpu_count_for_rental ≤ N ≤ available_gpu_count. Default OFF preserves SDK semver — third-party agent code that calls Lium().ls(gpu_count=1) keeps strict semantics.
  • lium ls --count N (the user-facing CLI) passes widen_for_splitting=True so the marketplace UI and the CLI agree.
  • @machine("XxY") decorator unchanged — it calls sdk.ls() with no kwargs at `decorators.py:49`, so the widen path never fires. A comment block at `decorators.py:43-48` documents this for future editors.
  • Rich-table Config column gains ↯ from N suffix on splittable rows (mirrors the existing (DinD) suffix pattern).
  • lium ls --format json exposes min_gpu_count_for_rental so AI-agent consumers can decide programmatically.
  • Version bump 0.0.24 → 0.0.25, matched in pyproject.toml + lium/__about__.py (release workflow cross-checks).

Files

  • lium/sdk/models.py — two new optional fields on ExecutorInfo
  • lium/sdk/client.py_is_splittable_for_count predicate helper (reciprocal-parity comment with frontend) + widen_for_splitting kwarg + payload deserialization in _dict_to_executor_info
  • lium/sdk/decorators.py — clarifying comment above sdk.ls() call
  • lium/cli/ls/actions.py — CLI passes widen_for_splitting=True
  • lium/cli/ls/command.py--count help text updated
  • lium/cli/ls/display.py — Rich-table marker + JSON field
  • pyproject.toml, lium/__about__.py — version bump
  • test/fixtures/splittable_executors.json (new) — shared fixture (byte-identical with frontend repo)
  • test/test_client_ls_widen.py (new) — 5 tests covering widen=True/False, default-off invariant, JSON field, Rich-table marker

Acceptance criteria

Test plan

  • `pytest test/test_client_ls_widen.py` — 5/5 passing
  • `python3 -c "import inspect; from lium.sdk.client import Client; assert inspect.signature(Client.ls).parameters['widen_for_splitting'].default is False"` — Gate D OK
  • Source grep confirms `widen_for_splitting: bool = False` at `lium/sdk/client.py:506`
  • Manual smoke: `lium ls` against staging, verify marker on a known splittable node; lium ls --count 1 returns native 1xGPU + splittable bigger nodes with min ≤ 1; lium ls --format json | jq '.[0].min_gpu_count_for_rental' returns the value.

Companion PR

Datura-ai/lium-io-frontend#204 — `feat/2254-gpu-splitting-filter` surfaces the same signal in the marketplace UI. The frontend's `matchesGpuCountFilter` predicate and this PR's `_is_splittable_for_count` predicate share a byte-identical JSON fixture; reciprocal code comments at `PodFiltersProvider.tsx` and `client.py` link them.

Source artifacts

  • Spec: `.omc/specs/deep-interview-dah-2254-gpu-splitting.md` (deep-interview final ambiguity 12.5%)
  • Plan: `.omc/plans/dah-2254-gpu-splitting.md` (Critic-APPROVED consensus, 14/14 ACs traced)

Notes for reviewer

  • Client.ls() default OFF is deliberate. SDK consumers that call Lium().ls(gpu_count=1) programmatically (AI agents per spec) get the same result-set as before this PR. Only lium ls opts in; only the CLI passes widen_for_splitting=True.
  • If you ever add gpu_count=... to the sdk.ls() call in decorators.py, decide explicitly about widen_for_splitting — the comment block flags this.
  • The shared fixture path is test/fixtures/splittable_executors.json (mirrored at src/contexts/__fixtures__/splittable-executors.json in the frontend repo). Any change to one must be made byte-for-byte to the other; Gate C diff catches drift.

- ExecutorInfo: add min_gpu_count_for_rental and available_gpu_count fields
- _dict_to_executor_info: wire both new fields from API dict
- _is_splittable_for_count: module-level predicate helper (parity with FE)
- Lium.ls(): add widen_for_splitting kwarg (default False per D2a)
- decorators.py: clarifying comment — @machine stays strict
- cli/ls/actions.py: pass widen_for_splitting=True (CLI opt-in only)
- cli/ls/command.py: update --count help string
- cli/ls/display.py: append '↯ from N' in _cfg, add field to compact_executor
- test/fixtures/splittable_executors.json: byte-identical twin of frontend fixture
- test/test_client_ls_widen.py: 5 tests covering widen truth table, default-off,
  compact_executor field round-trip, and _cfg '↯ from N' marker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant