<commit_before>
from optparse import OptionParser
import subprocess
import re
import os

def get_cuda_version():
    # Get CUDA version
    nvcc_out_filename = "nvcc_out.txt"
    nvcc_out_file = open(nvcc_out_filename, 'w+')
    subprocess.call(["nvcc", "--version"],\
                   stdout=nvcc_out_file)
    nvcc_out_file.seek(0)
    cuda_version = re.sub(r".*release (\d+\.\d+).*", r"\1", nvcc_out_file.read().strip().replace("\n"," "))
    nvcc_out_file.close()
    os.remove(nvcc_out_filename)
    return cuda_version

# This function exists so that this file can accept both absolute and relative paths
# If no name is provided it sets the default
# Either way it does a test if the absolute path exists and if not, tries a relative path
def file_option_test(name, default, this_directory):
    if name == "":
        name = os.path.join(this_directory, default)
    try:
        with open(name): pass
    except IOError:
        name = os.path.join(os.getcwd(), name)
        try:
            with open(name): pass
        except IOError:
            exit("Error - cannot open file {0}".format(name))
    return name

def dir_option_test(name, default, this_directory):
    if name == "":
        name = os.path.join(this_directory, default)
    if not os.path.isdir(name):
        name = os.path.join(os.getcwd(), name)
        if not os.path.isdir(name):
            sys.exit("Error - cannot open file {0}".format(name))
    return name

def parse_run_simulations_options():
    parser = OptionParser()
    parser.add_option("-c", "--configs_file", dest="configs_file",
                  help="configs_file used to determine which configurations are run",
                  default="")
    parser.add_option("-b", "--benchmark_file", dest="benchmark_file",
                  help="the yaml file used to define which benchmarks are run",<commit_msg>Small error when printing an error :)<commit_after>
from optparse import OptionParser
import subprocess
import re
import os

def get_cuda_version():
    # Get CUDA version
    nvcc_out_filename = "nvcc_out.txt"
    nvcc_out_file = open(nvcc_out_filename, 'w+')
    subprocess.call(["nvcc", "--version"],\
                   stdout=nvcc_out_file)
    nvcc_out_file.seek(0)
    cuda_version = re.sub(r".*release (\d+\.\d+).*", r"\1", nvcc_out_file.read().strip().replace("\n"," "))
    nvcc_out_file.close()
    os.remove(nvcc_out_filename)
    return cuda_version

# This function exists so that this file can accept both absolute and relative paths
# If no name is provided it sets the default
# Either way it does a test if the absolute path exists and if not, tries a relative path
def file_option_test(name, default, this_directory):
    if name == "":
        name = os.path.join(this_directory, default)
    try:
        with open(name): pass
    except IOError:
        name = os.path.join(os.getcwd(), name)
        try:
            with open(name): pass
        except IOError:
            exit("Error - cannot open file {0}".format(name))
    return name

def dir_option_test(name, default, this_directory):
    if name == "":
        name = os.path.join(this_directory, default)
    if not os.path.isdir(name):
        name = os.path.join(os.getcwd(), name)
        if not os.path.isdir(name):
            exit("Error - cannot open file {0}".format(name))
    return name

def parse_run_simulations_options():
    parser = OptionParser()
    parser.add_option("-c", "--configs_file", dest="configs_file",
                  help="configs_file used to determine which configurations are run",
                  default="")
    parser.add_option("-b", "--benchmark_file", dest="benchmark_file",
                  help="the yaml file used to define which benchmarks are run",
{'fraction_non_alphanumeric': 0.11945483698556922, 'fraction_numerical': 0.002137894174238375, 'mean_word_length': 2.8908523908523907, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7341307', 'n_tokens_mistral': 1155, 'n_tokens_neox': 1142, 'n_words': 329}