Skip to content

Commit 2f1dbe5

Browse files
authored
[0.9.1][bugfix] fix file not found error with shutil.rmtree (#2506)
### What this PR does / why we need it? 1. fix FileNotFoundError when calling shutil.rmtree 2. add a suffix directory after `TORCHAIR_CACHE_HOME` to prevent accidental file deletion. ### Does this PR introduce any user-facing change? We've made a change to how the `TORCHAIR_CACHE_HOME` enviroment variable is utilized to enhance safety and prevent accidental file deletion by adding a suffix directory. ### How was this patch tested? e2e vllm serving and CI passed. Signed-off-by: linfeng-yuan <[email protected]>
1 parent 8dda7d9 commit 2f1dbe5

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

vllm_ascend/utils.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@
6868
KV_CACHE_BYTES_CACHE_PATH_NAME = ".kv_cache_bytes"
6969
KV_CACHE_BYTES_CACHE_FILE_NAME = "kv_cache_bytes"
7070
TORCHAIR_CACHE_PATH_NAME = ".torchair_cache"
71-
TORCHAIR_CACHE_DIR = os.getenv(
72-
'TORCHAIR_CACHE_HOME', os.path.join(os.getcwd(), TORCHAIR_CACHE_PATH_NAME))
71+
TORCHAIR_CACHE_DIR = os.path.join(
72+
os.getenv('TORCHAIR_CACHE_HOME', os.getcwd()), TORCHAIR_CACHE_PATH_NAME)
7373

7474

7575
def try_register_lib(lib_name: str, lib_info: str = ""):
@@ -450,5 +450,7 @@ def write_kv_cache_bytes_to_file(rank, kv_cache_bytes):
450450

451451
def delete_torchair_cache_file():
452452
torch_air_abs_path = get_torchair_current_work_dir()
453-
if os.path.exists(torch_air_abs_path):
453+
try:
454454
shutil.rmtree(torch_air_abs_path)
455+
except FileNotFoundError:
456+
pass

0 commit comments

Comments
 (0)