Skip to content

Commit

Permalink
[Tests] Fix test for g6 instance type (#3421)
Browse files Browse the repository at this point in the history
* remove resources not having price

* format
  • Loading branch information
Michaelvll authored Apr 5, 2024
1 parent 495140e commit d18b70a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions sky/clouds/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,15 @@ def _get_feasible_launchable_resources(
) -> Tuple[List['resources_lib.Resources'], List[str]]:
if resources.instance_type is not None:
assert resources.is_launchable(), resources
# Check the instance type is valid in the cloud
regions = self.regions_with_offering(
resources.instance_type,
accelerators=resources.accelerators,
use_spot=resources.use_spot,
region=resources.region,
zone=resources.zone)
if not regions:
return ([], [])
# Treat Resources(AWS, p3.2x, V100) as Resources(AWS, p3.2x).
resources = resources.copy(accelerators=None)
return ([resources], [])
Expand Down
6 changes: 6 additions & 0 deletions sky/clouds/service_catalog/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,10 @@ def get_hourly_cost_impl(
# all the zones in the same region.
assert region is None or len(set(df[price_str])) == 1, df

if pd.isna(df[price_str]).all():
with ux_utils.print_exception_no_traceback():
raise ValueError(f'No {price_str} found for instance type '
f'{instance_type!r}.')
cheapest_idx = df[price_str].idxmin()
cheapest = df.loc[cheapest_idx]
return cheapest[price_str]
Expand Down Expand Up @@ -523,6 +527,8 @@ def get_instance_type_for_accelerator_impl(

# Current strategy: choose the cheapest instance
price_str = 'SpotPrice' if use_spot else 'Price'
if pd.isna(result[price_str]).all():
return ([], [])
result = result.sort_values(price_str, ascending=True)
instance_types = list(result['InstanceType'].drop_duplicates())
return (instance_types, [])
Expand Down
2 changes: 2 additions & 0 deletions tests/test_optimizer_random_dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ def generate_random_dag(
accelerators={
candidate.accelerator_name: candidate.accelerator_count
})
if not resources.get_valid_regions_for_launchable():
continue
requested_features = set()
if op.num_nodes > 1:
requested_features.add(
Expand Down

0 comments on commit d18b70a

Please sign in to comment.