From d38171fe6eecfd654b8fb8b1ba1a4036964eba0e Mon Sep 17 00:00:00 2001 From: Yiwen Xie Date: Fri, 26 Sep 2025 13:35:17 -0700 Subject: [PATCH] fix rmtree failure in coreml export (#14632) Summary: Use actual temp directory instead of local folder "tmp/" to avoid rmtree failure. Reviewed By: limintang, metascroy Differential Revision: D83371990 --- backends/apple/coreml/compiler/coreml_preprocess.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backends/apple/coreml/compiler/coreml_preprocess.py b/backends/apple/coreml/compiler/coreml_preprocess.py index d1614f30451..16ace2e7a88 100644 --- a/backends/apple/coreml/compiler/coreml_preprocess.py +++ b/backends/apple/coreml/compiler/coreml_preprocess.py @@ -6,6 +6,7 @@ import logging import shutil +import tempfile import uuid from dataclasses import asdict, dataclass from enum import Enum @@ -415,7 +416,7 @@ def preprocess_model( mlmodel: ct.models.MLModel, model_type: MODEL_TYPE ) -> PreprocessResult: identifier = "executorch_" + str(uuid.uuid4()) - dir_path: Path = Path("tmp") / identifier + dir_path: Path = Path(tempfile.gettempdir()) / identifier model_dir_path: Path = dir_path / "lowered_module" model_spec: ct.proto.Model_pb2 = mlmodel.get_spec() logger.warning(