Skip to content

Commit 373fb65

Browse files
dstack offer fixes: (#3038)
- [x] Added older-server compatibility (to exclude `repos` - [x] Use backend from offer
1 parent 1851c28 commit 373fb65

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from typing import Optional
2+
3+
from dstack._internal.core.compatibility.runs import get_run_spec_excludes
4+
from dstack._internal.core.models.common import IncludeExcludeDictType
5+
from dstack._internal.server.schemas.gpus import ListGpusRequest
6+
7+
8+
def get_list_gpus_excludes(request: ListGpusRequest) -> Optional[IncludeExcludeDictType]:
9+
list_gpus_excludes: IncludeExcludeDictType = {}
10+
run_spec_excludes = get_run_spec_excludes(request.run_spec)
11+
if run_spec_excludes is not None:
12+
list_gpus_excludes["run_spec"] = run_spec_excludes
13+
return list_gpus_excludes

src/dstack/_internal/server/services/gpus.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ def _process_offers_into_backend_gpus(
7979
"""Transforms raw offers into a structured list of BackendGpus, aggregating GPU info."""
8080
backend_data: Dict[BackendType, Dict] = {}
8181

82-
for backend, offer in offers:
83-
backend_type = backend.TYPE
82+
for _, offer in offers:
83+
backend_type = offer.backend
8484
if backend_type not in backend_data:
8585
backend_data[backend_type] = {"gpus": {}, "regions": set()}
8686

src/dstack/api/server/_gpus.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from pydantic import parse_obj_as
44

5+
from dstack._internal.core.compatibility.gpus import get_list_gpus_excludes
56
from dstack._internal.core.models.runs import RunSpec
67
from dstack._internal.server.schemas.gpus import GpuGroup, ListGpusRequest, ListGpusResponse
78
from dstack.api.server._group import APIClientGroup
@@ -17,6 +18,6 @@ def list_gpus(
1718
body = ListGpusRequest(run_spec=run_spec, group_by=group_by)
1819
resp = self._request(
1920
f"/api/project/{project_name}/gpus/list",
20-
body=body.json(),
21+
body=body.json(exclude=get_list_gpus_excludes(body)),
2122
)
2223
return parse_obj_as(ListGpusResponse, resp.json()).gpus

0 commit comments

Comments
 (0)