Skip to content

Commit 0ad0b01

Browse files
authored
[Core] Make working_dir support files created before 1980 (ray-project#46634)
Signed-off-by: Jiajun Yao <jeromeyjj@gmail.com>
1 parent 5e16fd0 commit 0ad0b01

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

python/ray/_private/runtime_env/packaging.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ def _zip_directory(
393393
directory inside the zip file.
394394
"""
395395
pkg_file = Path(output_path).absolute()
396-
with ZipFile(pkg_file, "w") as zip_handler:
396+
with ZipFile(pkg_file, "w", strict_timestamps=False) as zip_handler:
397397
# Put all files in the directory into the zip file.
398398
dir_path = Path(directory).absolute()
399399

python/ray/tests/test_runtime_env_working_dir_2.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,28 @@ def g():
279279
ray.get(refs)
280280

281281

282+
def test_file_created_before_1980(shutdown_only, tmp_working_dir):
283+
# Make sure working_dir supports file created before 1980
284+
# https://github.com/ray-project/ray/issues/46379
285+
working_path = Path(tmp_working_dir)
286+
file_1970 = working_path / "1970"
287+
with file_1970.open(mode="w") as f:
288+
f.write("1970")
289+
os.utime(
290+
file_1970,
291+
(0, 0),
292+
)
293+
294+
ray.init(runtime_env={"working_dir": tmp_working_dir})
295+
296+
@ray.remote
297+
def task():
298+
with open("1970") as f:
299+
assert f.read() == "1970"
300+
301+
ray.get(task.remote())
302+
303+
282304
if __name__ == "__main__":
283305
if os.environ.get("PARALLEL_CI"):
284306
sys.exit(pytest.main(["-n", "auto", "--boxed", "-vs", __file__]))

0 commit comments

Comments
 (0)