ATLAS Offline Software
Loading...
Searching...
No Matches
python.TaskManager Namespace Reference

Classes

class  DbParam
class  JobAnalyzer
class  TaskAnalyzer
class  TaskManager
class  TaskManagerCheckError
class  TaskManagerDatabaseError

Functions

 dictFactory (cursor, row)
 getKey (d, v)
 getStatusClass (status)
 appendUnique (s, v)
 getFullTaskNames (taskman, dsname, taskname, requireSingleTask=False, confirmWithUser=False, addWildCards=True)
 getJobConfig (jobDir, dsName, taskName, jobName=' *')

Variables

str __author__ = 'Juerg Beringer'
str __version__ = 'TaskManager.py atlas/athena'

Detailed Description

TaskManager is a tool for keeping track of JobRunner jobs using a
database. TaskManager uses the notion of a task as the primary unit for
bookkeeping. Each task includes one or more jobs run using the same
JobRunner template and typically resulting from a single invocation of
JobRunner through one of the makeDPD.py or runDPD.py
scripts. TaskManager keeps track of the status of tasks and associated
jobs, runs postprocessing scripts, and accumulates results for later
analysis accross tasks.

Written by Juerg Beringer (LBNL) in 2009.

Function Documentation

◆ appendUnique()

python.TaskManager.appendUnique ( s,
v )

Definition at line 64 of file TaskManager.py.

64def appendUnique(s,v):
65 if not s:
66 s = '' # make sure it is not None
67 if v not in s.split():
68 s = ' '.join([s,v])
69 return s
70
71

◆ dictFactory()

python.TaskManager.dictFactory ( cursor,
row )
Convert a tuple from a database query into a dictonary.

Definition at line 33 of file TaskManager.py.

33def dictFactory(cursor, row):
34 """Convert a tuple from a database query into a dictonary."""
35 d = {}
36 for idx, col in enumerate(cursor.description):
37 d[col[0]] = row[idx]
38 return d
39
40

◆ getFullTaskNames()

python.TaskManager.getFullTaskNames ( taskman,
dsname,
taskname,
requireSingleTask = False,
confirmWithUser = False,
addWildCards = True )
Retrieve the full dataset and task names given a pair of (dsname,task) that may
   contain wildcards or be just a parital name such as the run number. Depending
   on the requireSingleTask and confirmWithUser settings a TaskManagerCheckError
   is raised if there are multiple tasks or if the user doesn't confirm.

Definition at line 72 of file TaskManager.py.

72def getFullTaskNames(taskman,dsname,taskname,requireSingleTask=False,confirmWithUser=False,addWildCards=True):
73 """Retrieve the full dataset and task names given a pair of (dsname,task) that may
74 contain wildcards or be just a parital name such as the run number. Depending
75 on the requireSingleTask and confirmWithUser settings a TaskManagerCheckError
76 is raised if there are multiple tasks or if the user doesn't confirm."""
77 taskList = taskman.getTaskNames(dsname,taskname,addWildCards)
78 if len(taskList)==0:
79 raise TaskManagerCheckError ('ERROR: No tasks found for dataset = %s, task = %s' % (dsname,taskname))
80 if requireSingleTask and len(taskList)!=1:
81 m = "ERROR: Multiple data set names found for dataset = %s, task = %s\n Please use full dataset or task name from list below, using option -n if necessary:\n\n" % (dsname,taskname)
82 m += " %-50s %s\n" % ('DATASET NAME','TASK NAME')
83 m += " %s\n" % (75*'-')
84 for t in taskList:
85 m += " %-50s %s\n" % (t[0],t[1])
86 m += '\n'
87 raise TaskManagerCheckError (m)
88 if confirmWithUser:
89 print ('Please confirm that you want to execute this command for the following tasks:\n')
90 print (" %-50s %s" % ('DATASET NAME','TASK NAME'))
91 print (" %s" % (75*'-'))
92 for t in taskList:
93 print (" %-50s %s" % (t[0],t[1]))
94 a = input('\nARE YOU SURE [n] ? ')
95 if a!='y':
96 raise TaskManagerCheckError ('ERROR: Aborted by user')
97 print()
98 return taskList
99
100
void print(char *figname, TCanvas *c1)

◆ getJobConfig()

python.TaskManager.getJobConfig ( jobDir,
dsName,
taskName,
jobName = '*' )
Read config dict from job files.

Definition at line 101 of file TaskManager.py.

101def getJobConfig(jobDir,dsName,taskName,jobName='*'):
102 """Read config dict from job files."""
103 config = {}
104 configFile = glob.glob('%s/%s/%s/%s/%s' % (jobDir,dsName,taskName,jobName,'*.config.py.final.py'))
105 if not configFile:
106 configFile = glob.glob('%s/%s/%s/%s/%s' % (jobDir,dsName,taskName,jobName,'*.config.py'))
107 if configFile:
108 exec(open(configFile[0]).read(),config) # Eval config file and put defs into config dict
109 return config['jobConfig']
110
111
IovVectorMap_t read(const Folder &theFolder, const SelectionCriterion &choice, const unsigned int limit=10)

◆ getKey()

python.TaskManager.getKey ( d,
v )
Get the key for which dictonary d has an entry with value v.
Returns 'Undefined' if there's no such key, if several values are found.

Definition at line 41 of file TaskManager.py.

41def getKey(d, v):
42 """Get the key for which dictonary d has an entry with value v.
43 Returns 'Undefined' if there's no such key, if several values are found."""
44 l = [k for k in d.keys() if d[k]==v]
45 if len(l)==1:
46 return l[0]
47 else:
48 return 'Undefined'
49
50

◆ getStatusClass()

python.TaskManager.getStatusClass ( status)
Returns 'ok', 'warn' or 'bad' depending on the value of status.

Definition at line 51 of file TaskManager.py.

51def getStatusClass(status):
52 """Returns 'ok', 'warn' or 'bad' depending on the value of status."""
53 statusMap = {
54 7: 'bad',
55 10: 'ok',
56 11: 'bad'
57 }
58 if status in statusMap:
59 return statusMap[status]
60 else:
61 return 'warn'
62
63

Variable Documentation

◆ __author__

str python.TaskManager.__author__ = 'Juerg Beringer'
private

Definition at line 17 of file TaskManager.py.

◆ __version__

str python.TaskManager.__version__ = 'TaskManager.py atlas/athena'
private

Definition at line 18 of file TaskManager.py.