dstack 0.18.44__py3-none-any.whl → 0.19.0rc1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dstack/_internal/cli/commands/gateway.py +15 -3
- dstack/_internal/cli/commands/logs.py +0 -22
- dstack/_internal/cli/commands/stats.py +8 -17
- dstack/_internal/cli/main.py +1 -5
- dstack/_internal/cli/services/configurators/fleet.py +4 -39
- dstack/_internal/cli/services/configurators/run.py +22 -21
- dstack/_internal/cli/services/profile.py +34 -83
- dstack/_internal/cli/utils/gateway.py +1 -1
- dstack/_internal/core/backends/__init__.py +56 -39
- dstack/_internal/core/backends/aws/__init__.py +0 -25
- dstack/_internal/core/backends/aws/auth.py +1 -10
- dstack/_internal/core/backends/aws/backend.py +26 -0
- dstack/_internal/core/backends/aws/compute.py +20 -45
- dstack/_internal/{server/services/backends/configurators/aws.py → core/backends/aws/configurator.py} +46 -85
- dstack/_internal/core/backends/aws/models.py +135 -0
- dstack/_internal/core/backends/aws/resources.py +1 -1
- dstack/_internal/core/backends/azure/__init__.py +0 -20
- dstack/_internal/core/backends/azure/auth.py +2 -11
- dstack/_internal/core/backends/azure/backend.py +21 -0
- dstack/_internal/core/backends/azure/compute.py +13 -27
- dstack/_internal/{server/services/backends/configurators/azure.py → core/backends/azure/configurator.py} +141 -210
- dstack/_internal/core/backends/azure/models.py +89 -0
- dstack/_internal/core/backends/base/__init__.py +0 -12
- dstack/_internal/core/backends/base/backend.py +18 -0
- dstack/_internal/core/backends/base/compute.py +153 -33
- dstack/_internal/core/backends/base/configurator.py +105 -0
- dstack/_internal/core/backends/base/models.py +14 -0
- dstack/_internal/core/backends/configurators.py +138 -0
- dstack/_internal/core/backends/cudo/__init__.py +0 -15
- dstack/_internal/core/backends/cudo/backend.py +16 -0
- dstack/_internal/core/backends/cudo/compute.py +8 -26
- dstack/_internal/core/backends/cudo/configurator.py +72 -0
- dstack/_internal/core/backends/cudo/models.py +37 -0
- dstack/_internal/core/backends/datacrunch/__init__.py +0 -15
- dstack/_internal/core/backends/datacrunch/backend.py +16 -0
- dstack/_internal/core/backends/datacrunch/compute.py +8 -25
- dstack/_internal/core/backends/datacrunch/configurator.py +66 -0
- dstack/_internal/core/backends/datacrunch/models.py +38 -0
- dstack/_internal/core/{models/backends/dstack.py → backends/dstack/models.py} +7 -7
- dstack/_internal/core/backends/gcp/__init__.py +0 -16
- dstack/_internal/core/backends/gcp/auth.py +2 -11
- dstack/_internal/core/backends/gcp/backend.py +17 -0
- dstack/_internal/core/backends/gcp/compute.py +13 -43
- dstack/_internal/{server/services/backends/configurators/gcp.py → core/backends/gcp/configurator.py} +46 -103
- dstack/_internal/core/backends/gcp/models.py +125 -0
- dstack/_internal/core/backends/kubernetes/__init__.py +0 -15
- dstack/_internal/core/backends/kubernetes/backend.py +16 -0
- dstack/_internal/core/backends/kubernetes/compute.py +16 -5
- dstack/_internal/core/backends/kubernetes/configurator.py +55 -0
- dstack/_internal/core/backends/kubernetes/models.py +72 -0
- dstack/_internal/core/backends/lambdalabs/__init__.py +0 -16
- dstack/_internal/core/backends/lambdalabs/backend.py +17 -0
- dstack/_internal/core/backends/lambdalabs/compute.py +7 -28
- dstack/_internal/core/backends/lambdalabs/configurator.py +82 -0
- dstack/_internal/core/backends/lambdalabs/models.py +37 -0
- dstack/_internal/core/backends/local/__init__.py +0 -13
- dstack/_internal/core/backends/local/backend.py +14 -0
- dstack/_internal/core/backends/local/compute.py +16 -2
- dstack/_internal/core/backends/models.py +128 -0
- dstack/_internal/core/backends/oci/__init__.py +0 -15
- dstack/_internal/core/backends/oci/auth.py +1 -5
- dstack/_internal/core/backends/oci/backend.py +16 -0
- dstack/_internal/core/backends/oci/compute.py +9 -23
- dstack/_internal/{server/services/backends/configurators/oci.py → core/backends/oci/configurator.py} +40 -85
- dstack/_internal/core/{models/backends/oci.py → backends/oci/models.py} +24 -25
- dstack/_internal/core/backends/oci/region.py +1 -1
- dstack/_internal/core/backends/runpod/__init__.py +0 -15
- dstack/_internal/core/backends/runpod/backend.py +16 -0
- dstack/_internal/core/backends/runpod/compute.py +7 -3
- dstack/_internal/core/backends/runpod/configurator.py +59 -0
- dstack/_internal/core/backends/runpod/models.py +54 -0
- dstack/_internal/core/backends/template/__init__.py +0 -0
- dstack/_internal/core/backends/tensordock/__init__.py +0 -15
- dstack/_internal/core/backends/tensordock/backend.py +16 -0
- dstack/_internal/core/backends/tensordock/compute.py +8 -27
- dstack/_internal/core/backends/tensordock/configurator.py +68 -0
- dstack/_internal/core/backends/tensordock/models.py +38 -0
- dstack/_internal/core/backends/vastai/__init__.py +0 -15
- dstack/_internal/core/backends/vastai/backend.py +16 -0
- dstack/_internal/core/backends/vastai/compute.py +2 -2
- dstack/_internal/core/backends/vastai/configurator.py +66 -0
- dstack/_internal/core/backends/vastai/models.py +37 -0
- dstack/_internal/core/backends/vultr/__init__.py +0 -15
- dstack/_internal/core/backends/vultr/backend.py +16 -0
- dstack/_internal/core/backends/vultr/compute.py +10 -24
- dstack/_internal/core/backends/vultr/configurator.py +64 -0
- dstack/_internal/core/backends/vultr/models.py +34 -0
- dstack/_internal/core/models/backends/__init__.py +0 -184
- dstack/_internal/core/models/backends/base.py +0 -19
- dstack/_internal/core/models/configurations.py +20 -15
- dstack/_internal/core/models/envs.py +4 -3
- dstack/_internal/core/models/fleets.py +17 -22
- dstack/_internal/core/models/gateways.py +3 -3
- dstack/_internal/core/models/instances.py +24 -0
- dstack/_internal/core/models/profiles.py +41 -46
- dstack/_internal/core/models/projects.py +1 -1
- dstack/_internal/core/models/repos/base.py +0 -5
- dstack/_internal/core/models/repos/local.py +3 -3
- dstack/_internal/core/models/repos/remote.py +26 -12
- dstack/_internal/core/models/repos/virtual.py +1 -1
- dstack/_internal/core/models/resources.py +45 -76
- dstack/_internal/core/models/runs.py +17 -19
- dstack/_internal/core/models/volumes.py +1 -3
- dstack/_internal/core/services/profiles.py +7 -16
- dstack/_internal/core/services/repos.py +0 -4
- dstack/_internal/server/app.py +0 -3
- dstack/_internal/server/background/tasks/process_gateways.py +4 -8
- dstack/_internal/server/background/tasks/process_instances.py +14 -9
- dstack/_internal/server/background/tasks/process_metrics.py +1 -1
- dstack/_internal/server/background/tasks/process_placement_groups.py +4 -1
- dstack/_internal/server/background/tasks/process_prometheus_metrics.py +1 -1
- dstack/_internal/server/background/tasks/process_running_jobs.py +14 -5
- dstack/_internal/server/background/tasks/process_submitted_jobs.py +16 -37
- dstack/_internal/server/background/tasks/process_volumes.py +5 -2
- dstack/_internal/server/migrations/versions/7bc2586e8b9e_make_instancemodel_pool_id_optional.py +36 -0
- dstack/_internal/server/migrations/versions/bc8ca4a505c6_store_backendtype_as_string.py +171 -0
- dstack/_internal/server/models.py +48 -9
- dstack/_internal/server/routers/backends.py +14 -23
- dstack/_internal/server/routers/instances.py +3 -4
- dstack/_internal/server/routers/metrics.py +10 -8
- dstack/_internal/server/routers/prometheus.py +1 -1
- dstack/_internal/server/routers/repos.py +1 -2
- dstack/_internal/server/routers/runs.py +13 -59
- dstack/_internal/server/schemas/gateways.py +14 -23
- dstack/_internal/server/schemas/projects.py +7 -2
- dstack/_internal/server/schemas/repos.py +2 -38
- dstack/_internal/server/schemas/runner.py +1 -0
- dstack/_internal/server/schemas/runs.py +1 -24
- dstack/_internal/server/services/backends/__init__.py +85 -158
- dstack/_internal/server/services/config.py +52 -576
- dstack/_internal/server/services/fleets.py +8 -103
- dstack/_internal/server/services/gateways/__init__.py +12 -4
- dstack/_internal/server/services/{pools.py → instances.py} +22 -329
- dstack/_internal/server/services/jobs/__init__.py +9 -6
- dstack/_internal/server/services/jobs/configurators/base.py +16 -0
- dstack/_internal/server/services/jobs/configurators/dev.py +9 -1
- dstack/_internal/server/services/jobs/configurators/extensions/cursor.py +42 -0
- dstack/_internal/server/services/metrics.py +39 -13
- dstack/_internal/server/services/offers.py +1 -1
- dstack/_internal/server/services/projects.py +23 -14
- dstack/_internal/server/services/prometheus.py +176 -18
- dstack/_internal/server/services/runs.py +24 -16
- dstack/_internal/server/services/volumes.py +8 -4
- dstack/_internal/server/statics/index.html +1 -1
- dstack/_internal/server/statics/{main-4eb116b97819badd1e2c.js → main-4fd5a4770eff59325ee3.js} +7 -7
- dstack/_internal/server/statics/{main-4eb116b97819badd1e2c.js.map → main-4fd5a4770eff59325ee3.js.map} +1 -1
- dstack/_internal/server/testing/common.py +58 -32
- dstack/_internal/utils/json_schema.py +6 -0
- dstack/_internal/utils/ssh.py +2 -1
- dstack/api/__init__.py +4 -0
- dstack/api/_public/__init__.py +16 -20
- dstack/api/_public/backends.py +1 -1
- dstack/api/_public/repos.py +36 -36
- dstack/api/_public/runs.py +167 -83
- dstack/api/server/__init__.py +11 -13
- dstack/api/server/_backends.py +12 -16
- dstack/api/server/_fleets.py +15 -57
- dstack/api/server/_gateways.py +3 -14
- dstack/api/server/_repos.py +1 -4
- dstack/api/server/_runs.py +21 -100
- dstack/api/server/_volumes.py +10 -5
- dstack/version.py +1 -1
- {dstack-0.18.44.dist-info → dstack-0.19.0rc1.dist-info}/METADATA +1 -1
- {dstack-0.18.44.dist-info → dstack-0.19.0rc1.dist-info}/RECORD +218 -204
- tests/_internal/cli/services/configurators/test_profile.py +6 -6
- tests/_internal/core/backends/aws/test_configurator.py +35 -0
- tests/_internal/core/backends/aws/test_resources.py +1 -1
- tests/_internal/core/backends/azure/test_configurator.py +61 -0
- tests/_internal/core/backends/cudo/__init__.py +0 -0
- tests/_internal/core/backends/cudo/test_configurator.py +37 -0
- tests/_internal/core/backends/datacrunch/__init__.py +0 -0
- tests/_internal/core/backends/datacrunch/test_configurator.py +17 -0
- tests/_internal/core/backends/gcp/test_configurator.py +42 -0
- tests/_internal/core/backends/kubernetes/test_configurator.py +43 -0
- tests/_internal/core/backends/lambdalabs/__init__.py +0 -0
- tests/_internal/core/backends/lambdalabs/test_configurator.py +38 -0
- tests/_internal/core/backends/oci/test_configurator.py +55 -0
- tests/_internal/core/backends/runpod/__init__.py +0 -0
- tests/_internal/core/backends/runpod/test_configurator.py +33 -0
- tests/_internal/core/backends/tensordock/__init__.py +0 -0
- tests/_internal/core/backends/tensordock/test_configurator.py +38 -0
- tests/_internal/core/backends/vastai/__init__.py +0 -0
- tests/_internal/core/backends/vastai/test_configurator.py +33 -0
- tests/_internal/core/backends/vultr/__init__.py +0 -0
- tests/_internal/core/backends/vultr/test_configurator.py +33 -0
- tests/_internal/server/background/tasks/test_process_gateways.py +4 -0
- tests/_internal/server/background/tasks/test_process_instances.py +49 -48
- tests/_internal/server/background/tasks/test_process_metrics.py +0 -3
- tests/_internal/server/background/tasks/test_process_placement_groups.py +2 -0
- tests/_internal/server/background/tasks/test_process_prometheus_metrics.py +0 -3
- tests/_internal/server/background/tasks/test_process_running_jobs.py +0 -21
- tests/_internal/server/background/tasks/test_process_runs.py +8 -22
- tests/_internal/server/background/tasks/test_process_submitted_jobs.py +3 -40
- tests/_internal/server/background/tasks/test_process_submitted_volumes.py +2 -0
- tests/_internal/server/background/tasks/test_process_terminating_jobs.py +10 -15
- tests/_internal/server/routers/test_backends.py +6 -764
- tests/_internal/server/routers/test_fleets.py +0 -26
- tests/_internal/server/routers/test_gateways.py +27 -3
- tests/_internal/server/routers/test_instances.py +0 -10
- tests/_internal/server/routers/test_metrics.py +27 -0
- tests/_internal/server/routers/test_projects.py +56 -0
- tests/_internal/server/routers/test_prometheus.py +116 -27
- tests/_internal/server/routers/test_repos.py +0 -15
- tests/_internal/server/routers/test_runs.py +4 -219
- tests/_internal/server/routers/test_volumes.py +2 -3
- tests/_internal/server/services/backends/__init__.py +0 -0
- tests/_internal/server/services/jobs/configurators/test_task.py +35 -0
- tests/_internal/server/services/test_config.py +7 -4
- tests/_internal/server/services/test_fleets.py +1 -4
- tests/_internal/server/services/{test_pools.py → test_instances.py} +11 -49
- tests/_internal/server/services/test_metrics.py +9 -5
- tests/_internal/server/services/test_repos.py +1 -14
- tests/_internal/server/services/test_runs.py +0 -4
- dstack/_internal/cli/commands/pool.py +0 -581
- dstack/_internal/cli/commands/run.py +0 -75
- dstack/_internal/core/backends/aws/config.py +0 -18
- dstack/_internal/core/backends/azure/config.py +0 -12
- dstack/_internal/core/backends/base/config.py +0 -5
- dstack/_internal/core/backends/cudo/config.py +0 -9
- dstack/_internal/core/backends/datacrunch/config.py +0 -9
- dstack/_internal/core/backends/gcp/config.py +0 -22
- dstack/_internal/core/backends/kubernetes/config.py +0 -6
- dstack/_internal/core/backends/lambdalabs/config.py +0 -9
- dstack/_internal/core/backends/nebius/__init__.py +0 -15
- dstack/_internal/core/backends/nebius/api_client.py +0 -319
- dstack/_internal/core/backends/nebius/compute.py +0 -220
- dstack/_internal/core/backends/nebius/config.py +0 -6
- dstack/_internal/core/backends/nebius/types.py +0 -37
- dstack/_internal/core/backends/oci/config.py +0 -6
- dstack/_internal/core/backends/runpod/config.py +0 -17
- dstack/_internal/core/backends/tensordock/config.py +0 -9
- dstack/_internal/core/backends/vastai/config.py +0 -6
- dstack/_internal/core/backends/vultr/config.py +0 -9
- dstack/_internal/core/models/backends/aws.py +0 -86
- dstack/_internal/core/models/backends/azure.py +0 -68
- dstack/_internal/core/models/backends/cudo.py +0 -43
- dstack/_internal/core/models/backends/datacrunch.py +0 -44
- dstack/_internal/core/models/backends/gcp.py +0 -67
- dstack/_internal/core/models/backends/kubernetes.py +0 -40
- dstack/_internal/core/models/backends/lambdalabs.py +0 -43
- dstack/_internal/core/models/backends/nebius.py +0 -54
- dstack/_internal/core/models/backends/runpod.py +0 -42
- dstack/_internal/core/models/backends/tensordock.py +0 -44
- dstack/_internal/core/models/backends/vastai.py +0 -43
- dstack/_internal/core/models/backends/vultr.py +0 -40
- dstack/_internal/core/models/pools.py +0 -43
- dstack/_internal/server/routers/pools.py +0 -142
- dstack/_internal/server/schemas/pools.py +0 -38
- dstack/_internal/server/services/backends/configurators/base.py +0 -72
- dstack/_internal/server/services/backends/configurators/cudo.py +0 -87
- dstack/_internal/server/services/backends/configurators/datacrunch.py +0 -79
- dstack/_internal/server/services/backends/configurators/kubernetes.py +0 -63
- dstack/_internal/server/services/backends/configurators/lambdalabs.py +0 -98
- dstack/_internal/server/services/backends/configurators/nebius.py +0 -85
- dstack/_internal/server/services/backends/configurators/runpod.py +0 -67
- dstack/_internal/server/services/backends/configurators/tensordock.py +0 -82
- dstack/_internal/server/services/backends/configurators/vastai.py +0 -80
- dstack/_internal/server/services/backends/configurators/vultr.py +0 -80
- dstack/api/_public/pools.py +0 -41
- dstack/api/_public/resources.py +0 -105
- dstack/api/server/_pools.py +0 -63
- tests/_internal/server/routers/test_pools.py +0 -612
- /dstack/_internal/{server/services/backends/configurators → core/backends/dstack}/__init__.py +0 -0
- {dstack-0.18.44.dist-info → dstack-0.19.0rc1.dist-info}/LICENSE.md +0 -0
- {dstack-0.18.44.dist-info → dstack-0.19.0rc1.dist-info}/WHEEL +0 -0
- {dstack-0.18.44.dist-info → dstack-0.19.0rc1.dist-info}/entry_points.txt +0 -0
- {dstack-0.18.44.dist-info → dstack-0.19.0rc1.dist-info}/top_level.txt +0 -0
dstack/api/server/_runs.py
CHANGED
|
@@ -1,36 +1,22 @@
|
|
|
1
1
|
from datetime import datetime
|
|
2
|
-
from typing import Any, List, Optional, Union
|
|
2
|
+
from typing import Any, Dict, List, Optional, Union
|
|
3
3
|
from uuid import UUID
|
|
4
4
|
|
|
5
5
|
from pydantic import parse_obj_as
|
|
6
6
|
|
|
7
|
-
from dstack._internal.core.models.common import is_core_model_instance
|
|
8
|
-
from dstack._internal.core.models.configurations import (
|
|
9
|
-
STRIP_PREFIX_DEFAULT,
|
|
10
|
-
DevEnvironmentConfiguration,
|
|
11
|
-
ServiceConfiguration,
|
|
12
|
-
)
|
|
13
|
-
from dstack._internal.core.models.pools import Instance
|
|
14
|
-
from dstack._internal.core.models.profiles import Profile
|
|
15
7
|
from dstack._internal.core.models.runs import (
|
|
16
8
|
ApplyRunPlanInput,
|
|
17
|
-
PoolInstanceOffers,
|
|
18
|
-
Requirements,
|
|
19
9
|
Run,
|
|
20
10
|
RunPlan,
|
|
21
11
|
RunSpec,
|
|
22
12
|
)
|
|
23
|
-
from dstack._internal.core.models.volumes import InstanceMountPoint
|
|
24
13
|
from dstack._internal.server.schemas.runs import (
|
|
25
14
|
ApplyRunPlanRequest,
|
|
26
|
-
CreateInstanceRequest,
|
|
27
15
|
DeleteRunsRequest,
|
|
28
|
-
GetOffersRequest,
|
|
29
16
|
GetRunPlanRequest,
|
|
30
17
|
GetRunRequest,
|
|
31
18
|
ListRunsRequest,
|
|
32
19
|
StopRunsRequest,
|
|
33
|
-
SubmitRunRequest,
|
|
34
20
|
)
|
|
35
21
|
from dstack.api.server._group import APIClientGroup
|
|
36
22
|
|
|
@@ -62,8 +48,7 @@ class RunsAPIClient(APIClientGroup):
|
|
|
62
48
|
|
|
63
49
|
def get(self, project_name: str, run_name: str) -> Run:
|
|
64
50
|
body = GetRunRequest(run_name=run_name)
|
|
65
|
-
|
|
66
|
-
json_body = body.json(exclude={"id"})
|
|
51
|
+
json_body = body.json()
|
|
67
52
|
resp = self._request(f"/api/project/{project_name}/runs/get", body=json_body)
|
|
68
53
|
return parse_obj_as(Run.__response__, resp.json())
|
|
69
54
|
|
|
@@ -89,14 +74,6 @@ class RunsAPIClient(APIClientGroup):
|
|
|
89
74
|
)
|
|
90
75
|
return parse_obj_as(Run.__response__, resp.json())
|
|
91
76
|
|
|
92
|
-
def submit(self, project_name: str, run_spec: RunSpec) -> Run:
|
|
93
|
-
body = SubmitRunRequest(run_spec=run_spec)
|
|
94
|
-
resp = self._request(
|
|
95
|
-
f"/api/project/{project_name}/runs/submit",
|
|
96
|
-
body=body.json(exclude=_get_run_spec_excludes(run_spec)),
|
|
97
|
-
)
|
|
98
|
-
return parse_obj_as(Run.__response__, resp.json())
|
|
99
|
-
|
|
100
77
|
def stop(self, project_name: str, runs_names: List[str], abort: bool):
|
|
101
78
|
body = StopRunsRequest(runs_names=runs_names, abort=abort)
|
|
102
79
|
self._request(f"/api/project/{project_name}/runs/stop", body=body.json())
|
|
@@ -105,91 +82,35 @@ class RunsAPIClient(APIClientGroup):
|
|
|
105
82
|
body = DeleteRunsRequest(runs_names=runs_names)
|
|
106
83
|
self._request(f"/api/project/{project_name}/runs/delete", body=body.json())
|
|
107
84
|
|
|
108
|
-
# FIXME: get_offers and create_instance do not belong runs api
|
|
109
|
-
|
|
110
|
-
def get_offers(
|
|
111
|
-
self, project_name: str, profile: Profile, requirements: Requirements
|
|
112
|
-
) -> PoolInstanceOffers:
|
|
113
|
-
body = GetOffersRequest(profile=profile, requirements=requirements)
|
|
114
|
-
resp = self._request(f"/api/project/{project_name}/runs/get_offers", body=body.json())
|
|
115
|
-
return parse_obj_as(PoolInstanceOffers.__response__, resp.json())
|
|
116
85
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
body = CreateInstanceRequest(profile=profile, requirements=requirements)
|
|
124
|
-
resp = self._request(f"/api/project/{project_name}/runs/create_instance", body=body.json())
|
|
125
|
-
return parse_obj_as(Instance.__response__, resp.json())
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
def _get_apply_plan_excludes(plan: ApplyRunPlanInput) -> Optional[dict]:
|
|
86
|
+
def _get_apply_plan_excludes(plan: ApplyRunPlanInput) -> Optional[Dict]:
|
|
87
|
+
"""
|
|
88
|
+
Returns `plan` exclude mapping to exclude certain fields from the request.
|
|
89
|
+
Use this method to exclude new fields when they are not set to keep
|
|
90
|
+
clients backward-compatibility with older servers.
|
|
91
|
+
"""
|
|
129
92
|
run_spec_excludes = _get_run_spec_excludes(plan.run_spec)
|
|
130
93
|
if run_spec_excludes is not None:
|
|
131
94
|
return {"plan": run_spec_excludes}
|
|
132
95
|
return None
|
|
133
96
|
|
|
134
97
|
|
|
135
|
-
def _get_run_spec_excludes(run_spec: RunSpec) -> Optional[
|
|
98
|
+
def _get_run_spec_excludes(run_spec: RunSpec) -> Optional[Dict]:
|
|
99
|
+
"""
|
|
100
|
+
Returns `run_spec` exclude mapping to exclude certain fields from the request.
|
|
101
|
+
Use this method to exclude new fields when they are not set to keep
|
|
102
|
+
clients backward-compatibility with older servers.
|
|
103
|
+
"""
|
|
136
104
|
spec_excludes: dict[str, Any] = {}
|
|
137
105
|
configuration_excludes: dict[str, Any] = {}
|
|
138
106
|
profile_excludes: set[str] = set()
|
|
139
|
-
configuration = run_spec.configuration
|
|
140
|
-
profile = run_spec.profile
|
|
141
|
-
|
|
142
|
-
#
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
#
|
|
146
|
-
if configuration.type == "service" and configuration.gateway is None:
|
|
147
|
-
configuration_excludes["gateway"] = True
|
|
148
|
-
# client >= 0.18.30 / server <= 0.18.29 compatibility tweak
|
|
149
|
-
if run_spec.configuration.user is None:
|
|
150
|
-
configuration_excludes["user"] = True
|
|
151
|
-
# client >= 0.18.30 / server <= 0.18.29 compatibility tweak
|
|
152
|
-
if configuration.reservation is None:
|
|
153
|
-
configuration_excludes["reservation"] = True
|
|
154
|
-
if profile is not None and profile.reservation is None:
|
|
155
|
-
profile_excludes.add("reservation")
|
|
156
|
-
if configuration.idle_duration is None:
|
|
157
|
-
configuration_excludes["idle_duration"] = True
|
|
158
|
-
if profile is not None and profile.idle_duration is None:
|
|
159
|
-
profile_excludes.add("idle_duration")
|
|
160
|
-
# client >= 0.18.38 / server <= 0.18.37 compatibility tweak
|
|
161
|
-
if configuration.stop_duration is None:
|
|
162
|
-
configuration_excludes["stop_duration"] = True
|
|
163
|
-
if profile is not None and profile.stop_duration is None:
|
|
164
|
-
profile_excludes.add("stop_duration")
|
|
165
|
-
# client >= 0.18.40 / server <= 0.18.39 compatibility tweak
|
|
166
|
-
if (
|
|
167
|
-
is_core_model_instance(configuration, ServiceConfiguration)
|
|
168
|
-
and configuration.strip_prefix == STRIP_PREFIX_DEFAULT
|
|
169
|
-
):
|
|
170
|
-
configuration_excludes["strip_prefix"] = True
|
|
171
|
-
if configuration.single_branch is None:
|
|
172
|
-
configuration_excludes["single_branch"] = True
|
|
173
|
-
if all(
|
|
174
|
-
not is_core_model_instance(v, InstanceMountPoint) or not v.optional
|
|
175
|
-
for v in configuration.volumes
|
|
176
|
-
):
|
|
177
|
-
configuration_excludes["volumes"] = {"__all__": {"optional"}}
|
|
178
|
-
# client >= 0.18.41 / server <= 0.18.40 compatibility tweak
|
|
179
|
-
if configuration.availability_zones is None:
|
|
180
|
-
configuration_excludes["availability_zones"] = True
|
|
181
|
-
if profile is not None and profile.availability_zones is None:
|
|
182
|
-
profile_excludes.add("availability_zones")
|
|
183
|
-
if (
|
|
184
|
-
is_core_model_instance(configuration, DevEnvironmentConfiguration)
|
|
185
|
-
and configuration.inactivity_duration is None
|
|
186
|
-
):
|
|
187
|
-
configuration_excludes["inactivity_duration"] = True
|
|
188
|
-
if configuration.utilization_policy is None:
|
|
189
|
-
configuration_excludes["utilization_policy"] = True
|
|
190
|
-
if profile is not None and profile.utilization_policy is None:
|
|
191
|
-
profile_excludes.add("utilization_policy")
|
|
192
|
-
|
|
107
|
+
# configuration = run_spec.configuration
|
|
108
|
+
# profile = run_spec.profile
|
|
109
|
+
# Fields can be excluded like this:
|
|
110
|
+
# if configuration.availability_zones is None:
|
|
111
|
+
# configuration_excludes["availability_zones"] = True
|
|
112
|
+
# if profile is not None and profile.availability_zones is None:
|
|
113
|
+
# profile_excludes.add("availability_zones")
|
|
193
114
|
if configuration_excludes:
|
|
194
115
|
spec_excludes["configuration"] = configuration_excludes
|
|
195
116
|
if profile_excludes:
|
dstack/api/server/_volumes.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import List
|
|
1
|
+
from typing import Dict, List
|
|
2
2
|
|
|
3
3
|
from pydantic import parse_obj_as
|
|
4
4
|
|
|
@@ -38,9 +38,14 @@ class VolumesAPIClient(APIClientGroup):
|
|
|
38
38
|
self._request(f"/api/project/{project_name}/volumes/delete", body=body.json())
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
def _get_volume_configuration_excludes(configuration: VolumeConfiguration) ->
|
|
41
|
+
def _get_volume_configuration_excludes(configuration: VolumeConfiguration) -> Dict:
|
|
42
|
+
"""
|
|
43
|
+
Returns `configuration` exclude mapping to exclude certain fields from the request.
|
|
44
|
+
Use this method to exclude new fields when they are not set to keep
|
|
45
|
+
clients backward-compatibility with older servers.
|
|
46
|
+
"""
|
|
42
47
|
configuration_excludes = {}
|
|
43
|
-
#
|
|
44
|
-
if configuration.availability_zone is None:
|
|
45
|
-
|
|
48
|
+
# Fields can be excluded like this:
|
|
49
|
+
# if configuration.availability_zone is None:
|
|
50
|
+
# configuration_excludes["availability_zone"] = True
|
|
46
51
|
return {"configuration": configuration_excludes}
|
dstack/version.py
CHANGED