Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
landscapepainter committed Jul 16, 2024
1 parent e212ea2 commit beba84a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
11 changes: 6 additions & 5 deletions sky/adaptors/azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ def exceptions():

@functools.lru_cache()
@common.load_lazy_modules(modules=_LAZY_MODULES)
def get_client(name: str, subscription_id: Optional[str] = None, **kwargs) -> Client:
def get_client(name: str,
subscription_id: Optional[str] = None,
**kwargs) -> Client:
"""Creates and returns an Azure client for the specified service.
Args:
Expand Down Expand Up @@ -127,8 +129,8 @@ def get_client(name: str, subscription_id: Optional[str] = None, **kwargs) -> Cl
# Note: Checking a private container without credentials is
# faster (~0.2s) than checking a public container with
# credentials (~90s).
from azure.storage import blob
from azure.mgmt import storage
from azure.storage import blob
container_url = kwargs.pop('container_url', None)
assert container_url is not None, ('Must provide container_url'
' keyword arguments for '
Expand All @@ -146,13 +148,12 @@ def get_client(name: str, subscription_id: Optional[str] = None, **kwargs) -> Cl
credential, subscription_id)
storage_account_availability = (
storage_client.storage_accounts.check_name_availability(
{"name": storage_account_name}))
{'name': storage_account_name}))
if storage_account_availability.name_available:
with ux_utils.print_exception_no_traceback():
raise sky_exceptions.NonExistentStorageAccountError(
f'The storage account {storage_account_name!r} does '
'not exist. Please check if the name is correct and '
'the account is created.')
'not exist. Please check if the name is correct.')

# First, assume the URL is from a public container.
container_client = blob.ContainerClient.from_container_url(
Expand Down
1 change: 0 additions & 1 deletion sky/adaptors/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ def wrapper(*args, **kwargs):
m.load_module()
return func(*args, **kwargs)


return wrapper

return decorator
9 changes: 4 additions & 5 deletions sky/cloud_stores.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,17 +236,16 @@ def is_directory(self, url: str) -> bool:
storage_account_name=storage_account_name,
resource_group_name=resource_group_name,
refresh_client=refresh_client)

if not container_client.exists():
with ux_utils.print_exception_no_traceback():
raise sky_exceptions.StorageBucketGetError(
f'The provided container {container_name!r} from the '
f'passed endpoint url {url!r} does not exist. Please '
'check if the name is correct and the container is '
'created.')

'check if the name is correct.')

# If there aren't more than just container name and storage account,
# that's a directory.
# that's a directory.
# Note: This must be ran after existence of the storage account is
# checked while obtaining container client.
if not path:
Expand Down

0 comments on commit beba84a

Please sign in to comment.