I just pushed a patch to the repository that adds a debug mode to bgpm
and bgsched. The diffs are attached. Basically it adds a '-D' option to
bgpm and bgsched, which removes DB2-related code, and also replaces the
mpirun command with the program name used on the cqsub line. For
example, using this cqsub line
cqsub.py -n 32 -t 10 /bin/sleep 10
would run one instance of /bin/sleep for 10 seconds.
--
Theron Voran <theron.voran(a)colorado.edu>
--- bgsched.py 2005/12/23 00:29:21 1.1
+++ bgsched.py 2006/01/03 20:30:50
@@ -14,7 +14,8 @@
import sys
sys.path.append('/soft/apps/rm-0.90/lib/python')
-import DB2
+if '-D' not in argv:
+ import DB2
class DataSet2(DataSet):
'''DataSet2 is DataSet with class parameters'''
@@ -161,8 +162,9 @@
def __init__(self):
DataSet2.__init__(self)
- self.db2 = DB2.connect(uid=self.config.get('db2uid'), pwd=self.config.get('db2pwd'),
- dsn=self.config.get('db2dsn')).cursor()
+ if '-D' not in argv:
+ self.db2 = DB2.connect(uid=self.config.get('db2uid'), pwd=self.config.get('db2pwd'),
+ dsn=self.config.get('db2dsn')).cursor()
self.jobs = []
self.qmconnect = FailureMode("QM Connection")
@@ -172,8 +174,9 @@
def __setstate__(self, state):
self.__dict__.update(state)
self.qmconnect = FailureMode("QM Connection")
- self.db2 = DB2.connect(uid=self.config.get('db2uid'), pwd=self.config.get('db2pwd'),
- dsn=self.config.get('db2dsn')).cursor()
+ if '-D' not in argv:
+ self.db2 = DB2.connect(uid=self.config.get('db2uid'), pwd=self.config.get('db2pwd'),
+ dsn=self.config.get('db2dsn')).cursor()
def Schedule(self, jobs):
'''Find new jobs, fit them on a partitions'''
@@ -208,20 +211,21 @@
#print "not idle:", [(nidlej.element.get('jobid'), nidlej.element.get('state')) for nidlej in self.jobs if nidlej not in idlejobs]
if candidates and idlejobs:
#print "Actively checking"
- self.db2.execute("select blockid, status from bglblock;")
- results = self.db2.fetchall()
- db2data = {}
- [db2data.update({block.strip():status}) for (block, status) in results]
- #print "db2data:", db2data
- for part in [part for part in candidates if db2data[part.element.get('name')] != 'F']:
- foundlocation = [job for job in jobs if job.get('location') == part.element.get('name')]
- if foundlocation:
- part.job = foundlocation[0].get('jobid')
- part.element.set('state', 'busy')
- syslog(LOG_ERR, "Found job %s on Partition %s. Manually setting state." % (foundlocation[0].get('jobid'), part.element.get('name')))
- else:
- syslog(LOG_ERR, 'Partition %s in inconsistent state' % (part.element.get('name')))
- candidates.remove(part)
+ if '-D' not in argv:
+ self.db2.execute("select blockid, status from bglblock;")
+ results = self.db2.fetchall()
+ db2data = {}
+ [db2data.update({block.strip():status}) for (block, status) in results]
+ #print "db2data:", db2data
+ for part in [part for part in candidates if db2data[part.element.get('name')] != 'F']:
+ foundlocation = [job for job in jobs if job.get('location') == part.element.get('name')]
+ if foundlocation:
+ part.job = foundlocation[0].get('jobid')
+ part.element.set('state', 'busy')
+ syslog(LOG_ERR, "Found job %s on Partition %s. Manually setting state." % (foundlocation[0].get('jobid'), part.element.get('name')))
+ else:
+ syslog(LOG_ERR, 'Partition %s in inconsistent state' % (part.element.get('name')))
+ candidates.remove(part)
#print "after db2 check"
#print "candidates: ", [cand.element.get('name') for cand in candidates]
partbyname = {}
@@ -257,7 +261,8 @@
# need to filter out dependency-used partitions
candidates = [part for part in candidates if not [item for item in deps[part] if item not in candidates]]
# need to filter out contained partitions
- candidates = [part for part in candidates if not [block for block in contained[part] if db2data.get(block.element.get('name'), 'F') != 'F']]
+ if '-D' not in argv:
+ candidates = [part for part in candidates if not [block for block in contained[part] if db2data.get(block.element.get('name'), 'F') != 'F']]
# now candidates are only completely free blocks
#print "candidates: ", [cand.element.get('name') for cand in candidates]
potential = {}
@@ -411,7 +416,7 @@
if __name__ == '__main__':
from getopt import getopt, GetoptError
try:
- (opts, arguments) = getopt(sys.argv[1:], 'C:d', ['daemon='])
+ (opts, arguments) = getopt(sys.argv[1:], 'D:C:d', ['daemon='])
except GetoptError, msg:
print "%s\nUsage:\nbgsched.py [-C configfile] [-d] [--daemon <pidfile>]" % (msg)
raise SystemExit, 1
--- ../../../head/src/components/bgpm.py 2005-12-22 17:16:56.000000000 -0700
+++ bgpm.py 2006-01-05 12:04:18.000000000 -0700
@@ -5,6 +5,7 @@
import atexit
from os import chmod, dup2, execl, fork, kill, setgid, setuid, system, waitpid, WNOHANG
+from os.path import basename
from pwd import getpwnam
import signal
import sys
@@ -108,7 +109,7 @@
syslog(LOG_ERR, "Failed to open stdout file %s. Stdout will be lost" % (self.outlog))
null = open('/dev/null', 'r')
dup2(null.fileno(), sys.__stdin__.fileno())
- cmd = (self.config['mpirun'], "mpirun", '-np', pnum, '-partition', partition,
+ cmd = (self.config['mpirun'], basename(self.config['mpirun']), '-np', pnum, '-partition', partition,
'-mode', mode, '-cwd', cwd, '-exe', program)
if args != '':
cmd = cmd + ('-args', args)
@@ -116,6 +117,10 @@
cmd = cmd + ('-env', envs)
if mapfile != '':
cmd = cmd + ('-mapfile', mapfile)
+
+ if '-D' in argv:
+ cmd = (program,basename(program),args)
+
syslog(LOG_INFO, "User %s: Running %s" % (self.element.get('submitter'), " ".join(cmd)))
apply(execl, cmd)
sys.exit(0)
@@ -221,7 +226,7 @@
if __name__ == '__main__':
from getopt import getopt, GetoptError
try:
- (opts, arg) = getopt(argv[1:], 'dC:', ['daemon='])
+ (opts, arg) = getopt(argv[1:], 'DdC:', ['daemon='])
except GetoptError,msg:
print "%s\nUsage:\nbgpm.py [-d] [-C config file] [--daemon <pidfile>]" % (msg)
raise SystemExit, 1