diff --git a/src/dstack/_internal/core/compatibility/runs.py b/src/dstack/_internal/core/compatibility/runs.py index 1deea7ee02..e88dda62c9 100644 --- a/src/dstack/_internal/core/compatibility/runs.py +++ b/src/dstack/_internal/core/compatibility/runs.py @@ -3,7 +3,16 @@ from dstack._internal.core.models.common import IncludeExcludeDictType, IncludeExcludeSetType from dstack._internal.core.models.configurations import ServiceConfiguration from dstack._internal.core.models.runs import ApplyRunPlanInput, JobSpec, JobSubmission, RunSpec -from dstack._internal.server.schemas.runs import GetRunPlanRequest +from dstack._internal.server.schemas.runs import GetRunPlanRequest, ListRunsRequest + + +def get_list_runs_excludes(list_runs_request: ListRunsRequest) -> IncludeExcludeSetType: + excludes = set() + if list_runs_request.include_jobs: + excludes.add("include_jobs") + if list_runs_request.job_submissions_limit is None: + excludes.add("job_submissions_limit") + return excludes def get_apply_plan_excludes(plan: ApplyRunPlanInput) -> Optional[IncludeExcludeDictType]: diff --git a/src/dstack/api/_public/runs.py b/src/dstack/api/_public/runs.py index feeacbe63f..0ff0d7c160 100644 --- a/src/dstack/api/_public/runs.py +++ b/src/dstack/api/_public/runs.py @@ -748,7 +748,7 @@ def list(self, all: bool = False, limit: Optional[int] = None) -> List[Run]: repo_id=None, only_active=only_active, limit=limit or 100, - job_submissions_limit=1, # no need to return more than 1 submission per job + # TODO: Pass job_submissions_limit=1 in 0.20 ) if only_active and len(runs) == 0: runs = self._api_client.runs.list( diff --git a/src/dstack/api/server/_runs.py b/src/dstack/api/server/_runs.py index 4e80321ca4..745ce9c782 100644 --- a/src/dstack/api/server/_runs.py +++ b/src/dstack/api/server/_runs.py @@ -4,7 +4,11 @@ from pydantic import parse_obj_as -from dstack._internal.core.compatibility.runs import get_apply_plan_excludes, get_get_plan_excludes +from dstack._internal.core.compatibility.runs import ( + get_apply_plan_excludes, + get_get_plan_excludes, + get_list_runs_excludes, +) from dstack._internal.core.models.runs import ( ApplyRunPlanInput, Run, @@ -48,7 +52,9 @@ def list( limit=limit, ascending=ascending, ) - resp = self._request("/api/runs/list", body=body.json()) + resp = self._request( + "/api/runs/list", body=body.json(exclude=get_list_runs_excludes(body)) + ) return parse_obj_as(List[Run.__response__], resp.json()) def get(self, project_name: str, run_name: str) -> Run: