Skip to content

Commit

Permalink
Change default spot_policy to on-demand (#1657)
Browse files Browse the repository at this point in the history
  • Loading branch information
r4victor authored Sep 4, 2024
1 parent 1537163 commit b4a5a76
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/dstack/_internal/core/models/fleets.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def _merged_profile(cls, values) -> Dict:
if conf_val is not None:
setattr(merged_profile, key, conf_val)
if merged_profile.spot_policy is None:
merged_profile.spot_policy = SpotPolicy.AUTO
merged_profile.spot_policy = SpotPolicy.ONDEMAND
if merged_profile.retry is None:
merged_profile.retry = False
if merged_profile.termination_policy is None:
Expand Down
5 changes: 2 additions & 3 deletions src/dstack/_internal/core/models/runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,8 @@ class PoolInstanceOffers(CoreModel):


def get_policy_map(spot_policy: Optional[SpotPolicy], default: SpotPolicy) -> Optional[bool]:
"""Map profile.spot_policy[SpotPolicy|None] to requirements.spot[bool|None]
- SpotPolicy.AUTO by default for `dstack run`
- SpotPolicy.ONDEMAND by default for `dstack pool add`
"""
Map profile.spot_policy[SpotPolicy|None] to requirements.spot[bool|None]
"""
if spot_policy is None:
spot_policy = default
Expand Down
2 changes: 1 addition & 1 deletion src/dstack/_internal/server/services/fleets.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ async def create_fleet_instance_model(
requirements = Requirements(
resources=spec.configuration.resources or ResourcesSpec(),
max_price=profile.max_price,
spot=get_policy_map(profile.spot_policy, default=SpotPolicy.AUTO),
spot=get_policy_map(profile.spot_policy, default=SpotPolicy.ONDEMAND),
)
instance_model = await pools_services.create_instance_model(
session=session,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def _default_max_duration(self) -> Optional[int]:
return None

def _spot_policy(self) -> SpotPolicy:
return self.run_spec.merged_profile.spot_policy or SpotPolicy.AUTO
return self.run_spec.merged_profile.spot_policy or SpotPolicy.ONDEMAND

def _ports(self) -> List[PortMapping]:
return []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def _default_max_duration(self) -> Optional[int]:
return DEFAULT_MAX_DURATION_SECONDS

def _spot_policy(self) -> SpotPolicy:
return self.run_spec.merged_profile.spot_policy or SpotPolicy.AUTO
return self.run_spec.merged_profile.spot_policy or SpotPolicy.ONDEMAND

def _ports(self) -> List[PortMapping]:
return self.run_spec.configuration.ports
Expand Down

0 comments on commit b4a5a76

Please sign in to comment.