From c59d26899523ed3c40990c144c9ca359177dc381 Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Wed, 7 Apr 2021 18:44:11 +0300 Subject: [PATCH] Fix venv cache crash on bad symbolic links --- clearml_agent/helper/os/folder_cache.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/clearml_agent/helper/os/folder_cache.py b/clearml_agent/helper/os/folder_cache.py index f0e6a39..16bdadc 100644 --- a/clearml_agent/helper/os/folder_cache.py +++ b/clearml_agent/helper/os/folder_cache.py @@ -152,7 +152,14 @@ class FolderCache(object): for f in source_folder.glob('*'): if f.name in exclude_sub_folders: continue - shutil.copytree(src=f.as_posix(), dst=(temp_folder / f.name).as_posix(), symlinks=True) + if f.is_dir(): + shutil.copytree( + src=f.as_posix(), dst=(temp_folder / f.name).as_posix(), + symlinks=True, ignore_dangling_symlinks=True) + else: + shutil.copy( + src=f.as_posix(), dst=(temp_folder / f.name).as_posix(), + follow_symlinks=False) # rename the target folder target_cache_folder = self._cache_folder / '.'.join(keys)