Skip to content

Commit

Permalink
[runtime env] Clarify error message about where to install `smart_ope…
Browse files Browse the repository at this point in the history
…n` for remote URI (#32110)

At least two users reported encountering

ImportError(
                            "You must `pip install smart_open` and "
                            "`pip install boto3` to fetch URIs in s3 "
                            "bucket. "
and trying to fix it by specifying them in the pip field of runtime_env, which won't work because the runtime_env setup code doesn't run inside the runtime_env. This PR clarifies the error message to say that they must be preinstalled on the cluster, and adds a note to the docs.
  • Loading branch information
architkulkarni committed Feb 1, 2023
1 parent 1454e63 commit 909c220
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 2 additions & 1 deletion doc/source/ray-core/handling-dependencies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,8 @@ Currently, three types of remote URIs are supported for hosting ``working_dir``

- ``runtime_env = {"working_dir": "gs:https://example_bucket/example_file.zip"}``


Note that the ``smart_open``, ``boto3``, and ``google-cloud-storage`` packages are not installed by default, and it is not sufficient to specify them in the ``pip`` section of your ``runtime_env``.
The relevant packages must already be installed on all nodes of the cluster when Ray starts.

Hosting a Dependency on a Remote Git Provider: Step-by-Step Guide
-----------------------------------------------------------------
Expand Down
11 changes: 9 additions & 2 deletions python/ray/_private/runtime_env/packaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,11 @@ async def download_and_unpack_package(
elif protocol in Protocol.remote_protocols():
# Download package from remote URI
tp = None
install_warning = (
"Note that these must be preinstalled "
"on all nodes in the Ray cluster; it is not "
"sufficient to install them in the runtime_env."
)

if protocol == Protocol.S3:
try:
Expand All @@ -658,7 +663,7 @@ async def download_and_unpack_package(
raise ImportError(
"You must `pip install smart_open` and "
"`pip install boto3` to fetch URIs in s3 "
"bucket."
"bucket. " + install_warning
)
tp = {"client": boto3.client("s3")}
elif protocol == Protocol.GS:
Expand All @@ -670,6 +675,7 @@ async def download_and_unpack_package(
"You must `pip install smart_open` and "
"`pip install google-cloud-storage` "
"to fetch URIs in Google Cloud Storage bucket."
+ install_warning
)
elif protocol == Protocol.FILE:
pkg_uri = pkg_uri[len("file:https://") :]
Expand All @@ -683,7 +689,8 @@ def open_file(uri, mode, *, transport_params=None):
except ImportError:
raise ImportError(
"You must `pip install smart_open` "
f"to fetch {protocol.value.upper()} URIs."
f"to fetch {protocol.value.upper()} URIs. "
+ install_warning
)

with open_file(pkg_uri, "rb", transport_params=tp) as package_zip:
Expand Down

0 comments on commit 909c220

Please sign in to comment.