All of the magic together.

def main(unusedargv):
    """All of the magic together."""
    del unusedargv

    bt_table = (bigtable
                .Client(FLAGS.cbt_project, admin=True)
                .instance(FLAGS.cbt_instance)
                .table(FLAGS.cbt_table))
    assert bt_table.exists(), "Table doesn't exist"

    # Get current game counter, updates are conditioned on this matching.
    last_game = latest_game_number(bt_table)
    print("eval_game_counter:", last_game)
    print()

    # Get existing SGF paths so we avoid uploading duplicates
    existing_paths = read_existing_paths(bt_table)
    print("Found {} existing".format(len(existing_paths)))
    if existing_paths:
        duplicates = Counter(existing_paths)
        existing_paths = set(existing_paths)

        for k, v in duplicates.most_common():
            if v == 1:
                break
            print("{}x{}".format(v, k))

        print("\tmin:", min(existing_paths))
        print("\tmax:", max(existing_paths))
        print()

    # Get all SGFs that match glob, skipping SGFs with existing records.
    data = read_games(FLAGS.sgf_glob, existing_paths)
    if data:
        write_eval_records(bt_table, data, last_game)