Skip to content

Commit b34be8e

Browse files
authored
Update convert.py with AtomicWriteFileHandle
1 parent 5f60a68 commit b34be8e

File tree

1 file changed

+4
-3
lines changed
  • tools/accuracy_checker/accuracy_checker/annotation_converters

1 file changed

+4
-3
lines changed

tools/accuracy_checker/accuracy_checker/annotation_converters/convert.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
)
3535
from ..data_readers import KaldiFrameIdentifier, KaldiMatrixIdentifier
3636
from ..utils import (
37-
get_path, OrderedSet, cast_to_bool, is_relative_to, start_telemetry, send_telemetry_event, end_telemetry
37+
get_path, OrderedSet, cast_to_bool, is_relative_to, start_telemetry, send_telemetry_event,
38+
end_telemetry, AtomicWriteFileHandle
3839
)
3940
from ..data_analyzer import BaseDataAnalyzer
4041
from .format_converter import BaseFormatConverter
@@ -327,7 +328,7 @@ def save_annotation(annotation, meta, annotation_file, meta_file, dataset_config
327328
annotation_dir = annotation_file.parent
328329
if not annotation_dir.exists():
329330
annotation_dir.mkdir(parents=True)
330-
with annotation_file.open('wb') as file:
331+
with AtomicWriteFileHandle(annotation_file,'wb') as file:
331332
if conversion_meta:
332333
pickle.dump(conversion_meta, file)
333334
for representation in annotation:
@@ -337,7 +338,7 @@ def save_annotation(annotation, meta, annotation_file, meta_file, dataset_config
337338
meta_dir = meta_file.parent
338339
if not meta_dir.exists():
339340
meta_dir.mkdir(parents=True)
340-
with meta_file.open('wt') as file:
341+
with AtomicWriteFileHandle(meta_file, 'wt') as file:
341342
json.dump(meta, file)
342343

343344

0 commit comments

Comments
 (0)