Skip to content

Commit 09992a0

Browse files
authored
Drop pools (#2401)
* Remove pools from the CLI and Python API * Remove pools from HTTP API and profiles/configurations * Do not require pools for instances
1 parent 7011a76 commit 09992a0

50 files changed

Lines changed: 247 additions & 2698 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

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

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

src/dstack/_internal/cli/main.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from dstack._internal.cli.commands.gateway import GatewayCommand
1414
from dstack._internal.cli.commands.init import InitCommand
1515
from dstack._internal.cli.commands.logs import LogsCommand
16-
from dstack._internal.cli.commands.pool import PoolCommand
1716
from dstack._internal.cli.commands.ps import PsCommand
1817
from dstack._internal.cli.commands.run import RunCommand
1918
from dstack._internal.cli.commands.server import ServerCommand
@@ -65,7 +64,6 @@ def main():
6564
DeleteCommand.register(subparsers)
6665
FleetCommand.register(subparsers)
6766
GatewayCommand.register(subparsers)
68-
PoolCommand.register(subparsers)
6967
InitCommand.register(subparsers)
7068
LogsCommand.register(subparsers)
7169
PsCommand.register(subparsers)

src/dstack/_internal/cli/services/configurators/run.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,6 @@ def apply_configuration(
101101
max_price=profile.max_price,
102102
working_dir=conf.working_dir,
103103
run_name=conf.name,
104-
pool_name=profile.pool_name,
105-
instance_name=profile.instance_name,
106104
creation_policy=profile.creation_policy,
107105
termination_policy=profile.termination_policy,
108106
termination_policy_idle=profile.termination_idle_time,

src/dstack/_internal/cli/services/profile.py

Lines changed: 32 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
from dstack._internal.core.models.configurations import AnyRunConfiguration
66
from dstack._internal.core.models.profiles import (
7-
DEFAULT_INSTANCE_RETRY_DURATION,
8-
DEFAULT_POOL_TERMINATION_IDLE_TIME,
97
CreationPolicy,
108
Profile,
119
ProfileRetryPolicy,
@@ -16,9 +14,9 @@
1614
)
1715

1816

19-
def register_profile_args(parser: argparse.ArgumentParser, pool_add: bool = False):
17+
def register_profile_args(parser: argparse.ArgumentParser):
2018
"""
21-
Registers `parser` with `dstack run` and `dstack pool add`
19+
Registers `parser` with `dstack apply` run configuration
2220
CLI arguments that override `profiles.yml` settings.
2321
"""
2422
profile_group = parser.add_argument_group("Profile")
@@ -36,14 +34,13 @@ def register_profile_args(parser: argparse.ArgumentParser, pool_add: bool = Fals
3634
help="The maximum price per hour, in dollars",
3735
dest="max_price",
3836
)
39-
if not pool_add:
40-
profile_group.add_argument(
41-
"--max-duration",
42-
type=max_duration,
43-
dest="max_duration",
44-
help="The maximum duration of the run",
45-
metavar="DURATION",
46-
)
37+
profile_group.add_argument(
38+
"--max-duration",
39+
type=max_duration,
40+
dest="max_duration",
41+
help="The maximum duration of the run",
42+
metavar="DURATION",
43+
)
4744
profile_group.add_argument(
4845
"-b",
4946
"--backend",
@@ -67,42 +64,28 @@ def register_profile_args(parser: argparse.ArgumentParser, pool_add: bool = Fals
6764
dest="instance_types",
6865
help="The cloud-specific instance types that will be tried for provisioning",
6966
)
70-
if pool_add:
71-
pools_group_exc = parser
72-
else:
73-
pools_group = parser.add_argument_group("Pools")
74-
pools_group_exc = pools_group.add_mutually_exclusive_group()
75-
pools_group_exc.add_argument(
76-
"--pool",
77-
dest="pool_name",
78-
help="The name of the pool. If not set, the default pool will be used",
79-
)
80-
pools_group_exc.add_argument(
67+
68+
fleets_group = parser.add_argument_group("Fleets")
69+
fleets_group_exc = fleets_group.add_mutually_exclusive_group()
70+
fleets_group_exc.add_argument(
8171
"-R",
8272
"--reuse",
8373
dest="creation_policy_reuse",
8474
action="store_true",
85-
help="Reuse instance from pool",
75+
help="Reuse an existing instance from fleet (do not provision a new one)",
8676
)
87-
pools_group_exc.add_argument(
77+
fleets_group_exc.add_argument(
8878
"--dont-destroy",
8979
dest="dont_destroy",
9080
action="store_true",
91-
help="Do not destroy instance after the run is finished",
81+
help="Do not destroy instance after the run is finished (if the run provisions a new instance)",
9282
)
93-
pools_group_exc.add_argument(
83+
fleets_group_exc.add_argument(
9484
"--idle-duration",
9585
dest="idle_duration",
9686
type=str,
97-
help="Time to wait before destroying the idle instance",
87+
help="Time to wait before destroying the idle instance (if the run provisions a new instance)",
9888
)
99-
if not pool_add:
100-
pools_group_exc.add_argument(
101-
"--instance",
102-
dest="instance_name",
103-
metavar="NAME",
104-
help="Reuse instance from pool with name [code]NAME[/]",
105-
)
10689

10790
spot_group = parser.add_argument_group("Spot policy")
10891
spot_group_exc = spot_group.add_mutually_exclusive_group()
@@ -149,7 +132,6 @@ def register_profile_args(parser: argparse.ArgumentParser, pool_add: bool = Fals
149132
def apply_profile_args(
150133
args: argparse.Namespace,
151134
profile_settings: Union[Profile, AnyRunConfiguration],
152-
pool_add: bool = False,
153135
):
154136
"""
155137
Overrides `profile_settings` settings with arguments registered by `register_profile_args()`.
@@ -165,53 +147,29 @@ def apply_profile_args(
165147
profile_settings.instance_types = args.instance_types
166148
if args.max_price is not None:
167149
profile_settings.max_price = args.max_price
168-
if not pool_add:
169-
if args.max_duration is not None:
170-
profile_settings.max_duration = args.max_duration
171-
172-
if args.pool_name:
173-
profile_settings.pool_name = args.pool_name
150+
if args.max_duration is not None:
151+
profile_settings.max_duration = args.max_duration
174152

175153
if args.idle_duration is not None:
176154
profile_settings.termination_idle_time = args.idle_duration
177-
if pool_add and args.idle_duration is None:
178-
profile_settings.termination_idle_time = DEFAULT_POOL_TERMINATION_IDLE_TIME
179155

180156
if args.dont_destroy:
181157
profile_settings.termination_policy = TerminationPolicy.DONT_DESTROY
182-
if not pool_add:
183-
if args.instance_name:
184-
profile_settings.instance_name = args.instance_name
185-
if args.creation_policy_reuse:
186-
profile_settings.creation_policy = CreationPolicy.REUSE
158+
if args.creation_policy_reuse:
159+
profile_settings.creation_policy = CreationPolicy.REUSE
187160

188161
if args.spot_policy is not None:
189162
profile_settings.spot_policy = args.spot_policy
190-
if pool_add and args.spot_policy is None: # ONDEMAND by default for `dstack pool add`
191-
profile_settings.spot_policy = SpotPolicy.ONDEMAND
192-
193-
if not pool_add:
194-
if args.retry_policy is not None:
195-
if not profile_settings.retry_policy:
196-
profile_settings.retry_policy = ProfileRetryPolicy()
197-
profile_settings.retry_policy.retry = args.retry_policy
198-
elif args.retry_duration is not None:
199-
if not profile_settings.retry_policy:
200-
profile_settings.retry_policy = ProfileRetryPolicy()
201-
profile_settings.retry_policy.retry = True
202-
profile_settings.retry_policy.duration = args.retry_duration
203-
else:
204-
if args.retry_policy is not None:
205-
if not profile_settings.retry_policy:
206-
profile_settings.retry_policy = ProfileRetryPolicy()
207-
profile_settings.retry_policy.retry = args.retry_policy
208-
if profile_settings.retry_policy.retry:
209-
profile_settings.retry_policy.duration = DEFAULT_INSTANCE_RETRY_DURATION
210-
elif args.retry_duration is not None:
211-
if not profile_settings.retry_policy:
212-
profile_settings.retry_policy = ProfileRetryPolicy()
213-
profile_settings.retry_policy.retry = True
214-
profile_settings.retry_policy.duration = args.retry_duration # --retry-duration
163+
164+
if args.retry_policy is not None:
165+
if not profile_settings.retry_policy:
166+
profile_settings.retry_policy = ProfileRetryPolicy()
167+
profile_settings.retry_policy.retry = args.retry_policy
168+
elif args.retry_duration is not None:
169+
if not profile_settings.retry_policy:
170+
profile_settings.retry_policy = ProfileRetryPolicy()
171+
profile_settings.retry_policy.retry = True
172+
profile_settings.retry_policy.duration = args.retry_duration
215173

216174

217175
def max_duration(v: str) -> int:

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
from dstack._internal.core.models.backends.base import BackendType
1111
from dstack._internal.core.models.common import CoreModel
1212
from dstack._internal.core.models.envs import Env
13-
from dstack._internal.core.models.instances import InstanceOfferWithAvailability, SSHKey
14-
from dstack._internal.core.models.pools import Instance
13+
from dstack._internal.core.models.instances import Instance, InstanceOfferWithAvailability, SSHKey
1514
from dstack._internal.core.models.profiles import (
1615
Profile,
1716
ProfileParams,

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import datetime
12
from enum import Enum
23
from typing import List, Optional
4+
from uuid import UUID
35

46
import gpuhunt
57
from pydantic import root_validator
@@ -167,3 +169,25 @@ def is_active(self) -> bool:
167169
@classmethod
168170
def finished_statuses(cls) -> List["InstanceStatus"]:
169171
return [cls.TERMINATING, cls.TERMINATED]
172+
173+
174+
class Instance(CoreModel):
175+
id: UUID
176+
project_name: str
177+
backend: Optional[BackendType] = None
178+
instance_type: Optional[InstanceType] = None
179+
name: str
180+
fleet_id: Optional[UUID] = None
181+
fleet_name: Optional[str] = None
182+
instance_num: int
183+
job_name: Optional[str] = None # deprecated, always None (instance can have more than one job)
184+
hostname: Optional[str] = None
185+
status: InstanceStatus
186+
unreachable: bool = False
187+
termination_reason: Optional[str] = None
188+
created: datetime.datetime
189+
region: Optional[str] = None
190+
availability_zone: Optional[str] = None
191+
price: Optional[float] = None
192+
total_blocks: Optional[int] = None
193+
busy_blocks: int = 0

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

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

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

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,9 @@
88
from dstack._internal.core.models.common import CoreModel, Duration
99

1010
DEFAULT_RETRY_DURATION = 3600
11-
DEFAULT_POOL_NAME = "default-pool"
1211

1312
DEFAULT_RUN_TERMINATION_IDLE_TIME = 5 * 60 # 5 minutes
14-
DEFAULT_POOL_TERMINATION_IDLE_TIME = 72 * 60 * 60 # 3 days
15-
16-
DEFAULT_INSTANCE_RETRY_DURATION = 60 * 60 * 24 # 24h
13+
DEFAULT_FLEET_TERMINATION_IDLE_TIME = 72 * 60 * 60 # 3 days
1714

1815
DEFAULT_STOP_DURATION = 300
1916

@@ -223,7 +220,7 @@ class ProfileParams(CoreModel):
223220
creation_policy: Annotated[
224221
Optional[CreationPolicy],
225222
Field(
226-
description="The policy for using instances from the pool. Defaults to `reuse-or-create`"
223+
description="The policy for using instances from fleets. Defaults to `reuse-or-create`"
227224
),
228225
]
229226
idle_duration: Annotated[
@@ -252,10 +249,6 @@ class ProfileParams(CoreModel):
252249
description="Deprecated in favor of `idle_duration`",
253250
),
254251
]
255-
# The name of the pool. If not set, dstack will use the default name
256-
pool_name: Optional[str]
257-
# The name of the instance
258-
instance_name: Optional[str]
259252
# The policy for resubmitting the run. Deprecated in favor of `retry`
260253
retry_policy: Optional[ProfileRetryPolicy]
261254

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -476,11 +476,6 @@ class ApplyRunPlanInput(CoreModel):
476476
] = None
477477

478478

479-
class PoolInstanceOffers(CoreModel):
480-
pool_name: str
481-
instances: List[InstanceOfferWithAvailability]
482-
483-
484479
def get_policy_map(spot_policy: Optional[SpotPolicy], default: SpotPolicy) -> Optional[bool]:
485480
"""
486481
Map profile.spot_policy[SpotPolicy|None] to requirements.spot[bool|None]

src/dstack/_internal/server/app.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
instances,
2828
logs,
2929
metrics,
30-
pools,
3130
projects,
3231
prometheus,
3332
repos,
@@ -184,8 +183,6 @@ def register_routes(app: FastAPI, ui: bool = True):
184183
app.include_router(volumes.project_router)
185184
app.include_router(service_proxy.router, prefix="/proxy/services", tags=["service-proxy"])
186185
app.include_router(model_proxy.router, prefix="/proxy/models", tags=["model-proxy"])
187-
app.include_router(pools.root_router)
188-
app.include_router(pools.router)
189186
app.include_router(prometheus.router)
190187

191188
@app.exception_handler(ForbiddenError)

0 commit comments

Comments
 (0)