parameters: (argv)
docstring: Main program.
docstring_summary: Main program.
docstring_tokens: Main program .
function: def main(argv):
      """Main program.
      """
      del argv  # Unused
      total_games = FLAGS.training_games
      total_moves = FLAGS.training_moves
      fresh = FLAGS.training_fresh
      thin = FLAGS.training_thin
      batch_size = FLAGS.batch_size
      output_prefix = FLAGS.output_prefix
  
      spec = bigtable_input.BigtableSpec(
          FLAGS.cbt_project,
          FLAGS.cbt_instance,
          FLAGS.cbt_table)
      gq_r = bigtable_input.GameQueue(spec.project, spec.instance, spec.table)
      gq_c = bigtable_input.GameQueue(spec.project, spec.instance, spec.table + '-nr')
  
      mix = bigtable_input.mix_by_decile(total_games, total_moves, 9)
      bounds = list(training_series(gq_r.latest_game_number,
                                    gq_c.latest_game_number,
                                    mix,
                                    fresh))
      trainings = [(spec, start_r, start_c,
                    mix, batch_size,
                    '{}{:0>10}_{:0>10}.tfrecord.zz'.format(output_prefix, start_r, start_c))
                   for start_r, finish_r, start_c, finish_c
                   in bounds]
  
      if FLAGS.starting_game:
          game = FLAGS.starting_game
          starts = [t[1] for t in trainings]
          where = bisect.bisect_left(starts, game)
          trainings = trainings[where:]
  
      if FLAGS.max_trainings:
          trainings = trainings[:FLAGS.max_trainings]
  
      trainings = trainings[::thin]
  
      if FLAGS.dry_run:
          for t in trainings:
              print(t)
          raise SystemExit
  
      concurrency = min(FLAGS.concurrency, multiprocessing.cpu_count() * 2)
      with tqdm(desc='Training Sets', unit_scale=2, total=len(trainings)) as pbar:
          for b in utils.iter_chunks(concurrency, trainings):
              with multiprocessing.Pool(processes=concurrency) as pool:
                  pool.map(_export_training_set, b)
                  pbar.update(len(b))
function_tokens: def main ( argv ) : del argv # Unused total_games = FLAGS . training_games total_moves = FLAGS . training_moves fresh = FLAGS . training_fresh thin = FLAGS . training_thin batch_size = FLAGS . batch_size output_prefix = FLAGS . output_prefix spec = bigtable_input . BigtableSpec ( FLAGS . cbt_project , FLAGS . cbt_instance , FLAGS . cbt_table ) gq_r = bigtable_input . GameQueue ( spec . project , spec . instance , spec . table ) gq_c = bigtable_input . GameQueue ( spec . project , spec . instance , spec . table + '-nr' ) mix = bigtable_input . mix_by_decile ( total_games , total_moves , 9 ) bounds = list ( training_series ( gq_r . latest_game_number , gq_c . latest_game_number , mix , fresh ) ) trainings = [ ( spec , start_r , start_c , mix , batch_size , '{}{:0>10}_{:0>10}.tfrecord.zz' . format ( output_prefix , start_r , start_c ) ) for start_r , finish_r , start_c , finish_c in bounds ] if FLAGS . starting_game : game = FLAGS . starting_game starts = [ t [ 1 ] for t in trainings ] where = bisect . bisect_left ( starts , game ) trainings = trainings [ where : ] if FLAGS . max_trainings : trainings = trainings [ : FLAGS . max_trainings ] trainings = trainings [ : : thin ] if FLAGS . dry_run : for t in trainings : print ( t ) raise SystemExit concurrency = min ( FLAGS . concurrency , multiprocessing . cpu_count ( ) * 2 ) with tqdm ( desc = 'Training Sets' , unit_scale = 2 , total = len ( trainings ) ) as pbar : for b in utils . iter_chunks ( concurrency , trainings ) : with multiprocessing . Pool ( processes = concurrency ) as pool : pool . map ( _export_training_set , b ) pbar . update ( len ( b ) )