|
19 | 19 |
|
20 | 20 | import csv |
21 | 21 | import hashlib |
22 | | -import json |
23 | 22 | import os |
24 | 23 | import random |
25 | 24 | import tempfile |
@@ -69,12 +68,6 @@ def _get_cache_filenames(cache_dir, model_spec, data_name, is_training): |
69 | 68 | return cache_tfrecord_file, cache_meta_data_file, cache_prefix |
70 | 69 |
|
71 | 70 |
|
72 | | -def _write_meta_data(meta_data_file, meta_data): |
73 | | - """Writes meta data into file.""" |
74 | | - with tf.io.gfile.GFile(meta_data_file, 'w') as f: |
75 | | - json.dump(meta_data, f) |
76 | | - |
77 | | - |
78 | 71 | def _get_cache_info(cache_dir, data_name, model_spec, is_training): |
79 | 72 | """Gets cache related information: whether is cached, related filenames.""" |
80 | 73 | if cache_dir is None: |
@@ -259,7 +252,7 @@ def _save_data(cls, examples, model_spec, label_names, tfrecord_file, |
259 | 252 | 'num_classes': len(label_names), |
260 | 253 | 'index_to_label': label_names |
261 | 254 | } |
262 | | - _write_meta_data(meta_data_file, meta_data) |
| 255 | + file_util.write_json_file(meta_data_file, meta_data) |
263 | 256 |
|
264 | 257 | @classmethod |
265 | 258 | def _get_cache_info(cls, cache_dir, data_name, model_spec, is_training): |
@@ -337,7 +330,7 @@ def from_squad(cls, |
337 | 330 | filename, model_spec, tfrecord_file, is_training, |
338 | 331 | version_2_with_negative) |
339 | 332 |
|
340 | | - _write_meta_data(meta_data_file, meta_data) |
| 333 | + file_util.write_json_file(meta_data_file, meta_data) |
341 | 334 |
|
342 | 335 | dataset, meta_data = _load(tfrecord_file, meta_data_file, model_spec, |
343 | 336 | is_training) |
|
0 commit comments