annotate gaussian_job_rules.py @ 2:ed472dc06c20 draft default tip

Uploaded 1.0.0
author malex
date Tue, 18 Sep 2012 23:03:01 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
1 def gaussian(job):
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
2 inp_data = dict( [ ( da.name, da.dataset ) for da in job.input_datasets ] )
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
3 inp_data.update( [ ( da.name, da.dataset ) for da in job.input_library_datasets ] )
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
4 src_comfile = inp_data[ "infile" ].file_name
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
5 comfile = open(src_comfile, 'r')
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
6 ppn='1'
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
7 pmem = '900mb'
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
8 overhead = 200
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
9 walltime = '11:59:59'
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
10 for line in comfile:
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
11 line = line.strip().lower()
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
12 if ( "%nproc=" in line):
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
13 try:
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
14 ppn = line.split('=')[1]
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
15 except Exception, e:
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
16 log.debug(e)
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
17 sys.stdout.write(e)
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
18 if ("%mem=" in line):
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
19 try:
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
20 mem_str = line.split('=')[1]
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
21 if ( "kb" in mem_str ):
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
22 mem_num = mem_str.split('kb')[0]
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
23 mem_num = int(int(mem_num) / 1024.0) + overhead
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
24 if ( "mb" in mem_str ):
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
25 mem_num = mem_str.split('mb')[0]
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
26 mem_num = int(mem_num) + overhead
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
27 elif ( "gb" in mem_str ):
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
28 mem_num = mem_str.split('gb')[0]
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
29 mem_num = (int(mem_num) * 1024) + overhead
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
30 elif ( "kw" in mem_str ):
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
31 mem_num = mem_str.split('kw')[0]
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
32 mem_num = int(int(mem_num) * 8 / 1024.0) + overhead
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
33 elif ( "mw" in mem_str ):
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
34 mem_num = mem_str.split('mw')[0]
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
35 mem_num = (int(mem_num) * 8) + overhead
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
36 elif ( "gw" in mem_str ):
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
37 mem_num = mem_str.split('gw')[0]
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
38 mem_num = (int(mem_num) * 8 * 1024) + overhead
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
39 else:
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
40 #Assume words
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
41 mem_num = int(int(mem_str) * 8 / 1024.0 / 1024.0) + overhead
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
42 pmem_num = int(mem_num / int(ppn))
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
43 pmem = str(pmem_num) + 'mb'
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
44 except Exception, e:
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
45 log.debug(e)
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
46 sys.stdout.write(e)
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
47 if ("!walltime=" in line):
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
48 try:
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
49 walltime = line.split('=')[1]
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
50 except Exception, e:
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
51 log.debug(e)
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
52 sys.stdout.write(e)
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
53 request = "-l nodes=1:ppn=%s,pmem=%s,walltime=%s" % (ppn, pmem, walltime)
ed472dc06c20 Uploaded 1.0.0
malex
parents:
diff changeset
54 return 'drmaa://%s/' % request