Skip to content

Commit 9d6ea7f

Browse files
authored
Drop dstack config, dstack stats, dstack gateway create (#3351)
* Drop dstack config * Drop dstack stats * Drop dstack gateway create * Drop ProfileRetryPolicy * Fix tests
1 parent 50bff04 commit 9d6ea7f

9 files changed

Lines changed: 43 additions & 241 deletions

File tree

docs/docs/guides/dstack-sky.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ sign up with [dstack Sky](../guides/dstack-sky.md).
55

66
### Set up the CLI
77

8-
If you've signed up, open your project settings, and copy the `dstack config` command to point the CLI to the project.
8+
If you've signed up, open your project settings, and copy the `dstack project add` command to point the CLI to the project.
99

1010
![](https://raw.githubusercontent.com/dstackai/static-assets/main/static-assets/images/dstack-sky-project-config.png){ width=800 }
1111

docs/docs/reference/cli/dstack/config.md

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/dstack/_internal/cli/commands/config.py

Lines changed: 0 additions & 89 deletions
This file was deleted.

src/dstack/_internal/cli/commands/gateway.py

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
print_gateways_table,
1818
)
1919
from dstack._internal.core.errors import CLIError
20-
from dstack._internal.core.models.backends.base import BackendType
21-
from dstack._internal.core.models.gateways import GatewayConfiguration
2220
from dstack._internal.utils.logging import get_logger
2321

2422
logger = get_logger(__name__)
@@ -62,24 +60,6 @@ def _register(self):
6260
help="Output in JSON format (equivalent to --format json)",
6361
)
6462

65-
create_parser = subparsers.add_parser(
66-
"create",
67-
help="Add a gateway. Deprecated in favor of `dstack apply` with gateway configuration.",
68-
formatter_class=self._parser.formatter_class,
69-
)
70-
create_parser.set_defaults(subfunc=self._create)
71-
create_parser.add_argument(
72-
"--backend", choices=["aws", "azure", "gcp", "kubernetes"], required=True
73-
)
74-
create_parser.add_argument("--region", required=True)
75-
create_parser.add_argument(
76-
"--set-default", action="store_true", help="Set as default gateway for the project"
77-
)
78-
create_parser.add_argument("--name", help="Set a custom name for the gateway")
79-
create_parser.add_argument(
80-
"--domain", help="Set the domain for the gateway", required=True
81-
)
82-
8363
delete_parser = subparsers.add_parser(
8464
"delete", help="Delete a gateway", formatter_class=self._parser.formatter_class
8565
)
@@ -129,26 +109,6 @@ def _list(self, args: argparse.Namespace):
129109
except KeyboardInterrupt:
130110
pass
131111

132-
def _create(self, args: argparse.Namespace):
133-
logger.warning(
134-
"`dstack gateway create` is deperecated in favor of `dstack apply` with gateway configurations."
135-
)
136-
with console.status("Creating gateway..."):
137-
configuration = GatewayConfiguration(
138-
name=args.name,
139-
backend=BackendType(args.backend),
140-
region=args.region,
141-
)
142-
gateway = self.api.client.gateways.create(self.api.project, configuration)
143-
if args.set_default:
144-
self.api.client.gateways.set_default(self.api.project, gateway.name)
145-
if args.domain:
146-
self.api.client.gateways.set_wildcard_domain(
147-
self.api.project, gateway.name, args.domain
148-
)
149-
gateway = self.api.client.gateways.get(self.api.project, gateway.name)
150-
print_gateways_table([gateway])
151-
152112
def _delete(self, args: argparse.Namespace):
153113
gateway = self.api.client.gateways.get(self.api.project, args.name)
154114
print_gateways_table([gateway])

src/dstack/_internal/cli/commands/stats.py

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/dstack/_internal/cli/main.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from dstack._internal.cli.commands.apply import ApplyCommand
88
from dstack._internal.cli.commands.attach import AttachCommand
99
from dstack._internal.cli.commands.completion import CompletionCommand
10-
from dstack._internal.cli.commands.config import ConfigCommand
1110
from dstack._internal.cli.commands.delete import DeleteCommand
1211
from dstack._internal.cli.commands.fleet import FleetCommand
1312
from dstack._internal.cli.commands.gateway import GatewayCommand
@@ -19,7 +18,6 @@
1918
from dstack._internal.cli.commands.ps import PsCommand
2019
from dstack._internal.cli.commands.secrets import SecretCommand
2120
from dstack._internal.cli.commands.server import ServerCommand
22-
from dstack._internal.cli.commands.stats import StatsCommand
2321
from dstack._internal.cli.commands.stop import StopCommand
2422
from dstack._internal.cli.commands.volume import VolumeCommand
2523
from dstack._internal.cli.utils.common import _colors, console
@@ -63,7 +61,6 @@ def main():
6361
subparsers = parser.add_subparsers(metavar="COMMAND")
6462
ApplyCommand.register(subparsers)
6563
AttachCommand.register(subparsers)
66-
ConfigCommand.register(subparsers)
6764
DeleteCommand.register(subparsers)
6865
FleetCommand.register(subparsers)
6966
GatewayCommand.register(subparsers)
@@ -75,7 +72,6 @@ def main():
7572
PsCommand.register(subparsers)
7673
SecretCommand.register(subparsers)
7774
ServerCommand.register(subparsers)
78-
StatsCommand.register(subparsers)
7975
StopCommand.register(subparsers)
8076
VolumeCommand.register(subparsers)
8177
CompletionCommand.register(subparsers)

src/dstack/_internal/core/models/profiles.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -98,26 +98,6 @@ def parse_idle_duration(v: Optional[Union[int, str, bool]]) -> Optional[int]:
9898
return parse_duration(v)
9999

100100

101-
# Deprecated in favor of ProfileRetry().
102-
# TODO: Remove when no longer referenced.
103-
class ProfileRetryPolicy(CoreModel):
104-
retry: Annotated[bool, Field(description="Whether to retry the run on failure or not")] = False
105-
duration: Annotated[
106-
Optional[Union[int, str]],
107-
Field(description="The maximum period of retrying the run, e.g., `4h` or `1d`"),
108-
] = None
109-
110-
_validate_duration = validator("duration", pre=True, allow_reuse=True)(parse_duration)
111-
112-
@root_validator
113-
def _validate_fields(cls, values):
114-
if values["retry"] and "duration" not in values:
115-
values["duration"] = DEFAULT_RETRY_DURATION
116-
if values.get("duration") is not None:
117-
values["retry"] = True
118-
return values
119-
120-
121101
class RetryEvent(str, Enum):
122102
NO_CAPACITY = "no-capacity"
123103
INTERRUPTION = "interruption"

src/tests/_internal/cli/commands/test_config.py

Lines changed: 0 additions & 48 deletions
This file was deleted.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
from pathlib import Path
2+
from unittest.mock import patch
3+
4+
import yaml
5+
from pytest import CaptureFixture
6+
7+
from tests._internal.cli.common import run_dstack_cli
8+
9+
10+
class TestProjectAdd:
11+
def test_adds_project(self, capsys: CaptureFixture, tmp_path: Path):
12+
cli_config_path = tmp_path / ".dstack" / "config.yml"
13+
with patch("dstack.api.server.APIClient") as APIClientMock:
14+
api_client_mock = APIClientMock.return_value
15+
exit_code = run_dstack_cli(
16+
[
17+
"project",
18+
"add",
19+
"--name",
20+
"project",
21+
"--url",
22+
"http://127.0.0.1:31313",
23+
"--token",
24+
"token",
25+
"-y",
26+
],
27+
home_dir=tmp_path,
28+
)
29+
APIClientMock.assert_called_once_with(base_url="http://127.0.0.1:31313", token="token")
30+
api_client_mock.projects.get.assert_called_with("project")
31+
assert exit_code == 0
32+
assert yaml.load(cli_config_path.read_text(), yaml.FullLoader) == {
33+
"projects": [
34+
{
35+
"default": True,
36+
"name": "project",
37+
"token": "token",
38+
"url": "http://127.0.0.1:31313",
39+
}
40+
],
41+
"repos": [],
42+
}

0 commit comments

Comments
 (0)