def run_job(host, job): tpl = common.get_command(host, job) command = tpl[0] args = tpl[1] argv = [command] argv.extend(args) common.exec_job(argv)
def main(): kwargs = common.get_default_kwargs(args) job_gen_type = "direct" template_dir = common.get_template_dir(job_gen_type) kwargs["command"] = common.get_command(args.unique_id) output_dir = common.get_output_dir("multi-level", args) assert os.path.isdir(template_dir), template_dir assert os.path.isdir(output_dir), output_dir if args.small_scale: num_nodes = 2 topologies = [[1], [4], [2, 4]] elif args.medium_scale: num_nodes = 8 topologies = [[1], [4], [2, 4]] else: num_nodes = 32 topologies = [[1], [1, num_nodes], [1, num_nodes, num_cores_per_node]] repetitions = range(1) if args.small_scale or args.medium_scale else range(3) if args.repetitions: repetitions = range(args.repetitions) for repetition in repetitions: variable_num_jobs( template_dir, output_dir, job_gen_type, topologies, num_nodes, repetition, **kwargs, )
def run_job(host,job): tpl = common.get_command(host,job) command = tpl[0] args = tpl[1] argv = [command] argv.extend(args) common.exec_job(argv)
def main(): kwargs = common.get_default_kwargs(args) job_gen_type = "direct" template_dir = common.get_template_dir(job_gen_type) kwargs["command"] = common.get_command(args.unique_id) output_dir = common.get_output_dir("model", args) assert os.path.isdir(template_dir), template_dir assert os.path.isdir(output_dir), output_dir num_nodes = 32 topologies = [[1], [1, num_nodes], [1, num_nodes, num_cores_per_node]] repetitions = range(1) if args.small_scale or args.medium_scale else range( 3) if args.repetitions: repetitions = range(args.repetitions) for repetition in repetitions: build_model(template_dir, output_dir, job_gen_type, repetition, **kwargs) just_hierarchy_setup( template_dir, output_dir, job_gen_type, topologies, num_nodes, repetition, **kwargs, )
def run_job(host, job): tpl = common.get_command(host, job) command = tpl[0] args = tpl[1] argv = ["ssh", "-t", "%s@%s" % (host["ssh_user"], host["ssh_host"]), command] argv.extend(args) common.exec_job(argv)
def run_job(host,job): tpl = common.get_command(host,job) command = tpl[0] args = tpl[1] argv = ["VBoxManage", "--nologo", "guestcontrol", host["vbox_name"], "execute", "--image", command, "--username", host["vbox_user"], "--password", host["vbox_pass"], "--wait-exit", "--wait-stdout", "--verbose"] if len(args) != 0: argv.append("--") argv.extend(args) common.exec_job(argv)
def run_job(host, job): tpl = common.get_command(host, job) command = tpl[0] args = tpl[1] argv = [ "ssh", "-t", "%s@%s" % (host["ssh_user"], host["ssh_host"]), command ] argv.extend(args) common.exec_job(argv)
def set_meta_and_check(meta, obj_name, value, attr=None, role="PWR_ROLE_RM", method=None, desc=None, expect=EXPECT_SUCCESS): """Set one metadata value associated with an object/attribute, verify that the change was made, and restore the metadata value to its prior value. Args: meta: a string metadata name. obj_name: a string object name. attr: a string name of an attribute (unnecessary if object metadata not associated with an attribute). role: a string role name (e.g., "PWR_ROLE_RM") method: a string method name to check against (e.g, "PWR_ObjAttrSetMeta") desc: a text description. expect: the expected return code of the pwrcmd call. Returns: True if the set-verify-reset test is successful; False, otherwise. Raises: This method raises no exceptions, but will exit() with a non-zero exit code on error. """ print " set value = {}".format(value) # Get the original value result = get_meta(meta, obj_name, attr=attr, desc=desc + " get orig") orig_value = result['value'] print " orig value = {}".format(orig_value) expect_value = value print " expect value = {}".format(expect_value) # Perform the set set_meta(meta, obj_name, value=value, attr=attr, role=role, method=method, desc=desc + " set new") # Record this command and description for errors cmd = get_command() dsc = get_description() # Get the new metadatum value. This should be the same as expect_value result = get_meta(meta, obj_name, attr=attr, desc=desc + " get check new") actual_value = result['value'] print " actual value = {}".format(actual_value) # Set the metadatum to the original value set_meta(meta, obj_name, value=orig_value, attr=attr, role=role, method=method, desc=desc + " reset orig") # Read back after reset result = get_meta(meta, obj_name, attr=attr, desc=desc + " get check orig") final_value = result['value'] print " final value = {}".format(final_value) # Want some indication of what went wrong text = "\n".join([ " set value = {}".format(value), " orig value = {}".format(orig_value), " expect value = {}".format(expect_value), " actual value = {}".format(actual_value), " final value = {}".format(final_value) ]) if actual_value != expect_value: print error_message("new value != expected value", output=text, desc=dsc, command=cmd) return False if orig_value != final_value: print error_message("final value != orig value", output=text, desc=dsc, command=cmd) return False return True
def set_attr_and_check(attrs, objs, values, role, errduples=None, method=None, desc=None, expect=EXPECT_SUCCESS): """Perform a set/get/reset operation on one or more attributes""" # Build this up as we go # We want these as lists-of-one, not as scalars if not isinstance(attrs, list): attrs = [attrs] if not isinstance(objs, list): objs = [objs] if not isinstance(values, list): values = [values] print " set values = {}".format(values) # This will have attributes * objects values in it result = get_attr(attrs, objs, desc=desc + " get orig") orig_values = result['attr_vals'] print " orig values = {}".format(orig_values) print get_command() # There is no API call to set a heterogeneous collection # of attribute values for multiple objects. Instead, we # have to set multiple attribute values for each object. # We need to slice this into # [ [o1v1,o1v2,o1v3,...], # [o2v1,o2v2,o2v3,...], ... ] numattrs = len(attrs) numvals = len(orig_values) reset_values = [ orig_values[i:i + numattrs] for i in range(0, numvals, numattrs) ] print " reset values = {}".format(reset_values) # This is what we expect actual_values to be # Values for set follow attribute count: 1 value for 1 attribute # Values for get expand as attributes * objects # This produces [o1v1,o1v2,o1v3,...o2v1,o2v2,o2v3,...] expect_values = [val for obj in objs for val in values] print " expect values = {}".format(expect_values) # Perform the set set_attr(attrs, objs, values, role, errduples, desc=desc + " set new", method=method, expect=expect) # Record this command and description for errors cmd = get_command() dsc = get_description() # Read attributes * objects values after set result = get_attr(attrs, objs, desc=desc + " get check new") actual_values = result['attr_vals'] print " actual values = {}".format(actual_values) # To put the originals back, we need to walk through reset_values i = 0 for obj in objs: set_attr(attrs, obj, reset_values[i], role, desc=desc + " reset orig") i += 1 # Read back after reset, attributes * objects values result = get_attr(attrs, objs, desc=desc + " get check orig") final_values = result['attr_vals'] print " final values = {}".format(final_values) # Want some indication of what went wrong text = "\n".join([ " set values = {}".format(values), " orig values = {}".format(orig_values), " expect values = {}".format(expect_values), " actual values = {}".format(actual_values), " final values = {}".format(final_values) ]) if actual_values != expect_values: print error_message("new values != expected values", output=text, desc=dsc, command=cmd) return False if orig_values != final_values: print error_message("final values != orig values", output=text, desc=dsc, command=cmd) return False return True
def listen(): while True: CHUNK = 2048 FORMAT = pyaudio.paInt16 CHANNELS = 2 RATE = 44100 RECORD_SECONDS = 100 window = np.blackman(CHUNK) swidth = 2 past = [-1] * N command = [] active = False p = pyaudio.PyAudio() stream = p.open(format=FORMAT, channels=CHANNELS, rate=RATE, input=True, frames_per_buffer=CHUNK) print("* waiting for command") for i in range(0, int(RATE / CHUNK * RECORD_SECONDS)): data = stream.read(int(CHUNK / 2)) indata = np.array(wave.struct.unpack("%dh"%(len(data)/swidth),\ data))*window # Take fft and square each value fftData = abs(np.fft.rfft(indata))**2 # find the max which = fftData[1:].argmax() + 1 if which != len(fftData) - 1: y0, y1, y2 = np.log(fftData[which - 1:which + 2:]) x1 = (y2 - y0) * .5 / (2 * y1 - y2 - y0) # find the frequency and output it sound_frequence = (which + x1) * RATE / CHUNK else: sound_frequence = which * RATE / CHUNK #update past past.pop(0) past.append(sound_frequence) #check for part of command if rms(data) > THRESH: if not active and max(past) - min(past) < tolerance: command.append(np.mean(past)) active = True print(command) else: active = False #check for command completion if len(command) == 3: # convert command to string command_letters = '' for i in range(len(command) - 1): t = command[i + 1] - command[i] if abs(t) < tolerance: command_letters += 'n' elif t > 0: command_letters += 'u' else: command_letters += 'd' command = [] common.get_command(command_letters) print("* done") stream.stop_stream() stream.close() p.terminate()