Skip to content

Commit

Permalink
Merge pull request #23930 from davidlange6/printMig_180721T4_Configur…
Browse files Browse the repository at this point in the history
…ation_PyReleaseValidation

Print function migration for Configuration_PyReleaseValidation
  • Loading branch information
cmsbuild committed Jul 23, 2018
2 parents 162b2e2 + 9ebd544 commit 9ecac21
Show file tree
Hide file tree
Showing 12 changed files with 113 additions and 101 deletions.
19 changes: 10 additions & 9 deletions Configuration/PyReleaseValidation/data/runall.py
@@ -1,5 +1,6 @@
#! /usr/bin/env python

from __future__ import print_function
import os
import time
import sys
Expand Down Expand Up @@ -45,7 +46,7 @@ def main(argv) :
try:
opts, args = getopt.getopt(argv, "", ["nproc=","dohighstat",'hlt','inFile=','intbld'])
except getopt.GetoptError as e:
print "unknown option", str(e)
print("unknown option", str(e))
sys.exit(2)

# check command line parameter
Expand All @@ -67,7 +68,7 @@ def main(argv) :
intBld = True

if hlt:
print "\nWARNING: option --hlt is deprecated as this is now default.\n"
print("\nWARNING: option --hlt is deprecated as this is now default.\n")

if inFile:
commands_standard_file=open(inFile,'r')
Expand Down Expand Up @@ -105,7 +106,7 @@ def main(argv) :
if intBld and linecomponents[0].strip() not in forIB: continue
command=linecomponents[1][:-1]
commands.append(command)
print 'Will do: '+command
print('Will do: '+command)


nfail=0
Expand All @@ -115,10 +116,10 @@ def main(argv) :
clist = []
cdone = []
i=0
print 'Running in %s thread(s)' %np
print('Running in %s thread(s)' %np)

for command in commands:
print 'Preparing to run %s' %command
print('Preparing to run %s' %command)
current = testit(command)
clist.append(current)
cdone.append(0)
Expand All @@ -139,7 +140,7 @@ def main(argv) :
npass+=pingle.npass
report+=pingle.report
cdone[j]=1
print pingle.report
print(pingle.report)
# print 'Number of running threads: %s' % i

alen=len(cdone)
Expand All @@ -151,18 +152,18 @@ def main(argv) :
nfail+=pingle.nfail
npass+=pingle.npass
report+=pingle.report
print pingle.report
print(pingle.report)

report+='\n %s tests passed, %s failed \n' %(npass,nfail)
print report
print(report)

runall_report_name='runall-report.log'
runall_report=open(runall_report_name,'w')
runall_report.write(report)
runall_report.close()

if hlt:
print "\nWARNING: option --hlt is deprecated as this is now default.\n"
print("\nWARNING: option --hlt is deprecated as this is now default.\n")

if __name__ == '__main__' :
main(sys.argv[1:])
59 changes: 30 additions & 29 deletions Configuration/PyReleaseValidation/python/MatrixInjector.py
@@ -1,3 +1,4 @@
from __future__ import print_function
import sys
import json
import os
Expand All @@ -7,7 +8,7 @@

def performInjectionOptionTest(opt):
if opt.show:
print 'Not injecting to wmagent in --show mode. Need to run the worklfows.'
print('Not injecting to wmagent in --show mode. Need to run the worklfows.')
sys.exit(-1)
if opt.wmcontrol=='init':
#init means it'll be in test mode
Expand All @@ -16,10 +17,10 @@ def performInjectionOptionTest(opt):
#means the wf were created already, and we just dryRun it.
opt.dryRun=True
if opt.wmcontrol=='submit' and opt.nProcs==0:
print 'Not injecting to wmagent in -j 0 mode. Need to run the worklfows.'
print('Not injecting to wmagent in -j 0 mode. Need to run the worklfows.')
sys.exit(-1)
if opt.wmcontrol=='force':
print "This is an expert setting, you'd better know what you're doing"
print("This is an expert setting, you'd better know what you're doing")
opt.dryRun=True

def upload_to_couch_oneArg(arguments):
Expand Down Expand Up @@ -83,12 +84,12 @@ def __init__(self,opt,mode='init',options=''):


if not os.getenv('WMCORE_ROOT'):
print '\n\twmclient is not setup properly. Will not be able to upload or submit requests.\n'
print('\n\twmclient is not setup properly. Will not be able to upload or submit requests.\n')
if not self.testMode:
print '\n\t QUIT\n'
print('\n\t QUIT\n')
sys.exit(-18)
else:
print '\n\tFound wmclient\n'
print('\n\tFound wmclient\n')

self.defaultChain={
"RequestType" : "TaskChain", #this is how we handle relvals
Expand Down Expand Up @@ -250,13 +251,13 @@ def prepare(self,mReader, directories, mode='init'):
#import pprint
#pprint.pprint(wmsplit)
except:
print "Not set up for step splitting"
print("Not set up for step splitting")
wmsplit={}

acqEra=False
for (n,dir) in directories.items():
chainDict=copy.deepcopy(self.defaultChain)
print "inspecting",dir
print("inspecting",dir)
nextHasDSInput=None
for (x,s) in mReader.workFlowSteps.items():
#x has the format (num, prefix)
Expand Down Expand Up @@ -290,12 +291,12 @@ def prepare(self,mReader, directories, mode='init'):
try:
chainDict['nowmTasklist'][-1]['nowmIO']=json.loads(open('%s/%s.io'%(dir,step)).read())
except:
print "Failed to find",'%s/%s.io'%(dir,step),".The workflows were probably not run on cfg not created"
print("Failed to find",'%s/%s.io'%(dir,step),".The workflows were probably not run on cfg not created")
return -15

chainDict['nowmTasklist'][-1]['PrimaryDataset']='RelVal'+s[1].split('+')[0]
if not '--relval' in s[2][index]:
print 'Impossible to create task from scratch without splitting information with --relval'
print('Impossible to create task from scratch without splitting information with --relval')
return -12
else:
arg=s[2][index].split()
Expand All @@ -312,7 +313,7 @@ def prepare(self,mReader, directories, mode='init'):
try:
chainDict['nowmTasklist'][-1]['nowmIO']=json.loads(open('%s/%s.io'%(dir,step)).read())
except:
print "Failed to find",'%s/%s.io'%(dir,step),".The workflows were probably not run on cfg not created"
print("Failed to find",'%s/%s.io'%(dir,step),".The workflows were probably not run on cfg not created")
return -15
chainDict['nowmTasklist'][-1]['InputDataset']=nextHasDSInput.dataSet
if ('DQMHLTonRAWAOD' in step) :
Expand All @@ -330,7 +331,7 @@ def prepare(self,mReader, directories, mode='init'):
if '--data' in s[2][index] and nextHasDSInput.label:
thisLabel+='_RelVal_%s'%nextHasDSInput.label
if 'filter' in chainDict['nowmTasklist'][-1]['nowmIO']:
print "This has an input DS and a filter sequence: very likely to be the PyQuen sample"
print("This has an input DS and a filter sequence: very likely to be the PyQuen sample")
processStrPrefix='PU_'
setPrimaryDs = 'RelVal'+s[1].split('+')[0]
if setPrimaryDs:
Expand All @@ -342,7 +343,7 @@ def prepare(self,mReader, directories, mode='init'):
try:
chainDict['nowmTasklist'][-1]['nowmIO']=json.loads(open('%s/%s.io'%(dir,step)).read())
except:
print "Failed to find",'%s/%s.io'%(dir,step),".The workflows were probably not run on cfg not created"
print("Failed to find",'%s/%s.io'%(dir,step),".The workflows were probably not run on cfg not created")
return -15
if splitForThisWf:
chainDict['nowmTasklist'][-1]['LumisPerJob']=splitForThisWf
Expand Down Expand Up @@ -506,21 +507,21 @@ def uploadConf(self,filePath,label,where):
cacheName=filePath.split('/')[-1]
if self.testMode:
self.count+=1
print '\tFake upload of',filePath,'to couch with label',labelInCouch
print('\tFake upload of',filePath,'to couch with label',labelInCouch)
return self.count
else:
try:
from modules.wma import upload_to_couch,DATABASE_NAME
except:
print '\n\tUnable to find wmcontrol modules. Please include it in your python path\n'
print '\n\t QUIT\n'
print('\n\tUnable to find wmcontrol modules. Please include it in your python path\n')
print('\n\t QUIT\n')
sys.exit(-16)

if cacheName in self.couchCache:
print "Not re-uploading",filePath,"to",where,"for",label
print("Not re-uploading",filePath,"to",where,"for",label)
cacheId=self.couchCache[cacheName]
else:
print "Loading",filePath,"to",where,"for",label
print("Loading",filePath,"to",where,"for",label)
## totally fork the upload to couch to prevent cross loading of process configurations
pool = multiprocessing.Pool(1)
cacheIds = pool.map( upload_to_couch_oneArg, [(filePath,labelInCouch,self.user,self.group,where)] )
Expand All @@ -537,40 +538,40 @@ def upload(self):
str(n)+d[it]['TaskName'],
d['ConfigCacheUrl']
)
print d[it]['ConfigCacheID']," uploaded to couchDB for",str(n),"with ID",couchID
print(d[it]['ConfigCacheID']," uploaded to couchDB for",str(n),"with ID",couchID)
d[it]['ConfigCacheID']=couchID
if it =='DQMConfigCacheID':
couchID=self.uploadConf(d['DQMConfigCacheID'],
str(n)+'harvesting',
d['ConfigCacheUrl']
)
print d['DQMConfigCacheID'],"uploaded to couchDB for",str(n),"with ID",couchID
print(d['DQMConfigCacheID'],"uploaded to couchDB for",str(n),"with ID",couchID)
d['DQMConfigCacheID']=couchID


def submit(self):
try:
from modules.wma import makeRequest,approveRequest
from wmcontrol import random_sleep
print '\n\tFound wmcontrol\n'
print('\n\tFound wmcontrol\n')
except:
print '\n\tUnable to find wmcontrol modules. Please include it in your python path\n'
print('\n\tUnable to find wmcontrol modules. Please include it in your python path\n')
if not self.testMode:
print '\n\t QUIT\n'
print('\n\t QUIT\n')
sys.exit(-17)

import pprint
for (n,d) in self.chainDicts.items():
if self.testMode:
print "Only viewing request",n
print pprint.pprint(d)
print("Only viewing request",n)
print(pprint.pprint(d))
else:
#submit to wmagent each dict
print "For eyes before submitting",n
print pprint.pprint(d)
print "Submitting",n,"..........."
print("For eyes before submitting",n)
print(pprint.pprint(d))
print("Submitting",n,"...........")
workFlow=makeRequest(self.wmagent,d,encodeDict=True)
print "...........",n,"submitted"
print("...........",n,"submitted")
random_sleep()


Expand Down

0 comments on commit 9ecac21

Please sign in to comment.