Skip to content

Commit 631e499

Browse files
committed
up
1 parent e0c4a07 commit 631e499

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

examples/apple/coreml/llama/extract_and_combine.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,25 @@
3434
output_dir = str(args.output_dir)
3535

3636
if os.path.exists(output_dir):
37-
shutil.rmtree(output_dir)
37+
raise Exception(f"Output directory {output_dir} already exists. Please make delete it before running script.")
3838
os.makedirs(output_dir)
3939

40+
coreml_extract_path = os.path.join(os.getcwd(), "extracted_coreml_models")
41+
if os.path.exists(coreml_extract_path):
42+
raise Exception(f"{coreml_extract_path} already exists. Please delete it before running script.")
43+
4044
extract_script_path = os.path.join(os.path.dirname(__file__), "../scripts/extract_coreml_models.py")
4145
extracted_path = "extracted_coreml_models/model_1/lowered_module/model.mlpackage"
4246

4347
subprocess.run(["python", extract_script_path, "--model", model1_path])
4448
items = os.listdir("extracted_coreml_models")
4549
assert len(items) == 1, "Expected one CoreML partition"
4650
shutil.copytree(extracted_path, f"{output_dir}/model1.mlpackage")
47-
shutil.rmtree("extracted_coreml_models")
4851

4952
subprocess.run(["python", extract_script_path, "--model", model2_path])
5053
items = os.listdir("extracted_coreml_models")
5154
assert len(items) == 1, "Expected one CoreML partition"
5255
shutil.copytree(extracted_path, f"{output_dir}/model2.mlpackage")
53-
shutil.rmtree("extracted_coreml_models")
54-
5556

5657
desc = ct.utils.MultiFunctionDescriptor()
5758

0 commit comments

Comments
 (0)