Skip to content

Commit 3f52e09

Browse files
Bihan  RanaBihan  Rana
authored andcommitted
Remove replica-list top-level resources validation; instead add comment
1 parent 8895195 commit 3f52e09

1 file changed

Lines changed: 8 additions & 27 deletions

File tree

  • src/dstack/_internal/server/services/runs

src/dstack/_internal/server/services/runs/spec.py

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
ServiceConfiguration,
66
)
77
from dstack._internal.core.models.repos.virtual import DEFAULT_VIRTUAL_REPO_ID, VirtualRunRepoData
8-
from dstack._internal.core.models.resources import ResourcesSpec
98
from dstack._internal.core.models.runs import LEGACY_REPO_DIR, AnyRunConfiguration, RunSpec
109
from dstack._internal.core.models.volumes import InstanceMountPoint
1110
from dstack._internal.core.services import validate_dstack_resource_name
@@ -113,34 +112,16 @@ def validate_run_spec_and_set_defaults(
113112
raise ServerClientError(
114113
f"Probe timeout cannot be longer than {settings.MAX_PROBE_TIMEOUT}s"
115114
)
116-
if isinstance(run_spec.configuration.replicas, list):
117-
default_resources = ResourcesSpec()
118-
if (
119-
run_spec.configuration.resources
120-
and run_spec.configuration.resources.dict() != default_resources.dict()
121-
):
122-
raise ServerClientError(
123-
"Top-level `resources` is not allowed when `replicas` is a list. "
124-
"Specify `resources` in each replica group instead."
125-
)
126115
if run_spec.configuration.priority is None:
127116
run_spec.configuration.priority = RUN_PRIORITY_DEFAULT
128-
129-
if not isinstance(run_spec.configuration, ServiceConfiguration):
130-
set_resources_defaults(run_spec.configuration.resources)
131-
set_gpu_vendor_default(
132-
run_spec.configuration.resources,
133-
image=run_spec.configuration.image,
134-
docker=getattr(run_spec.configuration, "docker", None),
135-
)
136-
else:
137-
if not isinstance(run_spec.configuration.replicas, list):
138-
set_resources_defaults(run_spec.configuration.resources)
139-
set_gpu_vendor_default(
140-
run_spec.configuration.resources,
141-
image=run_spec.configuration.image,
142-
docker=getattr(run_spec.configuration, "docker", None),
143-
)
117+
# We do not reject top-level `resources` when `replicas` is a list. Adding strict checks
118+
# would be fragile because the spec may be changed later (for example by plugins).
119+
set_resources_defaults(run_spec.configuration.resources)
120+
set_gpu_vendor_default(
121+
run_spec.configuration.resources,
122+
image=run_spec.configuration.image,
123+
docker=getattr(run_spec.configuration, "docker", None),
124+
)
144125
if run_spec.ssh_key_pub is None:
145126
if user.ssh_public_key:
146127
run_spec.ssh_key_pub = user.ssh_public_key

0 commit comments

Comments
 (0)