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..3ef40613 100644 --- a/test/pecos/xmc/xlinear/test_xlinear.py +++ b/test/pecos/xmc/xlinear/test_xlinear.py @@ -1138,7 +1138,6 @@ def test_on_model(model, X): def test_mmap(tmpdir): - from pathlib import Path from pecos.utils import smat_util from pecos.xmc.xlinear import XLinearModel from pecos.xmc import PostProcessor @@ -1153,7 +1152,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)