Skip to content

Commit a003a8c

Browse files
committed
[utils] check if folder exists before attempting to create directory
Signed-off-by: kcirred <[email protected]>
1 parent 4335a9d commit a003a8c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

fms_mo/utils/calib_data.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,8 @@ def get_tokenized_data(
399399
if path_to_save:
400400
datasets.Dataset.from_list(traindataset).save_to_disk(path_to_save + "_train")
401401
if isinstance(testdataset, BatchEncoding):
402-
os.mkdir(path_to_save + "_test")
402+
if not os.path.exists(path_to_save + "_test"):
403+
os.mkdir(path_to_save + "_test")
403404
torch.save(testdataset, path_to_save + "_test/testdataset.pt")
404405
elif isinstance(testdataset, list):
405406
datasets.Dataset.from_list(testdataset).save_to_disk(path_to_save + "_test")

0 commit comments

Comments
 (0)