@@ -87,8 +87,8 @@ def generate_statistics_from_tfrecord(
8787 if output_path is None :
8888 output_path = os .path .join (tempfile .mkdtemp (), 'data_stats.tfrecord' )
8989 output_dir_path = os .path .dirname (output_path )
90- if not tf .gfile .Exists (output_dir_path ):
91- tf .gfile .MakeDirs (output_dir_path )
90+ if not tf .io . gfile .exists (output_dir_path ):
91+ tf .io . gfile .makedirs (output_dir_path )
9292
9393 batch_size = (
9494 stats_options .desired_batch_size if stats_options .desired_batch_size
@@ -162,8 +162,8 @@ def generate_statistics_from_csv(
162162 if output_path is None :
163163 output_path = os .path .join (tempfile .mkdtemp (), 'data_stats.tfrecord' )
164164 output_dir_path = os .path .dirname (output_path )
165- if not tf .gfile .Exists (output_dir_path ):
166- tf .gfile .MakeDirs (output_dir_path )
165+ if not tf .io . gfile .exists (output_dir_path ):
166+ tf .io . gfile .makedirs (output_dir_path )
167167
168168 batch_size = (
169169 stats_options .desired_batch_size if stats_options .desired_batch_size
@@ -318,13 +318,13 @@ def get_csv_header(data_location: Text,
318318 ValueError: If any of the input files is not found or empty, or if the files
319319 have different headers.
320320 """
321- matched_files = tf .gfile .Glob (data_location )
321+ matched_files = tf .io . gfile .glob (data_location )
322322 if not matched_files :
323323 raise ValueError (
324324 'No file found in the input data location: %s' % data_location )
325325
326326 # Read the header line in the first file.
327- with tf .gfile .GFile (matched_files [0 ], 'r' ) as reader :
327+ with tf .io . gfile .GFile (matched_files [0 ], 'r' ) as reader :
328328 try :
329329 result = next (csv .reader (reader , delimiter = delimiter ))
330330 except StopIteration :
@@ -333,7 +333,7 @@ def get_csv_header(data_location: Text,
333333
334334 # Make sure that all files have the same header.
335335 for filename in matched_files [1 :]:
336- with tf .gfile .GFile (filename , 'r' ) as reader :
336+ with tf .io . gfile .GFile (filename , 'r' ) as reader :
337337 try :
338338 if next (csv .reader (reader , delimiter = delimiter )) != result :
339339 raise ValueError ('Files have different headers.' )
@@ -354,7 +354,7 @@ def load_statistics(
354354 Returns:
355355 A DatasetFeatureStatisticsList proto.
356356 """
357- serialized_stats = next (tf .python_io .tf_record_iterator (input_path ))
357+ serialized_stats = next (tf .compat . v1 . io .tf_record_iterator (input_path ))
358358 result = statistics_pb2 .DatasetFeatureStatisticsList ()
359359 result .ParseFromString (serialized_stats )
360360 return result
0 commit comments