summaryrefslogtreecommitdiff
path: root/util/pbs/send.py
diff options
context:
space:
mode:
authorNathan Binkert <binkertn@umich.edu>2005-08-16 11:27:49 -0400
committerNathan Binkert <binkertn@umich.edu>2005-08-16 11:27:49 -0400
commit09bb20348465f960b9465d94182306137d4b854f (patch)
tree3686d70546720d78ee2af6febb886337a1b5aecb /util/pbs/send.py
parent38da461fd79bcfd3eed683076f1ba40465af775e (diff)
downloadgem5-09bb20348465f960b9465d94182306137d4b854f.tar.xz
Updates to job scripts to accept more than 15 characters of jobname
Make the Link directory even more useful by working with sub-directories. util/pbs/job.py: Expose JOBNAME as a separate parameter from PBS_JOBNAME. If the former exists, it is used as the jobname for starting the job, if it doesn't exist, PBS_JOBNAME is used. This is to get around the 15 character maximum pbs job name length. While we're at it, shuffle things around to hopefully make things a bit more clear. util/pbs/send.py: Make the Link directory functionality more sophisticated, copy sub-directories and links to directories. (we still don't copy dotfiles though) Add the setname() function to contact pbs and use raj's hack to tell the webpage about longer jobnames. (it's gross, don't look) truncate the pbs job name to 15 characters so that it works. --HG-- extra : convert_revision : 4a76b1a1c33721c7ca93e2fbb761f95bc3a2ac69
Diffstat (limited to 'util/pbs/send.py')
-rwxr-xr-xutil/pbs/send.py69
1 files changed, 55 insertions, 14 deletions
diff --git a/util/pbs/send.py b/util/pbs/send.py
index f8ca5209c..ecb0be0ec 100755
--- a/util/pbs/send.py
+++ b/util/pbs/send.py
@@ -30,9 +30,9 @@
import os, os.path, re, socket, sys
from os import environ as env, listdir
-from os.path import basename, isdir, isfile, islink, join as joinpath
+from os.path import basename, isdir, isfile, islink, join as joinpath, normpath
from filecmp import cmp as filecmp
-from shutil import copyfile
+from shutil import copy
def nfspath(dir):
if dir.startswith('/.automount/'):
@@ -41,6 +41,38 @@ def nfspath(dir):
dir = '/n/%s%s' % (socket.gethostname().split('.')[0], dir)
return dir
+def syncdir(srcdir, destdir):
+ srcdir = normpath(srcdir)
+ destdir = normpath(destdir)
+ if not isdir(destdir):
+ sys.exit('destination directory "%s" does not exist' % destdir)
+
+ for root, dirs, files in os.walk(srcdir):
+ root = normpath(root)
+ prefix = os.path.commonprefix([root, srcdir])
+ root = root[len(prefix):]
+ if root.startswith('/'):
+ root = root[1:]
+ for rem in [ d for d in dirs if d.startswith('.') or d == 'SCCS']:
+ dirs.remove(rem)
+
+ for entry in dirs:
+ newdir = joinpath(destdir, root, entry)
+ if not isdir(newdir):
+ os.mkdir(newdir)
+ print 'mkdir', newdir
+
+ for i,d in enumerate(dirs):
+ if islink(joinpath(srcdir, root, d)):
+ dirs[i] = joinpath(d, '.')
+
+ for entry in files:
+ dest = normpath(joinpath(destdir, root, entry))
+ src = normpath(joinpath(srcdir, root, entry))
+ if not isfile(dest) or not filecmp(src, dest):
+ print 'copy %s %s' % (dest, src)
+ copy(src, dest)
+
progpath = nfspath(sys.path[0])
progname = basename(sys.argv[0])
usage = """\
@@ -107,16 +139,7 @@ for arg in args:
if not listonly and not onlyecho and isdir(linkdir):
if verbose:
print 'Checking for outdated files in Link directory'
- entries = listdir(linkdir)
- for entry in entries:
- link = joinpath(linkdir, entry)
- if not islink(link) or not isfile(link):
- continue
-
- base = joinpath(basedir, entry)
- if not isfile(base) or not filecmp(link, base):
- print 'Base/%s is different than Link/%s: copying' % (entry, entry)
- copyfile(link, base)
+ syncdir(linkdir, basedir)
import job, jobfile, pbs
@@ -164,6 +187,21 @@ if not onlyecho:
jl.append(jobname)
joblist = jl
+def setname(jobid, jobname):
+ # since pbs can handle jobnames of 15 characters or less, don't
+ # use the raj hack.
+ if len(jobname) <= 15:
+ return
+
+ import socket
+ s = socket.socket()
+ # Connect to pbs.pool and send the jobid/jobname pair to port
+ # 24465 (Raj didn't realize that there are only 64k ports and
+ # setup inetd to point to port 90001)
+ s.connect(("pbs.pool", 24465))
+ s.send("%s %s\n" % (jobid, jobname))
+ s.close()
+
for jobname in joblist:
jobdir = joinpath(rootdir, jobname)
@@ -176,10 +214,11 @@ for jobname in joblist:
qsub = pbs.qsub()
qsub.pbshost = 'simpool.eecs.umich.edu'
qsub.stdout = joinpath(jobdir, 'jobout')
- qsub.name = jobname
+ qsub.name = jobname[:15]
qsub.join = True
qsub.node_type = 'FAST'
qsub.env['ROOTDIR'] = rootdir
+ qsub.env['JOBNAME'] = jobname
if len(queue):
qsub.queue = queue
qsub.build(joinpath(progpath, 'job.py'))
@@ -190,6 +229,8 @@ for jobname in joblist:
if not onlyecho:
ec = qsub.do()
if ec == 0:
- print 'PBS Jobid: %s' % qsub.result
+ jobid = qsub.result
+ print 'PBS Jobid: %s' % jobid
+ setname(jobid, jobname)
else:
print 'PBS Failed'