Skip to content

Commit ee21f04

Browse files
committed
Tweak Compute API for dstack Sky
1 parent e3b82f8 commit ee21f04

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

src/dstack/_internal/core/backends/base/compute.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
DSTACK_RUNNER_SSH_PORT,
2424
DSTACK_SHIM_HTTP_PORT,
2525
)
26+
from dstack._internal.core.models.backends.base import BackendType
2627
from dstack._internal.core.models.configurations import LEGACY_REPO_DIR
2728
from dstack._internal.core.models.gateways import (
2829
GatewayComputeConfiguration,
@@ -403,9 +404,13 @@ def is_suitable_placement_group(
403404
"""
404405
pass
405406

406-
def are_placement_groups_compatible_with_reservations(self) -> bool:
407+
def are_placement_groups_compatible_with_reservations(self, backend_type: BackendType) -> bool:
407408
"""
408409
Whether placement groups can be used for instances provisioned in reservations.
410+
411+
Arguments:
412+
backend_type: matches the backend type of this compute, unless this compute is a proxy
413+
for other backends (dstack Sky)
409414
"""
410415
return True
411416

src/dstack/_internal/core/backends/gcp/compute.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ def is_suitable_placement_group(
528528
) -> bool:
529529
return placement_group.configuration.region == instance_offer.region
530530

531-
def are_placement_groups_compatible_with_reservations(self) -> bool:
531+
def are_placement_groups_compatible_with_reservations(self, backend_type: BackendType) -> bool:
532532
# Cannot use our own placement policies when provisioning in a reservation.
533533
# Instead, we use the placement policy defined in reservation settings.
534534
return False

src/dstack/_internal/server/background/tasks/process_instances.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ async def _create_instance(session: AsyncSession, instance: InstanceModel) -> No
560560
and instance_offer.backend in BACKENDS_WITH_PLACEMENT_GROUPS_SUPPORT
561561
and isinstance(compute, ComputeWithPlacementGroupSupport)
562562
and (
563-
compute.are_placement_groups_compatible_with_reservations()
563+
compute.are_placement_groups_compatible_with_reservations(instance_offer.backend)
564564
or instance_configuration.reservation is None
565565
)
566566
and instance.fleet

0 commit comments

Comments
 (0)