class_docstr: Chicago taxi dataset.
class_docstr_tok: ["Chicago","taxi","dataset","."]
docstr: Runs a Beam pipeline to convert the CSV file into a TFRecords file.
  
  This is needed because the conversion is orders of magnitude more
  time-consuming than the functions we want to benchmark, so instead of
  doing the conversion each time, we do it once to generate a converted
  dataset and use that for the benchmark instead.
  
  Args:
    csv_path: Path to CSV file containing examples.
    tfrecords_output_path: Path to output TFRecords file containing parsed
      examples.
docstr_tok: ["Runs","a","Beam","pipeline","to","convert","the","CSV","file","into","a","TFRecords","file",".","This","is","needed","because","the","conversion","is","orders","of","magnitude","more","time-consuming","than","the","functions","we","want","to","benchmark",",","so","instead","of","doing","the","conversion","each","time",",","we","do","it","once","to","generate","a","converted","dataset","and","use","that","for","the","benchmark","instead",".","Args",":","csv_path",":","Path","to","CSV","file","containing","examples",".","tfrecords_output_path",":","Path","to","output","TFRecords","file","containing","parsed","examples","."]
code: def convert_csv_to_tf_examples(self, csv_path, tfrecords_output_path):
      """Runs a Beam pipeline to convert the CSV file into a TFRecords file.
  
      This is needed because the conversion is orders of magnitude more
      time-consuming than the functions we want to benchmark, so instead of
      doing the conversion each time, we do it once to generate a converted
      dataset and use that for the benchmark instead.
  
      Args:
        csv_path: Path to CSV file containing examples.
        tfrecords_output_path: Path to output TFRecords file containing parsed
          examples.
      """
      # Copied from CSV example gen.
      fp = open(csv_path, "r")
      column_names = next(fp).strip().split(",")
      fp.close()
  
      with beam.Pipeline() as p:
          parsed_csv_lines = (
              p
              | "ReadFromText"
              >> beam.io.ReadFromText(
                  file_pattern=csv_path, skip_header_lines=1
              )
              | "ParseCSVLine"
              >> beam.ParDo(csv_decoder.ParseCSVLine(delimiter=","))
              | "ExtractParsedCSVLines" >> beam.Keys()
          )
  
          column_infos = beam.pvalue.AsSingleton(
              parsed_csv_lines
              | "InferColumnTypes"
              >> beam.CombineGlobally(
                  csv_decoder.ColumnTypeInferrer(
                      column_names, skip_blank_lines=True
                  )
              )
          )
          _ = (
              parsed_csv_lines
              | "ToTFExample"
              >> beam.ParDo(
                  csv_exgen._ParsedCsvToTfExample(),  # pylint: disable=protected-access
                  column_infos,
              )
              | "Serialize" >> beam.Map(lambda x: x.SerializeToString())
              | "WriteToTFRecord"
              >> beam.io.tfrecordio.WriteToTFRecord(
                  file_path_prefix=tfrecords_output_path,
                  shard_name_template="",
                  compression_type=beam.io.filesystem.CompressionTypes.GZIP,
              )
          )
  
imports: import itertools
  import math
  import os
  import shutil
  import tempfile
  from typing import Optional
  from absl import logging
  import apache_beam
  import tensorflow_transform
  from tfx import components
  from tfx.benchmarks import benchmark_dataset
  from tfx.components.example_gen.csv_example_gen import executor
  from tfx.examples.chicago_taxi_pipeline import taxi_utils
  from tfx.orchestration import metadata
  from tfx.orchestration import pipeline
  from tfx.orchestration.beam.beam_dag_runner import BeamDagRunner
  from tfx.proto import trainer_pb2
  from tfx_bsl.coders import csv_decoder
label_desc: Use image node_id 8 for calling the ChicagoTaxiDataset obj's underlying member method code with example usage: obj.convert_csv_to_tf_examples(csv_path, tfrecords_output_path) without return types