diff --git a/python/ray/_private/runtime_env/packaging.py b/python/ray/_private/runtime_env/packaging.py index abf854315155..7e386dba8607 100644 --- a/python/ray/_private/runtime_env/packaging.py +++ b/python/ray/_private/runtime_env/packaging.py @@ -393,7 +393,7 @@ def _zip_directory( directory inside the zip file. """ pkg_file = Path(output_path).absolute() - with ZipFile(pkg_file, "w") as zip_handler: + with ZipFile(pkg_file, "w", strict_timestamps=False) as zip_handler: # Put all files in the directory into the zip file. dir_path = Path(directory).absolute() diff --git a/python/ray/tests/test_runtime_env_working_dir_2.py b/python/ray/tests/test_runtime_env_working_dir_2.py index b70f2536f552..9fc3a9e70b4c 100644 --- a/python/ray/tests/test_runtime_env_working_dir_2.py +++ b/python/ray/tests/test_runtime_env_working_dir_2.py @@ -279,6 +279,28 @@ def g(): ray.get(refs) +def test_file_created_before_1980(shutdown_only, tmp_working_dir): + # Make sure working_dir supports file created before 1980 + # https://github.com/ray-project/ray/issues/46379 + working_path = Path(tmp_working_dir) + file_1970 = working_path / "1970" + with file_1970.open(mode="w") as f: + f.write("1970") + os.utime( + file_1970, + (0, 0), + ) + + ray.init(runtime_env={"working_dir": tmp_working_dir}) + + @ray.remote + def task(): + with open("1970") as f: + assert f.read() == "1970" + + ray.get(task.remote()) + + if __name__ == "__main__": if os.environ.get("PARALLEL_CI"): sys.exit(pytest.main(["-n", "auto", "--boxed", "-vs", __file__]))