def word_to_phone_lattice_torque(target, source, env):
    args = source[-1].read()
    data_list, lattice_list, wordpron, dic = source[0:4]
    args["DICTIONARY"] = dic.abspath
    args["DATA_FILE"] = data_list.abspath
    args["FSMGZ_FORMAT"] = "true"
    args["CONFUSION_NETWORK"] = ""
    args["FSM_DIR"] = "temp"
    args["WORDPRONSYMTABLE"] = wordpron.abspath
    argstr = "-d %(DICTIONARY)s -D %(DATA_FILE)s -t %(FSMGZ_FORMAT)s -s %(WORDPRONSYMTABLE)s -S %(EPSILON_SYMBOLS)s %(CONFUSION_NETWORK)s -P %(PRUNE_THRESHOLD)d %(FSM_DIR)s" % args
    if not os.path.exists(os.path.dirname(target[0].rstr())):
        os.makedirs(os.path.dirname(target[0].rstr()))
    command = env.subst("cat ${SOURCES[1].abspath}|${WRD2PHLATTICE} %s" % (argstr), source=source)
    interval = args.get("interval", 10)
    args["path"] = args.get("path", target[0].get_dir())
    stdout = env.Dir(args.get("stdout", args["path"])).Dir("stdout").rstr()
    stderr = env.Dir(args.get("stderr", args["path"])).Dir("stderr").rstr()
    if not os.path.exists(stdout):
        os.makedirs(stdout)
    if not os.path.exists(stderr):
        os.makedirs(stderr)
    job = torque.Job(args.get("name", "scons-wrd2phlattice"),
                     commands=["mkdir -p temp", command],
                     path=args.get("path", target[0].get_dir()).rstr(),
                     stdout_path=stdout,
                     stderr_path=stderr,
                     other=args.get("other", ["#PBS -W group_list=yeticcls"]),
                     )
    job.submit(commit=True)
    while job.job_id in [x[0] for x in torque.get_jobs(True)]:
        logging.info("sleeping...")
        time.sleep(interval)
    with meta_open(target[0].rstr(), "w") as ofd:
        ofd.write(time.asctime() + "\n")
    return None
Exemple #2
0
def torque_executor(env, commands):
    """Runs a list of commands as separate Torque jobs using environment variables."""
    args = {}
    running = []
    resources = {
        "mem" : env["TORQUE_MEMORY"],
        "cput" : env["TORQUE_TIME"],
        "walltime" : env["TORQUE_TIME"],
    }    
    for cmd in commands:
        stdout = env.subst("${TORQUE_LOG}/")
        stderr = env.subst("${TORQUE_LOG}/")
        job = torque.Job(args.get("name", "scons"),
                         commands=[env.subst("source ${BASHRC_TXT}"), env.subst(cmd)],
                         resources=resources,
                         path=args.get("path", os.getcwd()),
                         stdout_path=stdout,
                         stderr_path=stderr,
                         array=args.get("array", 0),
                         other=args.get("other", ["#PBS -W group_list=yeticcls"]))
        job.submit(commit=True)
        running.append(job.job_id)
    while len(running) > 0:
        logging.info("monitoring %d torque jobs..." % (len(running)))
        time.sleep(int(env["TORQUE_INTERVAL"]))
        active = [x[0] for x in torque.get_jobs(True)]
        running = [x for x in running if x in active]
    return None
def run_asr_experiment_torque(target, source, env):
    args = source[-1].read()
    construct_command = env.subst("${ATTILA_INTERPRETER} ${SOURCES[1].abspath}", source=source)
    out, err, success = run_command(construct_command)
    if not success:
        return out + err
    stdout = env.Dir(args.get("stdout", args["path"])).Dir("stdout").rstr()
    stderr = env.Dir(args.get("stderr", args["path"])).Dir("stderr").rstr()
    if not os.path.exists(stdout):
        os.makedirs(stdout)
    if not os.path.exists(stderr):
        os.makedirs(stderr)
    command = env.subst("${ATTILA_INTERPRETER} ${SOURCES[2].abspath} -n ${TORQUE_JOBS_PER_SCONS_INSTANCE} -j $${PBS_ARRAYID} -w ${ACOUSTIC_WEIGHT} -l 1", source=source)
    interval = args.get("interval", 10)
    job = torque.Job(args.get("name", "scons"),
                     commands=[command],
                     path=args["path"],
                     stdout_path=stdout,
                     stderr_path=stderr,
                     array=args.get("array", 0),
                     other=args.get("other", ["#PBS -W group_list=yeticcls"]),
                     )
    if env["HAS_TORQUE"]:
        job.submit(commit=True)
        while job.job_id in [x[0] for x in torque.get_jobs(True)]:
            logging.debug("sleeping...")
            time.sleep(interval)
    else:
        logging.info("no Torque server, but I would submit:\n%s" % (job))
    with meta_open(target[0].rstr(), "w") as ofd:
        ofd.write(time.asctime() + "\n")
    return None
def standard_search_torque(target, source, env):
    """
Usage: /mnt/calculon-minor/lorelei_svn/KWS/bin64/stdsearch [-opts] [result_file] [query_file]                     
Options:                                                                        
-d file          data file [data.list] with lines in the following format :     
                 utt_name start_time fst_path (default: data.list)              
-f filt          filter fst (default: none)                                     
-i fst           index fst (default: index.fst)                                 
-n N             return N-best results (default: return all)                    
-p fst           pad fst (default: fspad.fst)                                   
-s symbols       arc symbols (default: word.list)                               
-t threshold     min score needed to decide YES,                                
                 (if specified it overrides term-spec-threshold (default))      
-T true/false    true (default)=queries are in text format, false=fst format    
                 txtformat: query list is a list of queries,                    
                 fstformat: query list is a list of full-paths to query fsts    
-J int           job-batch (for parallel run)                                   
-N int           total number of jobs (for parallel run)                        
-a string        title on results list (default: stdbn.tlist.xml)               
-b string        prefix on termid (default: TERM-0)                             
-m string        termid numerical formatting string (default: -1524500936)             
-O               if specified, don't optimize (default : optimize = true)       
-v               (verbose) if specified, print all debug outputs to stderr      
-?               info/options
    """
    data_list, isym, idx, pad, queryph = source[0:5]
    args = source[-1].read()
    interval = args.get("interval", 30)
    if source[-2].stat().st_size == 0:
        with meta_open(target[0].rstr(), "w") as ofd:
            ofd.write("""<stdlist termlist_filename="std.xml" indexing_time="68.51" language="english" index_size="" system_id="" />\n""")
        return None
    command = env.subst("${STDSEARCH} -F ${TARGET} -i ${SOURCES[2]} -b KW%(LANGUAGE_ID)s- -s ${SOURCES[1]} -p ${SOURCES[3]} -d ${SOURCES[0]} -a %(TITLE)s -m %(PRECISION)s ${SOURCES[4]}" % args, target=target, source=source)
    job = torque.Job(args.get("name", "scons-stdsearch"),
                     commands=[command],
                     path=args.get("path", target[0].get_dir()).rstr(),
                     stdout_path=pjoin(target[0].get_dir().rstr(), "stdout"),
                     stderr_path=pjoin(target[0].get_dir().rstr(), "stderr"),
                     other=args.get("other", ["#PBS -W group_list=yeticcls"]),
                     )
    if env["HAS_TORQUE"]:
        print str(job)
        job.submit(commit=True)
        while job.job_id in [x[0] for x in torque.get_jobs(True)]:
            logging.info("sleeping...")
            time.sleep(interval)
    else:
        logging.info("no Torque server, but I would submit:\n%s" % (job))
    with meta_open(target[0].rstr(), "w") as ofd:
        ofd.write(time.asctime() + "\n")
    return None
def submit_job(target, source, env):
    args = source[-1].read()
    stdout = args.get("stdout", os.path.join(args["path"], "stdout"))
    stderr = args.get("stderr", os.path.join(args["path"], "stderr"))
    if not os.path.exists(stdout):
        os.makedirs(stdout)
    if not os.path.exists(stderr):
        os.makedirs(stderr)
    interval = args.get("interval", 10)
    job = torque.Job(args.get("name", "scons"),
                     commands=[env.subst(x) for x in args["commands"]],
                     path=args["path"],
                     stdout_path=stdout,
                     stderr_path=stderr,
                     array=args.get("array", 0),
                     other=args.get("other", []))
    job.submit(commit=True)
    while job.job_id in [x[0] for x in torque.get_jobs(True)]:
        logging.info("sleeping...")
        time.sleep(interval)
    meta_open(target[0].rstr(), "w")
    return None