Skip to content

Commit db5e45d

Browse files
Catalog: sort by (price, region name, zone name). (skypilot-org#1492)
1 parent ee73e7d commit db5e45d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

sky/clouds/service_catalog/common.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,10 @@ def get_region_zones(df: pd.DataFrame,
330330
use_spot: bool) -> List[cloud_lib.Region]:
331331
"""Returns a list of regions/zones from a dataframe."""
332332
price_str = 'SpotPrice' if use_spot else 'Price'
333-
df = df.dropna(subset=[price_str]).sort_values(price_str)
333+
sort_keys = [price_str, 'Region']
334+
if 'AvailabilityZone' in df.columns:
335+
sort_keys.append('AvailabilityZone')
336+
df = df.dropna(subset=[price_str]).sort_values(sort_keys)
334337
regions = [cloud_lib.Region(region) for region in df['Region'].unique()]
335338
if 'AvailabilityZone' in df.columns:
336339
zones_in_region = df.groupby('Region')['AvailabilityZone'].apply(

0 commit comments

Comments
 (0)