Skip to content

Commit 5cf1052

Browse files
[Feature]: Allow listing available key resources such as gpu, region, and backends #2142 (WIP)
Renamed `dstack list gpu` to `dstack gpu`
1 parent 0a757c9 commit 5cf1052

2 files changed

Lines changed: 6 additions & 24 deletions

File tree

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from dstack.api.utils import load_profile
1919

2020

21-
class ListGpuConfigurator(BaseRunConfigurator):
21+
class GpuConfigurator(BaseRunConfigurator):
2222
TYPE = ApplyConfigurationType.TASK
2323

2424
@classmethod
@@ -35,7 +35,7 @@ def register_args(
3535
)
3636

3737

38-
class ListGpuCommand(APIBaseCommand):
38+
class GpuCommand(APIBaseCommand):
3939
NAME = "gpu"
4040
DESCRIPTION = "List available GPUs"
4141

@@ -54,13 +54,13 @@ def _register(self):
5454
dest="format",
5555
help="Output in JSON format (equivalent to --format json)",
5656
)
57-
ListGpuConfigurator.register_args(self._parser)
57+
GpuConfigurator.register_args(self._parser)
5858

5959
def _command(self, args: argparse.Namespace):
6060
super()._command(args)
6161
conf = TaskConfiguration(commands=[":"])
6262

63-
configurator = ListGpuConfigurator(api_client=self.api)
63+
configurator = GpuConfigurator(api_client=self.api)
6464
configurator.apply_args(conf, args, [])
6565
profile = load_profile(Path.cwd(), profile_name=args.profile)
6666

@@ -278,21 +278,3 @@ def th(s: str) -> str:
278278

279279
console.print(props)
280280
console.print()
281-
282-
283-
class ListCommand(APIBaseCommand):
284-
NAME = "list"
285-
DESCRIPTION = "List various resources"
286-
287-
def _register(self):
288-
super()._register()
289-
subparsers = self._parser.add_subparsers(dest="subcommand", help="Available subcommands")
290-
291-
gpu_parser = subparsers.add_parser("gpu", help="List available GPUs")
292-
gpu_cmd = ListGpuCommand(gpu_parser)
293-
gpu_cmd._register()
294-
gpu_parser.set_defaults(func=gpu_cmd._command)
295-
296-
def _command(self, args: argparse.Namespace):
297-
if not hasattr(args, "subcommand") or args.subcommand is None:
298-
self._parser.print_help()

src/dstack/_internal/cli/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
from dstack._internal.cli.commands.delete import DeleteCommand
1212
from dstack._internal.cli.commands.fleet import FleetCommand
1313
from dstack._internal.cli.commands.gateway import GatewayCommand
14+
from dstack._internal.cli.commands.gpu import GpuCommand
1415
from dstack._internal.cli.commands.init import InitCommand
15-
from dstack._internal.cli.commands.list import ListCommand
1616
from dstack._internal.cli.commands.logs import LogsCommand
1717
from dstack._internal.cli.commands.metrics import MetricsCommand
1818
from dstack._internal.cli.commands.offer import OfferCommand
@@ -69,7 +69,7 @@ def main():
6969
FleetCommand.register(subparsers)
7070
GatewayCommand.register(subparsers)
7171
InitCommand.register(subparsers)
72-
ListCommand.register(subparsers)
72+
GpuCommand.register(subparsers)
7373
OfferCommand.register(subparsers)
7474
LogsCommand.register(subparsers)
7575
MetricsCommand.register(subparsers)

0 commit comments

Comments
 (0)