|
12 | 12 | import gpuhunt |
13 | 13 | from pydantic import parse_obj_as |
14 | 14 |
|
15 | | -import dstack._internal.core.models.resources as resources |
16 | | -from dstack._internal.cli.services.args import cpu_spec, disk_spec, gpu_spec, port_mapping |
| 15 | +from dstack._internal.cli.services.args import port_mapping |
17 | 16 | from dstack._internal.cli.services.configurators.base import ( |
18 | 17 | ApplyEnvVarsConfiguratorMixin, |
19 | 18 | BaseApplyConfigurator, |
|
26 | 25 | is_git_repo_url, |
27 | 26 | register_init_repo_args, |
28 | 27 | ) |
| 28 | +from dstack._internal.cli.services.resources import apply_resources_args, register_resources_args |
29 | 29 | from dstack._internal.cli.utils.common import confirm_ask, console |
30 | 30 | from dstack._internal.cli.utils.rich import MultiItemStatus |
31 | 31 | from dstack._internal.cli.utils.run import get_runs_table, print_run_plan |
@@ -309,29 +309,7 @@ def register_args(cls, parser: argparse.ArgumentParser): |
309 | 309 | default=3, |
310 | 310 | ) |
311 | 311 | cls.register_env_args(configuration_group) |
312 | | - configuration_group.add_argument( |
313 | | - "--cpu", |
314 | | - type=cpu_spec, |
315 | | - help="Request CPU for the run. " |
316 | | - "The format is [code]ARCH[/]:[code]COUNT[/] (all parts are optional)", |
317 | | - dest="cpu_spec", |
318 | | - metavar="SPEC", |
319 | | - ) |
320 | | - configuration_group.add_argument( |
321 | | - "--gpu", |
322 | | - type=gpu_spec, |
323 | | - help="Request GPU for the run. " |
324 | | - "The format is [code]NAME[/]:[code]COUNT[/]:[code]MEMORY[/] (all parts are optional)", |
325 | | - dest="gpu_spec", |
326 | | - metavar="SPEC", |
327 | | - ) |
328 | | - configuration_group.add_argument( |
329 | | - "--disk", |
330 | | - type=disk_spec, |
331 | | - help="Request the size range of disk for the run. Example [code]--disk 100GB..[/].", |
332 | | - metavar="RANGE", |
333 | | - dest="disk_spec", |
334 | | - ) |
| 312 | + register_resources_args(configuration_group) |
335 | 313 | register_profile_args(parser) |
336 | 314 | repo_group = parser.add_argument_group("Repo Options") |
337 | 315 | repo_group.add_argument( |
@@ -359,16 +337,10 @@ def register_args(cls, parser: argparse.ArgumentParser): |
359 | 337 | register_init_repo_args(repo_group) |
360 | 338 |
|
361 | 339 | def apply_args(self, conf: RunConfigurationT, args: argparse.Namespace): |
| 340 | + apply_resources_args(args, conf) |
362 | 341 | apply_profile_args(args, conf) |
363 | 342 | if args.run_name: |
364 | 343 | conf.name = args.run_name |
365 | | - if args.cpu_spec: |
366 | | - conf.resources.cpu = resources.CPUSpec.parse_obj(args.cpu_spec) |
367 | | - if args.gpu_spec: |
368 | | - conf.resources.gpu = resources.GPUSpec.parse_obj(args.gpu_spec) |
369 | | - if args.disk_spec: |
370 | | - conf.resources.disk = args.disk_spec |
371 | | - |
372 | 344 | self.apply_env_vars(conf.env, args) |
373 | 345 | self.interpolate_env(conf) |
374 | 346 |
|
|
0 commit comments