Skip to content

Commit f8902cc

Browse files
author
Jonathan Van Eenwyk
committed
Ensure output directory exists
If needed, create the directory for the intended output file. This allows outputs to be grouped into subdirectories instead of only in the main history directory.
1 parent 95f15c4 commit f8902cc

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

openhtf/output/callbacks/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import collections
2424
import contextlib
25+
import os
2526
import shutil
2627
import tempfile
2728

@@ -82,6 +83,10 @@ def serialize_test_record(test_record):
8283
@staticmethod
8384
def open_file(filename):
8485
"""Override method to alter file open behavior or file types."""
86+
basepath = os.path.dirname(filename)
87+
if not os.path.exists(basepath):
88+
os.makedirs(basepath)
89+
8590
return Atomic(filename)
8691

8792
def create_file_name(self, test_record):

0 commit comments

Comments
 (0)