Пример #1
0
def load_nodes_old(fname):

    executables = []

    if not(os.path.isfile(fname)):
        raise Exception("Tree file not found")

    with open(fname, 'r') as f:
        data = json.load(f)
        root = rebuild_tree(data);

    if root is None:
        raise Exception("Parsing failed")

    args = generate_params_preorder(root)

    for a in args:
        if a[2] > (sys.maxint >> 31):
            print("Casting parameters to avoid overflow")
            den = sys.maxint >> 31
            a[1] = a[1] * den / a[2]
            a[2] = den
        executables.append(Executable(BINS['run_add_node'], a))

    return executables
Пример #2
0
def load_schedule(name, fname, duration):
    '''Turn schedule file @fname into ProcEntry's and Executable's which execute
    for @duration time.'''
    with open(fname, 'r') as f:
        data = f.read().strip()
    try:
        schedule = eval(data)
    except:
        schedule = convert_data(data)

    sched_dir = os.path.split(fname)[0]

    # Make paths relative to the file's directory
    fix_paths(schedule, sched_dir, fname)

    proc_entries = []
    executables  = []

    # Create proc entries
    for entry_conf in schedule['proc']:
        proc_entries += [ProcEntry(*entry_conf)]

    # Create executables
    for task_conf in schedule['task']:
        if len(task_conf) != 2:
            raise Exception("Invalid task conf %s: %s" % (task_conf, name))

        (task, args) = (task_conf[0], task_conf[1])

        real_task = com.get_executable(task, sched_dir)

        # Last argument must always be duration
        real_args = args.split() + [duration]

        # Get the name of the task (for after-processing and matching with pid).
        # If it exists, it is flagged as '-n'
        task_id = ""
        i = 0
        while i<len(real_args):
            if real_args[i] == "-n":
                task_id = real_args[i+1]
                real_args.pop(i) # remove '-n' from args
                real_args.pop(i) # remove 'taskname' from args
                break
            i+=1

        # All spins take a -w flag
        if re.match(".*spin$", real_task) and '-w' not in real_args:
            real_args = ['-w'] + real_args

        executables += [Executable(real_task, real_args, taskid=task_id)]

    return proc_entries, executables
Пример #3
0
def run_script(script_params, exp, exp_dir, out_dir):
    '''Run an executable (arguments optional)'''
    if not script_params:
        return

    # Split into arguments and program name
    if type(script_params) != type([]):
        script_params = [script_params]

    exp.log("Running %s" % script_params.join(" "))

    script_name = script_params.pop(0)
    script = com.get_executable(script_name, cwd=exp_dir)

    out = open('%s/%s-out.txt' % (out_dir, script_name), 'w')
    prog = Executable(script,
                      script_params,
                      cwd=out_dir,
                      stderr_file=out,
                      stdout_file=out)

    prog.execute()
    prog.wait()

    out.close()
Пример #4
0
def run_script(script_params, exp, exp_dir, out_dir):
    '''Run an executable (arguments optional)'''
    if not script_params:
        return

    # Split into arguments and program name
    if type(script_params) != type([]):
        script_params = [script_params]

    exp.log("Running %s" % " ".join(script_params))

    script_name = script_params.pop(0)
    script = com.get_executable(script_name, cwd=exp_dir)

    out  = open('%s/%s-out.txt' % (out_dir, script_name), 'w')
    prog = Executable(script, script_params, cwd=out_dir,
                      stderr_file=out, stdout_file=out)

    prog.execute()
    prog.wait()

    out.close()
Пример #5
0
def run_parameter(exp_dir, out_dir, params, param_name):
    '''Run an executable (arguments optional) specified as a configurable
    @param_name in @params.'''
    if conf.PARAMS[param_name] not in params:
        return

    script_params = params[conf.PARAMS[param_name]]

    # Split into arguments and program name
    if type(script_params) != type([]):
        script_params = [script_params]
    script_name = script_params.pop(0)

    script = com.get_executable(script_name, cwd=exp_dir)

    out  = open('%s/%s-out.txt' % (out_dir, param_name), 'w')
    prog = Executable(script, script_params, cwd=out_dir,
                      stderr_file=out, stdout_file=out)

    prog.execute()
    prog.wait()

    out.close()
Пример #6
0
def load_nodes(fname):

    executables = []

    if not(os.path.isfile(fname)):
        raise Exception("Tree file not found")

    with open(fname, 'r') as f:
        data = json.load(f)
        root = rebuild_tree(data);

    if root is None:
        raise Exception("Parsing failed")

    executables.append(Executable(BINS['run_add_node'], [fname]))

    return executables
Пример #7
0
def load_masters(fname):
    args = []
    executables = []

    with open(fname, 'r') as f:
        csvreader = csv.reader(f, delimiter=' ')
        for row in csvreader:
            args.append(row)

    for a in args:
        if long(a[4]) > (sys.maxint >> 31):
            print("Casting parameters to avoid overflow")
            den = (sys.maxint >> 31)
            num = int(long(a[3]) * den / long(a[4]))
            a[3] = str(num)
            a[4] = str(den)
        executables.append(Executable(BINS['qps_add_master'], a))

    return executables
Пример #8
0
def load_schedule(name, fname, duration):
    '''Turn schedule file @fname into ProcEntry's and Executable's which execute
    for @duration time.'''
    with open(fname, 'r') as f:
        data = f.read().strip()
    try:
        schedule = eval(data)
    except:
        schedule = convert_data(data)

    sched_dir = os.path.split(fname)[0]

    # Make paths relative to the file's directory
    fix_paths(schedule, sched_dir, fname)

    proc_entries = []
    executables = []

    # Create proc entries
    for entry_conf in schedule['proc']:
        proc_entries += [ProcEntry(*entry_conf)]

    # Create executables
    for task_conf in schedule['task']:
        if len(task_conf) != 2:
            raise Exception("Invalid task conf %s: %s" % (task_conf, name))

        (task, args) = (task_conf[0], task_conf[1])

        real_task = com.get_executable(task, sched_dir)

        # Last argument must always be duration
        real_args = args.split() + [duration]

        # All spins take a -w flag
        if re.match(".*spin$", real_task) and '-w' not in real_args:
            real_args = ['-w'] + real_args

        executables += [Executable(real_task, real_args)]

    return proc_entries, executables