python/ray/_private/runtime_env/packaging.py
def parse_uri(pkg_uri: str) -> Tuple[Protocol, str]:
    """
    Parse resource uri into protocol and package name based on its format.
    Note that the output of this function is not for handling actual IO, it's
    only for setting up local directory folders by using package name as path.
    For GCS URIs, netloc is the package name.
        urlparse("gcs://_ray_pkg_029f88d5ecc55e1e4d64fc6e388fd103.zip")
            -> ParseResult(
                scheme='gcs',
                netloc='_ray_pkg_029f88d5ecc55e1e4d64fc6e388fd103.zip'
            )
            -> ("gcs", "_ray_pkg_029f88d5ecc55e1e4d64fc6e388fd103.zip")
    For HTTPS URIs, the netloc will have '.' replaced with '_', and
    the path will have '/' replaced with '_'. The package name will be the
    adjusted path with 'https_' prepended.
        urlparse(
            "https://github.com/shrekris-anyscale/test_module/archive/HEAD.zip"
        )
            -> ParseResult(
                scheme='https',
                netloc='github.com',
                path='/shrekris-anyscale/test_repo/archive/HEAD.zip'
            )
            -> ("https",
            "github_com_shrekris-anyscale_test_repo_archive_HEAD.zip")
    For S3 URIs, the bucket and path will have '/' replaced with '_'. The
    package name will be the adjusted path with 's3_' prepended.
        urlparse("s3://bucket/dir/file.zip")
            -> ParseResult(
                scheme='s3',
                netloc='bucket',
                path='/dir/file.zip'
            )
            -> ("s3", "bucket_dir_file.zip")
    For GS URIs, the path will have '/' replaced with '_'. The package name
    will be the adjusted path with 'gs_' prepended.
        urlparse("gs://public-runtime-env-test/test_module.zip")
            -> ParseResult(
                scheme='gs',
                netloc='public-runtime-env-test',
                path='/test_module.zip'
            )
            -> ("gs",
            "gs_public-runtime-env-test_test_module.zip")
    """
    uri = urlparse(pkg_uri)
    protocol = Protocol(uri.scheme)
    if protocol == Protocol.S3 or protocol == Protocol.GS:
        return (protocol, f"{protocol.value}_{uri.netloc}{uri.path.replace('/', '_')}")
    elif protocol == Protocol.HTTPS:
        return (
            protocol,
            f"https_{uri.netloc.replace('.', '_')}{uri.path.replace('/', '_')}",
        )
    else:
        return (protocol, uri.netloc)

    Parse resource uri into protocol and package name based on its format.
    Note that the output of this function is not for handling actual IO, it's
    only for setting up local directory folders by using package name as path.
    For GCS URIs, netloc is the package name.
        urlparse("gcs://_ray_pkg_029f88d5ecc55e1e4d64fc6e388fd103.zip")
            -> ParseResult(
                scheme='gcs',
                netloc='_ray_pkg_029f88d5ecc55e1e4d64fc6e388fd103.zip'
            )
            -> ("gcs", "_ray_pkg_029f88d5ecc55e1e4d64fc6e388fd103.zip")
    For HTTPS URIs, the netloc will have '.' replaced with '_', and
    the path will have '/' replaced with '_'. The package name will be the
    adjusted path with 'https_' prepended.
        urlparse(
            "https://github.com/shrekris-anyscale/test_module/archive/HEAD.zip"
        )
            -> ParseResult(
                scheme='https',
                netloc='github.com',
                path='/shrekris-anyscale/test_repo/archive/HEAD.zip'
            )
            -> ("https",
            "github_com_shrekris-anyscale_test_repo_archive_HEAD.zip")
    For S3 URIs, the bucket and path will have '/' replaced with '_'. The
    package name will be the adjusted path with 's3_' prepended.
        urlparse("s3://bucket/dir/file.zip")
            -> ParseResult(
                scheme='s3',
                netloc='bucket',
                path='/dir/file.zip'
            )
            -> ("s3", "bucket_dir_file.zip")
    For GS URIs, the path will have '/' replaced with '_'. The package name
    will be the adjusted path with 'gs_' prepended.
        urlparse("gs://public-runtime-env-test/test_module.zip")
            -> ParseResult(
                scheme='gs',
                netloc='public-runtime-env-test',
                path='/test_module.zip'
            )
            -> ("gs",
            "gs_public-runtime-env-test_test_module.zip")
    
Parse resource uri into protocol and package name based on its format.
Note that the output of this function is not for handling actual IO, it's
only for setting up local directory folders by using package name as path.
For GCS URIs, netloc is the package name.
Parse resource uri into protocol and package name based on its format . Note that the output of this function is not for handling actual IO it ' s only for setting up local directory folders by using package name as path . For GCS URIs netloc is the package name .
def parse_uri(pkg_uri: str) -> Tuple[Protocol, str]:
    uri = urlparse(pkg_uri)
    protocol = Protocol(uri.scheme)
    if protocol == Protocol.S3 or protocol == Protocol.GS:
        return (protocol, f"{protocol.value}_{uri.netloc}{uri.path.replace('/', '_')}")
    elif protocol == Protocol.HTTPS:
        return (
            protocol,
            f"https_{uri.netloc.replace('.', '_')}{uri.path.replace('/', '_')}",
        )
    else:
        return (protocol, uri.netloc)
def parse_uri ( pkg_uri : str ) -> Tuple [ Protocol , str ] : uri = urlparse ( pkg_uri ) protocol = Protocol ( uri . scheme ) if protocol == Protocol . S3 or protocol == Protocol . GS : return ( protocol , f"{protocol.value}_{uri.netloc}{uri.path.replace('/', '_')}" ) elif protocol == Protocol . HTTPS : return ( protocol , f"https_{uri.netloc.replace('.', '_')}{uri.path.replace('/', '_')}" , ) else : return ( protocol , uri . netloc )
Parse resource uri into protocol and package name based on its format.
Parse resource uri into protocol and package name based on its format .
"""
    Parse resource uri into protocol and package name based on its format.
    Note that the output of this function is not for handling actual IO, it's
    only for setting up local directory folders by using package name as path.
    For GCS URIs, netloc is the package name.
        urlparse("gcs://_ray_pkg_029f88d5ecc55e1e4d64fc6e388fd103.zip")
            -> ParseResult(
                scheme='gcs',
                netloc='_ray_pkg_029f88d5ecc55e1e4d64fc6e388fd103.zip'
            )
            -> ("gcs", "_ray_pkg_029f88d5ecc55e1e4d64fc6e388fd103.zip")
    For HTTPS URIs, the netloc will have '.' replaced with '_', and
    the path will have '/' replaced with '_'. The package name will be the
    adjusted path with 'https_' prepended.
        urlparse(
            "https://github.com/shrekris-anyscale/test_module/archive/HEAD.zip"
        )
            -> ParseResult(
                scheme='https',
                netloc='github.com',
                path='/shrekris-anyscale/test_repo/archive/HEAD.zip'
            )
            -> ("https",
            "github_com_shrekris-anyscale_test_repo_archive_HEAD.zip")
    For S3 URIs, the bucket and path will have '/' replaced with '_'. The
    package name will be the adjusted path with 's3_' prepended.
        urlparse("s3://bucket/dir/file.zip")
            -> ParseResult(
                scheme='s3',
                netloc='bucket',
                path='/dir/file.zip'
            )
            -> ("s3", "bucket_dir_file.zip")
    For GS URIs, the path will have '/' replaced with '_'. The package name
    will be the adjusted path with 'gs_' prepended.
        urlparse("gs://public-runtime-env-test/test_module.zip")
            -> ParseResult(
                scheme='gs',
                netloc='public-runtime-env-test',
                path='/test_module.zip'
            )
            -> ("gs",
            "gs_public-runtime-env-test_test_module.zip")
    """
pkg_uri
str