Deleted Added
sdiff udiff text old ( 1908:73342b7d6f83 ) new ( 1916:fe8d4e92c0a7 )
full compact
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 <basedir>/test.py)
86 -v be verbose
87
88 %(progname)s [-j <jobfile>] -l [-v] <regexp>
89 -j <jobfile> specify the jobfile (default is <basedir>/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:], '-CRcd:efhj:lq:v')
100except getopt.GetoptError:
101 sys.exit(usage)
102
103clean = False
104onlyecho = False
105exprs = []
106force = False
107listonly = False
108queue = ''
109verbose = False
110jfile = 'Base/test.py'
111docpts = False
112doruns = True
113runflag = False
114
115for opt,arg in opts:
116 if opt == '-C':
117 docpts = True
118 if opt == '-R':
119 runflag = True
120 if opt == '-c':
121 clean = True
122 if opt == '-e':
123 onlyecho = True
124 if opt == '-f':
125 force = True
126 if opt == '-h':
127 print usage
128 sys.exit(0)
129 if opt == '-j':
130 jfile = arg
131 if opt == '-l':
132 listonly = True
133 if opt == '-q':
134 queue = arg
135 if opt == '-v':
136 verbose = True
137
138if docpts:
139 doruns = runflag
140
141for arg in args:
142 exprs.append(re.compile(arg))
143
144import jobfile, pbs
145from job import JobDir, date
146
147conf = jobfile.JobFile(jfile)
148
149if not listonly and not onlyecho and isdir(conf.linkdir):
150 if verbose:
151 print 'Checking for outdated files in Link directory'
152 syncdir(conf.linkdir, conf.basedir)
153
154jobnames = {}
155joblist = []
156
157if docpts and doruns:
158 gen = conf.alljobs()
159elif docpts:

--- 72 unchanged lines hidden (view full) ---

232 self.socket.connect((self.host, self.port))
233
234 self.socket.send("%s %s\n" % (jobid, jobname))
235
236namehack = NameHack()
237
238for job in joblist:
239 jobdir = JobDir(joinpath(conf.rootdir, job.name))
240
241 if not onlyecho:
242 jobdir.create()
243
244 print 'Job name: %s' % job.name
245 print 'Job directory: %s' % jobdir
246
247 qsub = pbs.qsub()
248 qsub.pbshost = 'simpool.eecs.umich.edu'
249 qsub.stdout = jobdir.file('jobout')
250 qsub.name = job.name[:15]
251 qsub.join = True
252 qsub.node_type = 'FAST'
253 qsub.env['ROOTDIR'] = conf.rootdir
254 qsub.env['JOBNAME'] = job.name
255 if len(queue):
256 qsub.queue = queue
257 qsub.build(joinpath(progpath, 'job.py'))
258
259 if verbose:
260 print 'PBS Command: %s' % qsub.command
261
262 if not onlyecho:
263 ec = qsub.do()
264 if ec == 0:
265 jobid = qsub.result
266 print 'PBS Jobid: %s' % jobid
267 namehack.setname(jobid, job.name)
268 queued = date()
269 jobdir.echofile('.pbs_jobid', jobid)
270 jobdir.echofile('.pbs_jobname', job.name)
271 jobdir.echofile('.queued', queued)
272 jobdir.setstatus('queued on %s' % queued)
273 else:
274 print 'PBS Failed'