Skip to content

Commit

Permalink
[Feat][Core] Implement single file module for runtime_env (ray-projec…
Browse files Browse the repository at this point in the history
…t#47807)

Supports single file modules in `py_module` runtime_env.

Signed-off-by: Chi-Sheng Liu <[email protected]>
Signed-off-by: ujjawal-khare <[email protected]>
  • Loading branch information
MortalHappiness authored and ujjawal-khare committed Oct 15, 2024
1 parent b744185 commit 58d1523
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions python/ray/_private/runtime_env/packaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ def _hash_file_content_or_directory_name(
) -> bytes:
"""Helper function to create hash of a single file or directory.
This function hashes the path of the file or directory,
and if it's a file, then it hashes its content too.
This function will hash the path of the file or directory,
and if it's a file, it'll hash its content too.
"""

BUF_SIZE = 4096 * 1024
Expand All @@ -156,7 +156,7 @@ def _hash_file_content_or_directory_name(
except Exception as e:
logger.debug(
f"Skipping contents of file {filepath} when calculating package hash "
f"because the file couldn't be opened: {e}"
f"because the file could not be opened: {e}"
)
else:
try:
Expand All @@ -177,7 +177,7 @@ def _hash_file(
) -> bytes:
"""Helper function to create hash of a single file.
It hashes the path of the file and its content to create a hash value.
It'll hash the path of the file and its content to create a hash value.
"""
file_hash = _hash_file_content_or_directory_name(
filepath, relative_path, logger=logger
Expand Down Expand Up @@ -490,10 +490,9 @@ def get_uri_for_package(package: Path) -> str:
def get_uri_for_file(file: str) -> str:
"""Get a content-addressable URI from a file's content.
This function generates the name of the package by the file.
The final package name is _ray_pkg_<HASH_VAL>.zip of this package,
where HASH_VAL is the hash value of the file.
For example: _ray_pkg_029f88d5ecc55e1e4d64fc6e388fd103.zip
This function will generate the name of the package by the file.
The final package name is: _ray_pkg_<HASH_VAL>.zip of this package.
e.g., _ray_pkg_029f88d5ecc55e1e4d64fc6e388fd103.zip
Examples:
Expand Down

0 comments on commit 58d1523

Please sign in to comment.