/[pdpsoft]/nl.nikhef.pdp.dynsched-pbs-plugin/trunk/torqueAttMappers.py
ViewVC logotype

Annotation of /nl.nikhef.pdp.dynsched-pbs-plugin/trunk/torqueAttMappers.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2333 - (hide annotations) (download) (as text)
Thu Jul 7 09:03:58 2011 UTC (10 years, 10 months ago) by templon
File MIME type: application/x-python
File size: 3224 byte(s)
first version of module defining functions and data on attribute mappings
for torque output.

1 templon 2333 #--
2    
3     # torqueAttMappers.py -- helper functions to map and/or convert names and values returned by torque.
4     # Problem: some upstream tools like dynsched want LRMS-independent names for attribues.
5     # also prefer 3601 seconds over 1:00:01 for a elapsed walltime. Mapper functions here
6     # do the renaming and conversion. Also can filter attributes, for example most upstream
7     # applications will not need to know what is in the very long STAGEOUT string.
8    
9     # $URL: svn+ssh://svn@ndpfsvn.nikhef.nl/repos/pdpsoft/nl.nikhef.pdp.dynsched-pbs-plugin/trunk/torqueJobs.py $
10     # $Id: torqueJobs.py 2329 2011-07-06 15:12:07Z templon $
11    
12     #--
13    
14     # list of fields for which to convert times (H:M:S -> sec)
15     tfl = ['resources_used.cput', 'Resource_List.cput', 'Resource_List.walltime', 'resources_used.walltime' ]
16    
17     def hms(instring):
18     t = instring.split(':')
19     secs = int(t[2]) + 60.0*(int(t[1]) + 60*int(t[0]))
20     return secs
21    
22     # list of fields for which to convert memory
23     mfl = ['Resource_List.pvmem', 'resources_used.mem', 'Resource_List.pmem', 'resources_used.vmem']
24    
25     def memconvert(instr):
26     if instr[-2:] == 'mb':
27     return int(instr[:-2])
28     elif instr[-2:] == 'kb':
29     return float(instr[:-2])/1024.
30     else:
31     return 'BADVAL'
32    
33     # list of fields for which to convert string timestamps -> unix timestamps (seconds since 1970)
34    
35     tfl2 = ['ctime', 'mtime', 'qtime', 'etime', 'start_time']
36    
37     # attribute mapping dict to be used for the dynsched-pbs-plugin ... maps names to the ones
38     # used by the dynamic scheduler.
39    
40     amap_dynsched = {
41     'Resource_List.walltime' : 'maxwalltime',
42     'resources_used.walltime' : 'walltime',
43     'exec_host' : 'cpucount',
44     'jobname' : 'name'
45     }
46    
47     # attribute mapping dict to make some attribute names shorter
48    
49     amap_shortnames = {
50     'Resource_List.pvmem' : 'req.pvmem',
51     'resources_used.cput' : 'used.cpu',
52     'Resource_List.nodes' : 'req.nodes',
53     'Resource_List.cput' : 'req.cpu',
54     'resources_used.mem' : 'used.mem',
55     'Resource_List.pmem' : 'req.pmem',
56     'resources_used.vmem' : 'used.vmem',
57     'Resource_List.neednodes' : 'req.neednodes',
58     'Resource_List.nodect' : 'req.nodect'
59     }
60    
61     import time
62     def tconv(instring):
63     timetuple = time.strptime(instring,"%c")
64     ts = time.mktime(timetuple)
65     return ts
66    
67     def mapatts(indict):
68     odict = dict()
69     changekeys = amap.keys()
70     for k in indict.keys():
71     if k in tfl:
72     secs = hms(indict[k])
73     indict[k] = secs
74     elif k in mfl:
75     mem_num = memconvert(indict[k])
76     indict[k] = mem_num
77     if k in changekeys:
78     odict[amap[k]] = indict[k]
79     else:
80     odict[k] = indict[k]
81     return odict
82    
83     def mapatts2(indict):
84     odict = dict()
85     changekeys = amap.keys()
86     for k in indict.keys():
87     if k in tfl:
88     secs = hms(indict[k])
89     indict[k] = secs
90     elif k in mfl:
91     mem_num = memconvert(indict[k])
92     indict[k] = mem_num
93     elif k in tfl2:
94     ts = tconv(indict[k])
95     indict[k] = ts
96     if k in changekeys:
97     odict[amap[k]] = indict[k]
98     else:
99     odict[k] = indict[k]
100     return odict
101    

Properties

Name Value
svn:eol-style native

grid.support@nikhef.nl
ViewVC Help
Powered by ViewVC 1.1.28