Skip to content

Commit

Permalink
[Core] Fix aws dependency check (#2942)
Browse files Browse the repository at this point in the history
* Fix aws dependency check

* format

* format

* fix

* Update sky/clouds/aws.py

Co-authored-by: Zongheng Yang <[email protected]>

---------

Co-authored-by: Zongheng Yang <[email protected]>
  • Loading branch information
Michaelvll and concretevitamin authored Jan 4, 2024
1 parent e72d1f3 commit b13e9c6
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions sky/clouds/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,19 +461,28 @@ def _make(instance_list):
def check_credentials(cls) -> Tuple[bool, Optional[str]]:
"""Checks if the user has access credentials to this cloud."""

dependency_installation_hints = (
'AWS dependencies are not installed. '
'Run the following commands:'
f'\n{cls._INDENT_PREFIX} $ pip install skypilot[aws]'
f'\n{cls._INDENT_PREFIX}Credentials may also need to be set. '
f'{cls._STATIC_CREDENTIAL_HELP_STR}')

# Checks if the AWS CLI is installed properly
proc = subprocess.run('aws --version',
shell=True,
check=False,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
if proc.returncode != 0:
return False, (
'AWS CLI is not installed properly. '
'Run the following commands:'
f'\n{cls._INDENT_PREFIX} $ pip install skypilot[aws]'
f'\n{cls._INDENT_PREFIX}Credentials may also need to be set. '
f'{cls._STATIC_CREDENTIAL_HELP_STR}')
return False, dependency_installation_hints
try:
# Checks if aws boto is installed properly
# pylint: disable=import-outside-toplevel, unused-import
import boto3
import botocore
except ImportError:
return False, dependency_installation_hints

# Checks if AWS credentials 1) exist and 2) are valid.
# https://stackoverflow.com/questions/53548737/verify-aws-credentials-with-boto3
Expand Down

0 comments on commit b13e9c6

Please sign in to comment.