Skip to content

Commit

Permalink
auto refresh local images.csv
Browse files Browse the repository at this point in the history
  • Loading branch information
yika-luo committed Oct 25, 2024
1 parent ba3c6c7 commit 7aa2ba4
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions sky/clouds/service_catalog/azure_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
import re
from typing import Dict, List, Optional, Tuple

from sky import clouds as cloud_lib
from sky import clouds as cloud_lib, sky_logging
from sky.clouds import Azure
from sky.clouds.service_catalog import common
from sky.utils import resources_utils
from sky.utils import ux_utils

logger = sky_logging.init_logger(__name__)

# This list should match the list of regions in
# skypilot image generation Packer script's replication_regions
# sky/clouds/service_catalog/images/skypilot-azure-cpu-ubuntu.pkr.hcl
Expand Down Expand Up @@ -191,9 +193,16 @@ def list_accelerators(

def get_image_id_from_tag(tag: str, region: Optional[str]) -> Optional[str]:
"""Returns the image id from the tag."""
# Azure images are not region-specific.
del region # Unused.
return common.get_image_id_from_tag_impl(_image_df, tag, None)
global _image_df
image_id = common.get_image_id_from_tag_impl(_image_df, tag, region)
if image_id is None:
# Refresh the image catalog and try again, if the image tag is not
# found.
logger.debug('Refreshing the image catalog and trying again.')
_image_df = common.read_catalog('azure/images.csv',
pull_frequency_hours=0)
image_id = common.get_image_id_from_tag_impl(_image_df, tag, region)
return image_id


def is_image_tag_valid(tag: str, region: Optional[str]) -> bool:
Expand Down

0 comments on commit 7aa2ba4

Please sign in to comment.