From 3960b69f90e3da0344f6338f5e165fa7b5665328 Mon Sep 17 00:00:00 2001 From: Sergei Sokolov Date: Mon, 27 May 2024 19:20:48 +0700 Subject: [PATCH] Support of reading Working dir from HUAWEI Object Storage Service (OBS) Signed-off-by: Sergei Sokolov --- python/ray/_private/runtime_env/packaging.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/python/ray/_private/runtime_env/packaging.py b/python/ray/_private/runtime_env/packaging.py index abf85431515510..8269ce159e7b1b 100644 --- a/python/ray/_private/runtime_env/packaging.py +++ b/python/ray/_private/runtime_env/packaging.py @@ -89,13 +89,14 @@ def __new__(cls, value, doc=None): HTTPS = "https", "Remote https path, assumes everything packed in one zip file." S3 = "s3", "Remote s3 path, assumes everything packed in one zip file." GS = "gs", "Remote google storage path, assumes everything packed in one zip file." + OBS = "obs", "Remote huawei object storage service path, assumes everything packed in one zip file." FILE = "file", "File storage path, assumes everything packed in one zip file." @classmethod def remote_protocols(cls): # Returns a list of protocols that support remote storage # These protocols should only be used with paths that end in ".zip" or ".whl" - return [cls.HTTPS, cls.S3, cls.GS, cls.FILE] + return [cls.HTTPS, cls.S3, cls.GS, cls.FILE, cls.OBS] def _xor_bytes(left: bytes, right: bytes) -> bytes: @@ -719,6 +720,16 @@ async def download_and_unpack_package( "to fetch URIs in Google Cloud Storage bucket." + install_warning ) + elif protocol == Protocol.OBS: + try: + from obs import ObsClient # noqa: F401 + from smart_open import open as open_file + except ImportError: + raise ImportError( + "You must `pip install smart_open` and " + "`pip install esdk-obs-python` to fetch URIs in obs " + "bucket. " + install_warning + ) elif protocol == Protocol.FILE: pkg_uri = pkg_uri[len("file://") :]