#!/usr/bin/env python
import kimps, drmaa
def argsOption():
usage = "usage: %prog -o ./cluster_out/ ./input_dir/"
parser = kimps.OptionParser( usage=usage )
parser.add_option( "-o", "--cluster_out",dest="cluster_out",help="out stream of sge")
(options, args) = parser.parse_args()
if len(args) != 1:
parser.error("incorrect number of arguments")
return options, args
# main
options,args = argsOption()
input_dir = args[0]
inpath = input_dir
outpath = options.cluster_out
if not(outpath): outpath = inpath
s = drmaa.Session()
s.initialize()
jt = s.createJobTemplate()
joblist = []
#kimps_ctime.stime( kimps.sys._getframe().f_code.co_filename )
inlist = kimps.glob.glob( inpath + '*.sh' )
for onein in inlist:
kimps.os.chmod( onein, 0766 )
inname = onein.split('/')[-1]
innametag = '.'.join(inname.split('.')[:-1])
jt.remoteCommand = onein
jt.nativeSpecification = " -V -S /bin/bash -j y -cwd -o "+outpath+innametag+".qout"
jt.joinFiles = True
joblist.append( s.runJob( jt ) )
s.synchronize( joblist, drmaa.Session.TIMEOUT_WAIT_FOREVER, False)
for curjob in joblist:
# print "Collecting job "+curjob
retval = s.wait( curjob, drmaa.Session.TIMEOUT_WAIT_FOREVER )
# print 'Job: '+ str(retval.jobId ) + 'finished with status '+ str(retval.hasExited)
s.deleteJobTemplate( jt )
s.exit()
'TA > Cluster' 카테고리의 다른 글
[sge] sge queue 그룹 관리 (0) | 2012.12.24 |
---|---|
[useradd] 클러스터에서 계정 추가 (0) | 2012.12.24 |
[drmaa] drmaa qsub python (kimps_drmaaQsub_py.py) (0) | 2012.12.24 |
[rocks] Warning: Your private interface (eth0) is down (0) | 2011.06.13 |
[sge] 특정 노드에 job 할당하는 방법 (0) | 2011.06.13 |