diff --git a/python/ray/setup-dev.py b/python/ray/setup-dev.py index 31d722b8998..d26d377a65f 100755 --- a/python/ray/setup-dev.py +++ b/python/ray/setup-dev.py @@ -73,9 +73,27 @@ 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/_serve/" + 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 = 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__": parser = argparse.ArgumentParser(