Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/docs/guides/dstack-sky.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ sign up with [dstack Sky](../guides/dstack-sky.md).

### Set up the CLI

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

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

Expand Down
25 changes: 0 additions & 25 deletions docs/docs/reference/cli/dstack/config.md

This file was deleted.

89 changes: 0 additions & 89 deletions src/dstack/_internal/cli/commands/config.py

This file was deleted.

40 changes: 0 additions & 40 deletions src/dstack/_internal/cli/commands/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
print_gateways_table,
)
from dstack._internal.core.errors import CLIError
from dstack._internal.core.models.backends.base import BackendType
from dstack._internal.core.models.gateways import GatewayConfiguration
from dstack._internal.utils.logging import get_logger

logger = get_logger(__name__)
Expand Down Expand Up @@ -62,24 +60,6 @@ def _register(self):
help="Output in JSON format (equivalent to --format json)",
)

create_parser = subparsers.add_parser(
"create",
help="Add a gateway. Deprecated in favor of `dstack apply` with gateway configuration.",
formatter_class=self._parser.formatter_class,
)
create_parser.set_defaults(subfunc=self._create)
create_parser.add_argument(
"--backend", choices=["aws", "azure", "gcp", "kubernetes"], required=True
)
create_parser.add_argument("--region", required=True)
create_parser.add_argument(
"--set-default", action="store_true", help="Set as default gateway for the project"
)
create_parser.add_argument("--name", help="Set a custom name for the gateway")
create_parser.add_argument(
"--domain", help="Set the domain for the gateway", required=True
)

delete_parser = subparsers.add_parser(
"delete", help="Delete a gateway", formatter_class=self._parser.formatter_class
)
Expand Down Expand Up @@ -129,26 +109,6 @@ def _list(self, args: argparse.Namespace):
except KeyboardInterrupt:
pass

def _create(self, args: argparse.Namespace):
logger.warning(
"`dstack gateway create` is deperecated in favor of `dstack apply` with gateway configurations."
)
with console.status("Creating gateway..."):
configuration = GatewayConfiguration(
name=args.name,
backend=BackendType(args.backend),
region=args.region,
)
gateway = self.api.client.gateways.create(self.api.project, configuration)
if args.set_default:
self.api.client.gateways.set_default(self.api.project, gateway.name)
if args.domain:
self.api.client.gateways.set_wildcard_domain(
self.api.project, gateway.name, args.domain
)
gateway = self.api.client.gateways.get(self.api.project, gateway.name)
print_gateways_table([gateway])

def _delete(self, args: argparse.Namespace):
gateway = self.api.client.gateways.get(self.api.project, args.name)
print_gateways_table([gateway])
Expand Down
14 changes: 0 additions & 14 deletions src/dstack/_internal/cli/commands/stats.py

This file was deleted.

4 changes: 0 additions & 4 deletions src/dstack/_internal/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from dstack._internal.cli.commands.apply import ApplyCommand
from dstack._internal.cli.commands.attach import AttachCommand
from dstack._internal.cli.commands.completion import CompletionCommand
from dstack._internal.cli.commands.config import ConfigCommand
from dstack._internal.cli.commands.delete import DeleteCommand
from dstack._internal.cli.commands.fleet import FleetCommand
from dstack._internal.cli.commands.gateway import GatewayCommand
Expand All @@ -19,7 +18,6 @@
from dstack._internal.cli.commands.ps import PsCommand
from dstack._internal.cli.commands.secrets import SecretCommand
from dstack._internal.cli.commands.server import ServerCommand
from dstack._internal.cli.commands.stats import StatsCommand
from dstack._internal.cli.commands.stop import StopCommand
from dstack._internal.cli.commands.volume import VolumeCommand
from dstack._internal.cli.utils.common import _colors, console
Expand Down Expand Up @@ -63,7 +61,6 @@ def main():
subparsers = parser.add_subparsers(metavar="COMMAND")
ApplyCommand.register(subparsers)
AttachCommand.register(subparsers)
ConfigCommand.register(subparsers)
DeleteCommand.register(subparsers)
FleetCommand.register(subparsers)
GatewayCommand.register(subparsers)
Expand All @@ -75,7 +72,6 @@ def main():
PsCommand.register(subparsers)
SecretCommand.register(subparsers)
ServerCommand.register(subparsers)
StatsCommand.register(subparsers)
StopCommand.register(subparsers)
VolumeCommand.register(subparsers)
CompletionCommand.register(subparsers)
Expand Down
20 changes: 0 additions & 20 deletions src/dstack/_internal/core/models/profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,26 +98,6 @@ def parse_idle_duration(v: Optional[Union[int, str, bool]]) -> Optional[int]:
return parse_duration(v)


# Deprecated in favor of ProfileRetry().
# TODO: Remove when no longer referenced.
class ProfileRetryPolicy(CoreModel):
retry: Annotated[bool, Field(description="Whether to retry the run on failure or not")] = False
duration: Annotated[
Optional[Union[int, str]],
Field(description="The maximum period of retrying the run, e.g., `4h` or `1d`"),
] = None

_validate_duration = validator("duration", pre=True, allow_reuse=True)(parse_duration)

@root_validator
def _validate_fields(cls, values):
if values["retry"] and "duration" not in values:
values["duration"] = DEFAULT_RETRY_DURATION
if values.get("duration") is not None:
values["retry"] = True
return values


class RetryEvent(str, Enum):
NO_CAPACITY = "no-capacity"
INTERRUPTION = "interruption"
Expand Down
48 changes: 0 additions & 48 deletions src/tests/_internal/cli/commands/test_config.py

This file was deleted.

42 changes: 42 additions & 0 deletions src/tests/_internal/cli/commands/test_project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from pathlib import Path
from unittest.mock import patch

import yaml
from pytest import CaptureFixture

from tests._internal.cli.common import run_dstack_cli


class TestProjectAdd:
def test_adds_project(self, capsys: CaptureFixture, tmp_path: Path):
cli_config_path = tmp_path / ".dstack" / "config.yml"
with patch("dstack.api.server.APIClient") as APIClientMock:
api_client_mock = APIClientMock.return_value
exit_code = run_dstack_cli(
[
"project",
"add",
"--name",
"project",
"--url",
"http://127.0.0.1:31313",
"--token",
"token",
"-y",
],
home_dir=tmp_path,
)
APIClientMock.assert_called_once_with(base_url="http://127.0.0.1:31313", token="token")
api_client_mock.projects.get.assert_called_with("project")
assert exit_code == 0
assert yaml.load(cli_config_path.read_text(), yaml.FullLoader) == {
"projects": [
{
"default": True,
"name": "project",
"token": "token",
"url": "http://127.0.0.1:31313",
}
],
"repos": [],
}