From 3d5b2bed3aa3a45aec250fa4d6607ea24eab20f3 Mon Sep 17 00:00:00 2001 From: Mimi Liao Date: Mon, 18 Nov 2024 18:45:11 -0600 Subject: [PATCH 1/2] preserve ray/serve/generated Signed-off-by: Mimi Liao --- python/ray/setup-dev.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/python/ray/setup-dev.py b/python/ray/setup-dev.py index 31d722b89984..40da6095ac0b 100755 --- a/python/ray/setup-dev.py +++ b/python/ray/setup-dev.py @@ -73,9 +73,25 @@ def do_link(package, force=False, skip_list=None, local_path=None): print("You don't have write permission " f"to {package_home}, using sudo:") sudo = ["sudo"] print(f"Creating symbolic link from \n {local_home} to \n {package_home}") + + # Preserve ray/serve/generated + if package == "serve": + # Copy generated folder to a temp dir + generated_folder = os.path.join(package_home, "generated") + temp_dir = "/tmp/ray/" + if not os.path.exists(temp_dir): + os.makedirs(temp_dir) + subprocess.check_call(["cp", "-r", generated_folder, temp_dir]) + subprocess.check_call(sudo + ["rm", "-rf", package_home]) subprocess.check_call(sudo + ["ln", "-s", local_home, package_home]) + # Move generated folder to local_home + if package == "serve": + tmp_generated_folder = "/tmp/ray/generated" + local_generated_folder = os.path.join(local_home, "generated") + subprocess.check_call(["mv", tmp_generated_folder, local_generated_folder]) + if __name__ == "__main__": parser = argparse.ArgumentParser( From fdb417fb55b648402dda7a8130b383c3cb42703e Mon Sep 17 00:00:00 2001 From: Mimi Liao Date: Wed, 20 Nov 2024 12:20:19 -0600 Subject: [PATCH 2/2] fix temp_dir to avoid collision Signed-off-by: Mimi Liao --- python/ray/setup-dev.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/python/ray/setup-dev.py b/python/ray/setup-dev.py index 40da6095ac0b..d26d377a65f5 100755 --- a/python/ray/setup-dev.py +++ b/python/ray/setup-dev.py @@ -78,7 +78,7 @@ def do_link(package, force=False, skip_list=None, local_path=None): if package == "serve": # Copy generated folder to a temp dir generated_folder = os.path.join(package_home, "generated") - temp_dir = "/tmp/ray/" + temp_dir = "/tmp/ray/_serve/" if not os.path.exists(temp_dir): os.makedirs(temp_dir) subprocess.check_call(["cp", "-r", generated_folder, temp_dir]) @@ -88,9 +88,11 @@ def do_link(package, force=False, skip_list=None, local_path=None): # Move generated folder to local_home if package == "serve": - tmp_generated_folder = "/tmp/ray/generated" - local_generated_folder = os.path.join(local_home, "generated") - subprocess.check_call(["mv", tmp_generated_folder, local_generated_folder]) + tmp_generated_folder = os.path.join(temp_dir, "generated") + package_generated_folder = os.path.join(package_home, "generated") + subprocess.check_call( + ["mv", tmp_generated_folder, package_generated_folder] + ) if __name__ == "__main__":