예제 #1
0
def get_files(files_dir, extension):
    if os.path.isfile(files_dir):
        files = [files_dir]
    elif os.path.isdir(files_dir):
        files = list(get_files_with_extension(files_dir, extension))
    else:
        raise ValueError(
            'Input path is not a valid file or directory: {}.'.format(
                args.replays))
    return files
예제 #2
0
    change_log_handler(os.path.join(args.output, 'learning.log'))

    # saves args
    with open(os.path.join(args.output, 'args.json'), 'w') as fp:
        json.dump(vars(args), fp, indent=4)

    # checks input files
    files = []
    if args.replays is None:
        logging.info(
            'No replay file provided, skipping parsing benchmark.'.format(
                args.replays))
    elif os.path.isfile(args.replays):
        files = [args.replays]
    elif os.path.isdir(args.replays):
        files = list(get_files_with_extension(args.replays, 'csv'))
    else:
        logging.info(
            'Provided replay path is not a valid file or directory: {}.'.
            format(args.replays))

    # create replayer and process all files
    if len(files) > 0:
        replayer = BenchmarkReplayer(files)
        replayer.process_files()

        files = sorted(replayer.trajectories.keys())
        lengths = np.array(
            [len(replayer.trajectories[filename]) for filename in files])
        times = np.array([replayer.timings[filename] for filename in files])
        logging.info(