Skip to content

Commit 7936b35

Browse files
committed
Fix job_submissions_limit backward compatibility
1 parent 82e4a80 commit 7936b35

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

src/dstack/_internal/core/compatibility/runs.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,16 @@
33
from dstack._internal.core.models.common import IncludeExcludeDictType, IncludeExcludeSetType
44
from dstack._internal.core.models.configurations import ServiceConfiguration
55
from dstack._internal.core.models.runs import ApplyRunPlanInput, JobSpec, JobSubmission, RunSpec
6-
from dstack._internal.server.schemas.runs import GetRunPlanRequest
6+
from dstack._internal.server.schemas.runs import GetRunPlanRequest, ListRunsRequest
7+
8+
9+
def get_list_runs_excludes(list_runs_request: ListRunsRequest) -> IncludeExcludeSetType:
10+
excludes = set()
11+
if list_runs_request.include_jobs:
12+
excludes.add("include_jobs")
13+
if list_runs_request.job_submissions_limit is None:
14+
excludes.add("job_submissions_limit")
15+
return excludes
716

817

918
def get_apply_plan_excludes(plan: ApplyRunPlanInput) -> Optional[IncludeExcludeDictType]:

src/dstack/api/_public/runs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ def list(self, all: bool = False, limit: Optional[int] = None) -> List[Run]:
748748
repo_id=None,
749749
only_active=only_active,
750750
limit=limit or 100,
751-
job_submissions_limit=1, # no need to return more than 1 submission per job
751+
# TODO: Pass job_submissions_limit=1 in 0.20
752752
)
753753
if only_active and len(runs) == 0:
754754
runs = self._api_client.runs.list(

src/dstack/api/server/_runs.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44

55
from pydantic import parse_obj_as
66

7-
from dstack._internal.core.compatibility.runs import get_apply_plan_excludes, get_get_plan_excludes
7+
from dstack._internal.core.compatibility.runs import (
8+
get_apply_plan_excludes,
9+
get_get_plan_excludes,
10+
get_list_runs_excludes,
11+
)
812
from dstack._internal.core.models.runs import (
913
ApplyRunPlanInput,
1014
Run,
@@ -48,7 +52,9 @@ def list(
4852
limit=limit,
4953
ascending=ascending,
5054
)
51-
resp = self._request("/api/runs/list", body=body.json())
55+
resp = self._request(
56+
"/api/runs/list", body=body.json(exclude=get_list_runs_excludes(body))
57+
)
5258
return parse_obj_as(List[Run.__response__], resp.json())
5359

5460
def get(self, project_name: str, run_name: str) -> Run:

0 commit comments

Comments
 (0)