From 9d08d281657991ca8785f339feec7b1169025be6 Mon Sep 17 00:00:00 2001 From: jianhao peng Date: Thu, 22 Feb 2024 22:56:25 +0000 Subject: [PATCH] bug fix: generate directory if path not exist in compile_mmap_model --- pecos/xmc/xlinear/model.py | 2 ++ test/pecos/xmc/xlinear/test_xlinear.py | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pecos/xmc/xlinear/model.py b/pecos/xmc/xlinear/model.py index 98a7ab38..49afadf1 100644 --- a/pecos/xmc/xlinear/model.py +++ b/pecos/xmc/xlinear/model.py @@ -144,6 +144,8 @@ def compile_mmap_model(cls, npz_folder, mmap_folder): """ import shutil + if not path.exists(mmap_folder): + os.makedirs(mmap_folder) shutil.copyfile(path.join(npz_folder, "param.json"), path.join(mmap_folder, "param.json")) HierarchicalMLModel.compile_mmap_model( path.join(npz_folder, "ranker"), path.join(mmap_folder, "ranker") diff --git a/test/pecos/xmc/xlinear/test_xlinear.py b/test/pecos/xmc/xlinear/test_xlinear.py index 3d393d51..a671a82c 100644 --- a/test/pecos/xmc/xlinear/test_xlinear.py +++ b/test/pecos/xmc/xlinear/test_xlinear.py @@ -1153,7 +1153,6 @@ def test_mmap(tmpdir): npz_model_folder = str(tmpdir.join("save_model_npz")) mmap_model_folder = str(tmpdir.join("save_model_mmap")) - Path(mmap_model_folder).mkdir(parents=True, exist_ok=True) py_model.save(npz_model_folder) XLinearModel.compile_mmap_model(npz_model_folder, mmap_model_folder) mmap_model = XLinearModel.load(mmap_model_folder, is_predict_only=True)