Skip to content

Commit

Permalink
[Cluster launcher] Add friendly warning for missing boto3 and googlea…
Browse files Browse the repository at this point in the history
…piclient imports (#39942)

Adds a friendlier warning when required packages for the cluster launcher are missing. boto3 in the case of AWS, and googleapiclient for GCP

Related issue number
Closes #39941

---------

Signed-off-by: Archit Kulkarni <[email protected]>
Signed-off-by: Archit Kulkarni <[email protected]>
  • Loading branch information
architkulkarni committed Nov 27, 2023
1 parent b21831e commit d7b0ac2
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions python/ray/autoscaler/_private/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,30 @@


def _import_aws(provider_config):
try:
# boto3 and botocore are imported in multiple places in the codebase,
# so we just import them here to ensure that they are installed.
import boto3 # noqa: F401
except ImportError as e:
raise ImportError(
"The Ray AWS VM launcher requires the AWS SDK for Python (Boto3) "
"to be installed. You can install it with `pip install boto3`."
) from e

from ray.autoscaler._private.aws.node_provider import AWSNodeProvider

return AWSNodeProvider


def _import_gcp(provider_config):
try:
import googleapiclient # noqa: F401
except ImportError as e:
raise ImportError(
"The Ray GCP VM launcher requires the Google API Client to be installed. "
"You can install it with `pip install google-api-python-client`."
) from e

from ray.autoscaler._private.gcp.node_provider import GCPNodeProvider

return GCPNodeProvider
Expand Down

0 comments on commit d7b0ac2

Please sign in to comment.