def process_dataset(input_path, model_config, permute, num_repeats,
                    output_path):
  """Function that processes a dataset without multiprocessing."""
  fn = ConvertToSequenceExampleDoFn(
      model_config,
      FLAGS.generate_output,
      permute=permute,
      num_repeats=num_repeats)

  with tf.gfile.Open(input_path) as infile:
    examples = [NLToSQLExample().from_json(json.loads(line)) for line in infile]

  with tf.python_io.TFRecordWriter(output_path) as writer:
    num_examples_written = 0
    total_examples = 0
    for example in examples:
      total_examples += 1
      converteds = fn.non_parallel_process(example)
      if converteds:
        num_examples_written += 1
        for converted in converteds:
          writer.write(converted)
  print('Wrote to %d / %d to %s' %
        (num_examples_written, total_examples, output_path))
Function that processes a dataset without multiprocessing.
language/xsp/data_preprocessing/convert_to_tfrecords.py