From 9f51e75714f89c8a2d04c36e0f47bc15d05015fe Mon Sep 17 00:00:00 2001 From: JosepSampe Date: Tue, 22 Jul 2025 18:53:18 +0200 Subject: [PATCH] [Localhost] Potential fix for _copy_lithops_to_tmp --- lithops/localhost/v1/localhost.py | 5 +++-- lithops/localhost/v2/localhost.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lithops/localhost/v1/localhost.py b/lithops/localhost/v1/localhost.py index bc83c8505..5d2cd9cfc 100644 --- a/lithops/localhost/v1/localhost.py +++ b/lithops/localhost/v1/localhost.py @@ -213,8 +213,9 @@ def _copy_lithops_to_tmp(self): if is_lithops_worker() and os.path.isfile(RUNNER_FILE): return os.makedirs(LITHOPS_TEMP_DIR, exist_ok=True) - shutil.rmtree(os.path.join(LITHOPS_TEMP_DIR, 'lithops'), ignore_errors=True) - shutil.copytree(LITHOPS_LOCATION, os.path.join(LITHOPS_TEMP_DIR, 'lithops')) + dst_path = os.path.join(LITHOPS_TEMP_DIR, 'lithops') + shutil.rmtree(dst_path, ignore_errors=True) + shutil.copytree(LITHOPS_LOCATION, dst_path, dirs_exist_ok=True) src_handler = os.path.join(LITHOPS_LOCATION, 'localhost', 'v1', 'runner.py') copyfile(src_handler, RUNNER_FILE) diff --git a/lithops/localhost/v2/localhost.py b/lithops/localhost/v2/localhost.py index 357681689..a873104af 100644 --- a/lithops/localhost/v2/localhost.py +++ b/lithops/localhost/v2/localhost.py @@ -204,8 +204,9 @@ def _copy_lithops_to_tmp(self): if is_lithops_worker() and os.path.isfile(RUNNER_FILE): return os.makedirs(LITHOPS_TEMP_DIR, exist_ok=True) - shutil.rmtree(os.path.join(LITHOPS_TEMP_DIR, 'lithops'), ignore_errors=True) - shutil.copytree(LITHOPS_LOCATION, os.path.join(LITHOPS_TEMP_DIR, 'lithops')) + dst_path = os.path.join(LITHOPS_TEMP_DIR, 'lithops') + shutil.rmtree(dst_path, ignore_errors=True) + shutil.copytree(LITHOPS_LOCATION, dst_path, dirs_exist_ok=True) src_handler = os.path.join(LITHOPS_LOCATION, 'localhost', 'v2', 'runner.py') copyfile(src_handler, RUNNER_FILE)