Skip to content
Open
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
16 changes: 12 additions & 4 deletions src/dstack/_internal/core/backends/oci/compute.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from collections.abc import Iterable
from collections.abc import Container, Iterable
from concurrent.futures import ThreadPoolExecutor
from functools import cached_property
from functools import cached_property, partial
from typing import List, Optional

import oci
Expand Down Expand Up @@ -64,6 +64,10 @@ def __init__(self, config: OCIConfig):
super().__init__()
self.config = config
self.regions = make_region_clients_map(config.regions or [], config.creds)
self._supported_instances = partial(
_supported_instances,
experimental_instance_types=set(self.config.experimental_instance_types or []),
)

@cached_property
def shapes_quota(self) -> resources.ShapesQuota:
Expand All @@ -75,7 +79,7 @@ def get_all_offers_with_availability(
offers = get_catalog_offers(
backend=BackendType.OCI,
locations=self.config.regions,
extra_filter=_supported_instances,
extra_filter=self._supported_instances,
)

with ThreadPoolExecutor(max_workers=8) as executor:
Expand Down Expand Up @@ -206,7 +210,11 @@ def update_provisioning_data(
provisioning_data.internal_ip = vnic.private_ip


def _supported_instances(offer: InstanceOffer) -> bool:
def _supported_instances(
offer: InstanceOffer, experimental_instance_types: Container[str]
) -> bool:
if offer.instance.name in experimental_instance_types:
return True
if "Flex" in offer.instance.name:
return False
return any(map(offer.instance.name.startswith, SUPPORTED_SHAPE_FAMILIES))
10 changes: 10 additions & 0 deletions src/dstack/_internal/core/backends/oci/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ class OCIBackendConfig(CoreModel):
)
),
] = None
experimental_instance_types: Annotated[
Optional[List[str]],
Field(
description=(
"The list of shape names to allow provisioning in addition to"
" the standard supported shape families. Only works for shapes"
" included in `dstack`'s pricing catalog (`gpuhunt`)"
)
),
] = None


class OCIBackendConfigWithCreds(OCIBackendConfig):
Expand Down
Loading