Skip to content

Update AWS url for coordinates collection #345

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
47 changes: 23 additions & 24 deletions caribou/data_collector/components/provider/provider_retriever.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,33 +90,32 @@ def retrieve_aws_regions(self) -> dict[str, dict[str, Any]]:
if len(tables) == 0:
raise ValueError("Could not find any tables on the AWS regions page")

for table in tables:
if not table.find_previous("h3").text.strip() == "Available Regions":
# Process the first table (which is the regions table)
table = tables[0]
table_rows = table.find_all("tr")[1:] # Skip header row

for table_row in table_rows:
table_cells = table_row.find_all("td")
if len(table_cells) < 2: # We only need first two columns (Code and Name)
continue

region_code = table_cells[0].text.strip()
region_name = table_cells[1].text.strip()

table_rows = table.find_all("tr")

for table_row in table_rows:
table_cells = table_row.find_all("td")
if len(table_cells) != 3:
continue
region_code = table_cells[0].text.strip()
region_name = table_cells[1].text.strip()

if region_code not in all_enabled_regions:
# Skip regions that are not enabled for the current account
continue

coordinates = self.retrieve_location(region_name)
regions[f"{Provider.AWS.value}:{region_code}"] = {
"name": region_name,
"provider": Provider.AWS.value,
"code": region_code,
"latitude": coordinates[0],
"longitude": coordinates[1],
}
self._aws_region_name_to_code[region_name] = region_code
if region_code not in all_enabled_regions:
# Skip regions that are not enabled for the current account
continue

coordinates = self.retrieve_location(region_name)
print(f"Coordinates for {region_name}: {coordinates}")
regions[f"{Provider.AWS.value}:{region_code}"] = {
"name": region_name,
"provider": Provider.AWS.value,
"code": region_code,
"latitude": coordinates[0],
"longitude": coordinates[1],
}
self._aws_region_name_to_code[region_name] = region_code
return regions

def retrieve_integrationtest_regions(self) -> dict[str, dict[str, Any]]:
Expand Down
2 changes: 1 addition & 1 deletion caribou/data_collector/utils/constants.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
AMAZON_REGION_URL = "https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html#concepts-available-regions" # pylint: disable=line-too-long
AMAZON_REGION_URL = "https://docs.aws.amazon.com/global-infrastructure/latest/regions/aws-regions.html#available-regions" # pylint: disable=line-too-long
CLOUD_PING = "https://www.cloudping.co/grid/"
Loading