casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables
regressframe.py
Go to the documentation of this file.
00001 #pipeline['null'] ={'fill':{}, 'flag':{}, 'calibrate':{}, 'image':{}, 'analysis':{}}
00002 #pipeline['fill']['name'] = ''
00003 #pipeline['fill']['args'] = []
00004 #pipeline['fill']['verify'] = ''
00005 #pipeline['fill']['data'] = ''
00006 
00007 #regression(pipeline)
00008 import time
00009 import os
00010 from tasks import *
00011 
00012 class regressionframe :
00013    steps = ['fill', 'flag', 'calibrate', 'image', 'analysis']
00014    title = "Regression test"
00015    datarepos = ''
00016    workdir = ''
00017    fill = {}
00018    flag = {}
00019    calibrate = {}
00020    image = {}
00021    analysis = {}
00022 
00023    def run(self, workdir='testing', verbose=True) :
00024       try :
00025          startdir = os.getcwd()
00026          os.mkdir(self.workdir)
00027          os.chdir(self.workdir)
00028          startTime = time.time()
00029          print self.title + ":" + workdir
00030          for mystep in self.steps :
00031             print "Processing step: " +mystep
00032             beenrun = {}
00033             for task in eval('self.'+mystep+"['tasks']") :
00034                     beenrun[task] = 0
00035             for task in eval('self.'+mystep+"['tasks']") :
00036                #print "   "+ eval('self.'+mystep+"['"+task+"']")
00037                mycommand = "self."+mystep+"['"+task+"']"
00038                the_args = eval(mycommand)
00039                arg_list = ''
00040                thecommand=task+'('
00041                if(the_args.has_key('args')) :
00042                        argscount = len(the_args['args'].keys())
00043                        argcount = 0
00044                        comma = ', '
00045                        for key in the_args['args'] :
00046                                argcount = argcount+1
00047                                if(argcount == argscount):
00048                                   comma = ''
00049                                quoteit = ''
00050                                if type(the_args['args'][key]) == str :
00051                                        quoteit = "'"
00052                                arg_list=arg_list+key+'='+quoteit+str(the_args['args'][key])+quoteit+comma
00053                        thecommand=thecommand+arg_list
00054                elif(len(the_args.keys())>1) :
00055                        count = beenrun[task]
00056                        argscount = len(the_args[count]['args'].keys())
00057                        argcount = 0
00058                        comma = ', '
00059                        for key in the_args[count]['args'] :
00060                                argcount = argcount+1
00061                                if(argcount == argscount):
00062                                   comma = ''
00063                                quoteit = ''
00064                                if type(the_args[count]['args'][key]) == str :
00065                                        quoteit = "'"
00066                                arg_list=arg_list+key+'='+quoteit+str(the_args[count]['args'][key])+quoteit+comma
00067                        thecommand=thecommand+arg_list
00068                        beenrun[task] = beenrun[task]+1
00069                        
00070                thecommand=thecommand+')'
00071                beginTime = time.time()
00072                if verbose :
00073                   print thecommand
00074                eval(thecommand)
00075                endTime = time.time()
00076                print "   " + task+': Time to complete was '+str(endTime-beginTime)
00077             if (eval("self."+mystep+".has_key('verify')")) :
00078                 verified = eval('self.'+mystep+"['verify']()")
00079                 if not verified :
00080                    print mystep + " has failed verification."
00081                    os.chdir(startdir)
00082                    return False
00083                 else :
00084                    print '   '+mystep+' verified'
00085          endTime = time.time()
00086          print 'Total time was: '+str(endTime-startTime)
00087          os.chdir(startdir)
00088          return True
00089       except Exception, instance:
00090          print "***Oops exception*** ",instance
00091          os.chdir(startdir)
00092          return False