send.py (1908:73342b7d6f83) send.py (1916:fe8d4e92c0a7)
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
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)
85 -j <jobfile> specify the jobfile (default is <rootdir>/Test.py)
86 -v be verbose
87
88 %(progname)s [-j <jobfile>] -l [-v] <regexp>
86 -v be verbose
87
88 %(progname)s [-j <jobfile>] -l [-v] <regexp>
89 -j <jobfile> specify the jobfile (default is <basedir>/test.py)
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
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')
99 opts, args = getopt.getopt(sys.argv[1:], '-Ccdefhj:lq:Rt:v')
100except getopt.GetoptError:
101 sys.exit(usage)
102
100except getopt.GetoptError:
101 sys.exit(usage)
102
103depend = False
103clean = False
104onlyecho = False
105exprs = []
106force = False
107listonly = False
108queue = ''
109verbose = False
104clean = False
105onlyecho = False
106exprs = []
107force = False
108listonly = False
109queue = ''
110verbose = False
110jfile = 'Base/test.py'
111jfile = 'Test.py'
111docpts = False
112doruns = True
113runflag = False
112docpts = False
113doruns = True
114runflag = False
115node_type = 'FAST'
114
115for opt,arg in opts:
116 if opt == '-C':
117 docpts = True
116
117for opt,arg in opts:
118 if opt == '-C':
119 docpts = True
118 if opt == '-R':
119 runflag = True
120 if opt == '-c':
121 clean = True
120 if opt == '-c':
121 clean = True
122 if opt == '-d':
123 depend = 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
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
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'
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)
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))
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')
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
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
252 qsub.node_type = 'FAST'
263 qsub.node_type = node_type
253 qsub.env['ROOTDIR'] = conf.rootdir
254 qsub.env['JOBNAME'] = job.name
264 qsub.env['ROOTDIR'] = conf.rootdir
265 qsub.env['JOBNAME'] = job.name
255 if len(queue):
266 if depend:
267 qsub.afterok = cptjob
268 if 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'
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'