ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/VHbb/python/submitThem.py
(Generate patch)

Comparing UserCode/VHbb/python/submitThem.py (file contents):
Revision 1.34 by nmohr, Thu Feb 28 16:59:09 2013 UTC vs.
Revision 1.37 by bortigno, Wed Mar 27 14:29:38 2013 UTC

# Line 41 | Line 41 | en = opts.tag
41  
42   #create the list with the samples to run over
43   samplesList=opts.samples.split(",")
44
44   timestamp = time.asctime().replace(' ','_').replace(':','-')
45  
46 < configs = ['%sconfig/general'%(en),'%sconfig/paths'%(en),'%sconfig/plots'%(en),'%sconfig/training'%(en),'%sconfig/datacards'%(en),'%sconfig/cuts'%(en)]
48 <
46 > # the list of the config is taken from the path config
47   pathconfig = BetterConfigParser()
48   pathconfig.read('%sconfig/paths'%(en))
49 + _configs = pathconfig.get('Configuration','List').split(" ")
50 + configs = [ '%sconfig/'%(en) + c for c in _configs  ]
51  
52   if not opts.ftag == '':
53      tagDir = pathconfig.get('Directories','tagDir')
# Line 83 | Line 83 | print configs
83   config = BetterConfigParser()
84   config.read(configs)
85  
86 < btagLibrary = config.get('BTagReshaping','library')
87 < submitDir = os.getcwd()
88 < os.chdir(os.path.dirname(btagLibrary))
89 < if not os.path.exists(btagLibrary):
90 <    ROOT.gROOT.LoadMacro('%s+'%btagLibrary.replace('_h.so','.h'))
91 < shutil.copyfile(os.path.basename(btagLibrary),'/scratch/%s/%s'%(getpass.getuser(),os.path.basename(btagLibrary)))
92 < shutil.copyfile('/scratch/%s/%s'%(getpass.getuser(),os.path.basename(btagLibrary)),btagLibrary)
93 < os.chdir(submitDir)
86 > def dump_config(configs,output_file):
87 >    """
88 >    Dump all the configs in a output file
89 >    Args:
90 >        output_file: the file where the log will be dumped
91 >        configs: list of files (string) to be dumped
92 >    Returns:
93 >        nothing
94 >    """
95 >    outf = open(output_file,'w')
96 >    for i in configs:
97 >        try:
98 >            f=open(i,'r')
99 >            outf.write(f.read())
100 >        except: print '@WARNING: Config' + i + ' not found. It will not be used.'
101 >
102 > def compile_macro(config,macro):
103 >    """
104 >    Creates the library from a macro using CINT compiling it in scratch to avoid
105 >    problems with the linking in the working nodes.
106 >    Args:
107 >        config: configuration file where the macro path is specified
108 >        macro: macro name to be compiled
109 >    Returns:
110 >        nothing
111 >    """
112 >    submitDir = os.getcwd()
113 >    _macro=macro+'.h'
114 >    library = config.get(macro,'library')
115 >    libDir=os.path.dirname(library)
116 >    os.chdir(libDir)
117 >    if not os.path.exists(library):
118 >        print '@INFO: Compiling ' + _macro
119 >        scratchDir='/scratch/%s/'%(getpass.getuser())
120 >        shutil.copyfile(libDir+'/'+_macro,'/scratch/%s/%s'%(getpass.getuser(),_macro))
121 >        os.chdir(scratchDir)
122 >        ROOT.gROOT.ProcessLine('.L %s+'%(scratchDir+_macro))
123 >        shutil.copyfile('/scratch/%s/%s'%(getpass.getuser(),os.path.basename(library)),library)
124 >    os.chdir(submitDir)
125 >        
126 > compile_macro(config,'BTagReshaping')
127 > compile_macro(config,'VHbbNameSpace')
128 >
129   logPath = config.get("Directories","logpath")
130   logo = open('%s/data/submit.txt' %config.get('Directories','vhbbpath')).readlines()
131   counter = 0
132  
133   #check if the logPath exist. If not exit
134   if( not os.path.isdir(logPath) ):
135 <    print 'ERROR: ' + logPath + ': dir not found.'
136 <    print 'ERROR: Create it before submitting '
135 >    print '@ERROR : ' + logPath + ': dir not found.'
136 >    print '@ERROR : Create it before submitting '
137      print 'Exit'
138      sys.exit(-1)
139      
# Line 115 | Line 150 | def submit(job,repDict):
150          repDict['name'] = '%(job)s_%(en)s%(task)s' %repDict
151      command = 'qsub -V -cwd -q %(queue)s -l h_vmem=6G -N %(name)s -o %(logpath)s/%(timestamp)s_%(job)s_%(en)s_%(task)s.out -e %(logpath)s/%(timestamp)s_%(job)s_%(en)s_%(task)s.err runAll.sh %(job)s %(en)s ' %(repDict) + opts.task + ' ' + repDict['job_id'] + ' ' + repDict['additional']
152      print command
153 +    dump_config(configs,"%(logpath)s/%(timestamp)s_%(job)s_%(en)s_%(task)s.config" %(repDict))
154      subprocess.call([command], shell=True)
155  
156   if opts.task == 'train':
# Line 142 | Line 178 | if opts.task == 'plot':
178      for item in Plot_vars:
179          submit(item,repDict)
180  
181 + if opts.task == 'trainReg':
182 +    repDict['queue'] = 'all.q'
183 +    submit('trainReg',repDict)
184 +
185  
186   elif opts.task == 'dc':
187      repDict['queue'] = 'short.q'

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines