1#!/usr/bin/env python 2# Copyright (c) 2005 The Regents of The University of Michigan 3# All rights reserved. 4# 5# Redistribution and use in source and binary forms, with or without 6# modification, are permitted provided that the following conditions are 7# met: redistributions of source code must retain the above copyright 8# notice, this list of conditions and the following disclaimer; --- 68 unchanged lines hidden (view full) --- 77progname = basename(sys.argv[0]) 78usage = """\ 79Usage: 80 %(progname)s [-c] [-e] [-f] [-j <jobfile>] [-q queue] [-v] <regexp> 81 -c clean directory if job can be run 82 -e only echo pbs command info, don't actually send the job 83 -f force the job to run regardless of state 84 -q <queue> submit job to the named queue |
85 -j <jobfile> specify the jobfile (default is <rootdir>/Test.py) |
86 -v be verbose 87 88 %(progname)s [-j <jobfile>] -l [-v] <regexp> |
89 -j <jobfile> specify the jobfile (default is <rootdir>/Test.py) |
90 -l list job names, don't submit 91 -v be verbose (list job parameters) 92 93 %(progname)s -h 94 -h display this help 95""" % locals() 96 97try: 98 import getopt |
99 opts, args = getopt.getopt(sys.argv[1:], '-Ccdefhj:lq:Rt:v') |
100except getopt.GetoptError: 101 sys.exit(usage) 102 |
103depend = False |
104clean = False 105onlyecho = False 106exprs = [] 107force = False 108listonly = False 109queue = '' 110verbose = False |
111jfile = 'Test.py' |
112docpts = False 113doruns = True 114runflag = False |
115node_type = 'FAST' |
116 117for opt,arg in opts: 118 if opt == '-C': 119 docpts = True |
120 if opt == '-c': 121 clean = True |
122 if opt == '-d': 123 depend = True |
124 if opt == '-e': 125 onlyecho = True 126 if opt == '-f': 127 force = True 128 if opt == '-h': 129 print usage 130 sys.exit(0) 131 if opt == '-j': 132 jfile = arg 133 if opt == '-l': 134 listonly = True 135 if opt == '-q': 136 queue = arg |
137 if opt == '-R': 138 runflag = True 139 if opt == '-t': 140 node_type = arg |
141 if opt == '-v': 142 verbose = True 143 144if docpts: 145 doruns = runflag 146 147for arg in args: 148 exprs.append(re.compile(arg)) 149 150import jobfile, pbs 151from job import JobDir, date 152 153conf = jobfile.JobFile(jfile) 154 155if not listonly and not onlyecho and isdir(conf.linkdir): 156 if verbose: 157 print 'Checking for outdated files in Link directory' |
158 if not isdir(conf.basedir): 159 os.mkdir(conf.basedir) |
160 syncdir(conf.linkdir, conf.basedir) 161 162jobnames = {} 163joblist = [] 164 165if docpts and doruns: 166 gen = conf.alljobs() 167elif docpts: --- 72 unchanged lines hidden (view full) --- 240 self.socket.connect((self.host, self.port)) 241 242 self.socket.send("%s %s\n" % (jobid, jobname)) 243 244namehack = NameHack() 245 246for job in joblist: 247 jobdir = JobDir(joinpath(conf.rootdir, job.name)) |
248 if depend: 249 cptdir = JobDir(joinpath(conf.rootdir, job.checkpoint.name)) 250 cptjob = cptdir.readval('.pbs_jobid') |
251 252 if not onlyecho: 253 jobdir.create() 254 255 print 'Job name: %s' % job.name 256 print 'Job directory: %s' % jobdir 257 258 qsub = pbs.qsub() 259 qsub.pbshost = 'simpool.eecs.umich.edu' 260 qsub.stdout = jobdir.file('jobout') 261 qsub.name = job.name[:15] 262 qsub.join = True |
263 qsub.node_type = node_type |
264 qsub.env['ROOTDIR'] = conf.rootdir 265 qsub.env['JOBNAME'] = job.name |
266 if depend: 267 qsub.afterok = cptjob 268 if queue: |
269 qsub.queue = queue 270 qsub.build(joinpath(progpath, 'job.py')) 271 272 if verbose: 273 print 'PBS Command: %s' % qsub.command 274 275 if not onlyecho: 276 ec = qsub.do() 277 if ec == 0: 278 jobid = qsub.result 279 print 'PBS Jobid: %s' % jobid 280 namehack.setname(jobid, job.name) 281 queued = date() 282 jobdir.echofile('.pbs_jobid', jobid) 283 jobdir.echofile('.pbs_jobname', job.name) 284 jobdir.echofile('.queued', queued) 285 jobdir.setstatus('queued on %s' % queued) 286 else: 287 print 'PBS Failed' |