|
5 | 5 | ServiceConfiguration, |
6 | 6 | ) |
7 | 7 | from dstack._internal.core.models.repos.virtual import DEFAULT_VIRTUAL_REPO_ID, VirtualRunRepoData |
8 | | -from dstack._internal.core.models.resources import ResourcesSpec |
9 | 8 | from dstack._internal.core.models.runs import LEGACY_REPO_DIR, AnyRunConfiguration, RunSpec |
10 | 9 | from dstack._internal.core.models.volumes import InstanceMountPoint |
11 | 10 | from dstack._internal.core.services import validate_dstack_resource_name |
@@ -113,34 +112,16 @@ def validate_run_spec_and_set_defaults( |
113 | 112 | raise ServerClientError( |
114 | 113 | f"Probe timeout cannot be longer than {settings.MAX_PROBE_TIMEOUT}s" |
115 | 114 | ) |
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 | | - ) |
126 | 115 | if run_spec.configuration.priority is None: |
127 | 116 | 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 | + ) |
144 | 125 | if run_spec.ssh_key_pub is None: |
145 | 126 | if user.ssh_public_key: |
146 | 127 | run_spec.ssh_key_pub = user.ssh_public_key |
|
0 commit comments