Beispiel #1
0
## Retrieve parser args:
args = parser.parse_args( namespace = LoggerNamespace() )
mainLogger.debug("Raw input files are:")
if mainLogger.isEnabledFor( LoggingLevel.DEBUG ):
  pprint(args.inputFiles)
## Treat special arguments
if len( args.inputFiles ) == 1:
  args.inputFiles = csvStr2List( args.inputFiles[0] )
args.inputFiles = expandFolders( args.inputFiles )
mainLogger.verbose("All input files are:")
if mainLogger.isEnabledFor( LoggingLevel.VERBOSE ):
  pprint(args.inputFiles)
if args.binFilters is not NotSet:
  try:
    args.binFilters = str_to_class( "TuningTools.CrossValidStat", args.binFilters )
    args.binFilters = getFilters( args.binFilters, args.inputFiles, 
                                  printf = mainLogger.info )
  except TypeError:
    args.binFilters = csvStr2List( args.binFilters )
  args.inputFiles = select( args.inputFiles, args.binFilters ) 
  if len(args.binFilters) is 1:
    args.inputFiles = [args.inputFiles]
else:
  args.inputFiles = [args.inputFiles]
import re
searchFormat = re.compile(r'.*\.(tar.gz|tgz|pic)(\.[0-9]*)?$')

for idx, fileCollection in enumerate(args.inputFiles):
  m = searchFormat.match( fileCollection[0] )
  # Treat output file name:
 # Retrieve information:
 import ast, re
 replacer = re.compile("(\w+(\(.*?\))?)")
 args.ppCol = replacer.sub(r'"\1"', args.ppCol)
 ppCol = ast.literal_eval(args.ppCol)
 from RingerCore import traverse
 class_str_re = re.compile("(\w+)(\(.*?\))?")
 fix_args = re.compile("(\([^{}]+)((?<!,)\))")
 dict_args = re.compile("(\{.*\})")
 for str_, idx, parent, _, _ in traverse(ppCol):
   m = class_str_re.match(str_)
   if m:
     # The class representation in string:
     class_str = m.group(1)
     # Retrieve the class itself (must be from PreProc module)
     tClass = str_to_class( "TuningTools.PreProc", class_str)
     # Retrieve the arguments, if available
     class_attr = m.group(2)
     if class_attr:
       # Fix the arguments:
       m2 = fix_args.search( m.group(2) )
       if m2:
         class_attr = m2.expand(r'\1,\2')
         # Parse it:
         class_attr_parsed = ast.literal_eval( class_attr )
         # And create the instance
         inst = tClass( *class_attr_parsed )
       else:
         m3 = dict_args.search(str_)
         if m3:
           d = m3.group(1)
if args.tmpFolder:
  args.tmpFolder = expandPath( args.tmpFolder )
  mkdir_p( args.tmpFolder )
  import tempfile
  tempfile.tempdir = args.tmpFolder

if mainLogger.isEnabledFor( LoggingLevel.DEBUG ):
  import cProfile, pstats, StringIO
  pr = cProfile.Profile()
  pr.enable()

## Treat special arguments
# Check if binFilters is a class
if args.binFilters is not NotSet:
  try:
    args.binFilters = str_to_class( "TuningTools.CrossValidStat", args.binFilters )
  except (TypeError, AttributeError,):
    args.binFilters = csvStr2List( args.binFilters )

# Retrieve reference benchmark:
call_kw = {}
if args.refFile is not None:
  # If user has specified a reference performance file:
  mainLogger.info("Loading reference file...")
  effArchieve = BenchmarkEfficiencyArchieve.load(args.refFile, loadCrossEfficiencies = True)
  refBenchmarkCol = ReferenceBenchmarkCollection([])
  if args.operation is None:
    args.operation = effArchieve.operation
  from TuningTools.dataframe import RingerOperation
  refLabel = RingerOperation.tostring( args.operation )
  from TuningTools import getEfficiencyKeyAndLabel
 # Retrieve information:
 import ast, re
 replacer = re.compile("(\w+(\(.*?\))?)")
 args.ppCol = replacer.sub(r'"\1"', args.ppCol)
 ppCol = ast.literal_eval(args.ppCol)
 from RingerCore import traverse
 class_str_re = re.compile("(\w+)(\(.*?\))?")
 fix_args = re.compile("(\([^{}]+)((?<!,)\))")
 dict_args = re.compile("(\{.*\})")
 for str_, idx, parent, _, _ in traverse(ppCol):
     m = class_str_re.match(str_)
     if m:
         # The class representation in string:
         class_str = m.group(1)
         # Retrieve the class itself (must be from PreProc module)
         tClass = str_to_class("TuningTools.PreProc", class_str)
         # Retrieve the arguments, if available
         class_attr = m.group(2)
         if class_attr:
             # Fix the arguments:
             m2 = fix_args.search(m.group(2))
             if m2:
                 class_attr = m2.expand(r'\1,\2')
                 # Parse it:
                 class_attr_parsed = ast.literal_eval(class_attr)
                 # And create the instance
                 inst = tClass(*class_attr_parsed)
             else:
                 m3 = dict_args.search(str_)
                 if m3:
                     d = m3.group(1)