Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 🎸 Add --regions and --exclude flag to fetch_azure #2553

Merged
merged 10 commits into from
Sep 14, 2023
Merged
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ build/
sky_logs/
sky/clouds/service_catalog/data_fetchers/*.csv
.vscode/
.idea/

14 changes: 12 additions & 2 deletions docs/source/reference/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,22 @@ By default, SkyPilot supports most global regions on AWS and only supports the U
version=$(python -c 'import sky; print(sky.clouds.service_catalog.constants.CATALOG_SCHEMA_VERSION)')
mkdir -p ~/.sky/catalogs/${version}
cd ~/.sky/catalogs/${version}
# Fetch all regions for GCP
# GCP
pip install lxml
# Fetch U.S. regions for GCP
python -m sky.clouds.service_catalog.data_fetchers.fetch_gcp
# Fetch all regions for GCP
python -m sky.clouds.service_catalog.data_fetchers.fetch_gcp --all-regions


# Azure
# Fetch U.S. regions for Azure
python -m sky.clouds.service_catalog.data_fetchers.fetch_azure
# Fetch all regions for Azure
python -m sky.clouds.service_catalog.data_fetchers.fetch_azure --all-regions
# Fetch the specified regions for Azure
python -m sky.clouds.service_catalog.data_fetchers.fetch_azure --regions japaneast australiaeast uksouth
# Fetch U.S. regions for Azure, excluding the specified regions
python -m sky.clouds.service_catalog.data_fetchers.fetch_azure --exclude centralus eastus

To make your managed spot jobs potentially use all global regions, please log into the spot controller with ``ssh sky-spot-controller-<hash>``
(the full name can be found in ``sky status``), and run the commands above.
Expand Down
31 changes: 23 additions & 8 deletions sky/clouds/service_catalog/data_fetchers/fetch_azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import pandas as pd
import requests

US_REGIONS = [
US_REGIONS = {
'centralus',
'eastus',
'eastus2',
Expand All @@ -24,7 +24,7 @@
'westus',
'westus2',
'westus3',
]
}

# Exclude the following regions as they do not have ProductName in the
# pricing table. Reference: #1768
Expand Down Expand Up @@ -248,14 +248,29 @@ def get_additional_columns(row):

if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument(
'--all-regions',
action='store_true',
help='Fetch all global regions, not just the U.S. ones.')
group = parser.add_mutually_exclusive_group()
group.add_argument('--all-regions',
action='store_true',
help='Fetch all global regions, not just the U.S. ones.')
group.add_argument('--regions',
nargs='+',
help='Fetch the list of specified regions.')
parser.add_argument('--exclude',
nargs='+',
help='Exclude the list of specified regions.')
args = parser.parse_args()

region_filter = get_regions() if args.all_regions else US_REGIONS
region_filter = set(region_filter) - EXCLUDED_REGIONS
if args.regions:
region_filter = set(args.regions) - EXCLUDED_REGIONS
elif args.all_regions:
region_filter = set(get_regions()) - EXCLUDED_REGIONS
else:
region_filter = US_REGIONS
region_filter = region_filter - set(
args.exclude) if args.exclude else region_filter

sunny0826 marked this conversation as resolved.
Show resolved Hide resolved
if not region_filter:
raise ValueError('No regions to fetch. Please check your arguments.')

instance_df = get_all_regions_instance_types_df(region_filter)
os.makedirs('azure', exist_ok=True)
Expand Down