Beispiel #1
0
def batch_job_parsed(args):
    if not (args.resource and
          args.appkernel and
          args.nodes):
        parser.error(
            'Please provide a resource, application kernel and node count.')
        exit(1)
    resource = akrr.FindResourceByName(args.resource)
    app = akrr.FindAppByName(args.appkernel)
    nodes = args.nodes
    node_list = [node.strip() for node in nodes.split(',')] if ',' in nodes else [int(nodes)]
    print_only=args.print_only
    verbose=args.verbose

    str_io=cStringIO.StringIO()
    if not verbose:
        sys.stdout = sys.stderr = str_io
    from akrrtaskappker import akrrTaskHandlerAppKer
#    taskHandler=akrrTaskHandlerAppKer(1,resource['name'],app['name'],"{'nnodes':%s}" % (node_list[0],),"{}","{}")
    # test arbitrary resourceParam like WLMheader stuff
    taskHandler=akrrTaskHandlerAppKer(1,resource['name'],app['name'],"{'SlUrM':'--foo','slurm':'#SBATCH --mail=maya','nnodes':%s}" % (node_list[0],),"{}","{}")
    if print_only:
        taskHandler.GenerateBatchJobScript()
    else:
        taskHandler.CreateBatchJobScriptAndSubmitIt(doNotSubmitToQueue=True)
    sys.stdout=sys.__stdout__
    sys.stderr=sys.__stderr__

    if taskHandler.status.count("ERROR")>0:
        log.error('Batch job script was not generated see log below!')
        print str_io.getvalue()
        log.error('Batch job script was not generated see log above!')


    jobScriptFullPath=os.path.join(taskHandler.taskDir,"jobfiles",taskHandler.JobScriptName)
    if os.path.isfile(jobScriptFullPath):
        fin=open(jobScriptFullPath,"r")
        jobScriptContent=fin.read()
        fin.close()

        if print_only:
            log.info('Below is content of generated batch job script:')
            print jobScriptContent
        else:
            log.info("Local copy of batch job script is "+jobScriptFullPath)
            print
            log.info("Application kernel working directory on "+resource['name']+" is "+taskHandler.remoteTaskDir)
            log.info("Batch job script location on "+resource['name']+" is "+os.path.join(taskHandler.remoteTaskDir,taskHandler.JobScriptName))
    else:
        log.error('Batch job script was not generated see messages above!')
    if print_only:
        log.info('Removing generated files from file-system as only batch job script printing was requested')
        taskHandler.DeleteLocalFolder()
Beispiel #2
0
def akrrGetNewTaskHandler(task_id,resourceName,appName,resourceParam,appParam,task_param,timeToSubmit=None,repetition=None,timeStamp=None):
    """return new instance of akrrTaskHandler. based on resourceName,appName,resourceParam,appParam it can give different handlers...in the feture"""
    if appName.count("bundle")>0:
        return akrrTaskHandlerBundle(task_id,resourceName,appName,resourceParam,appParam,task_param,timeToSubmit,repetition,timeStamp)
    else:
        return akrrTaskHandlerAppKer(task_id,resourceName,appName,resourceParam,appParam,task_param,timeToSubmit,repetition,timeStamp)