Spaces:
Sleeping
Sleeping
devjas1
commited on
Commit
·
86d081c
1
Parent(s):
8ce4090
(fix): ensure parent directory exists before saving output file
Browse files- scripts/run_inference.py +3 -0
scripts/run_inference.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import sys
|
2 |
import os
|
3 |
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
|
|
|
4 |
|
5 |
import argparse
|
6 |
import warnings
|
@@ -125,6 +126,8 @@ if __name__ == "__main__":
|
|
125 |
|
126 |
# 5. Save or stdout
|
127 |
if args.output:
|
|
|
|
|
128 |
with open(args.output, "w", encoding="utf-8") as fout:
|
129 |
fout.write(result)
|
130 |
logging.info("Result saved to %s", args.output)
|
|
|
1 |
import sys
|
2 |
import os
|
3 |
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
|
4 |
+
from pathlib import Path
|
5 |
|
6 |
import argparse
|
7 |
import warnings
|
|
|
126 |
|
127 |
# 5. Save or stdout
|
128 |
if args.output:
|
129 |
+
# ensure parent dir exists (e.g., outputs/inference/)
|
130 |
+
Path(args.output).parent.mkdir(parents=True, exist_ok=True)
|
131 |
with open(args.output, "w", encoding="utf-8") as fout:
|
132 |
fout.write(result)
|
133 |
logging.info("Result saved to %s", args.output)
|