[mlpack-svn] r15771 - in mlpack/conf/jenkins-conf/benchmark: benchmark util

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Fri Sep 13 11:28:53 EDT 2013


Author: marcus
Date: Fri Sep 13 11:28:53 2013
New Revision: 15771

Log:
Handle error which occurs when a module isn't available.

Modified:
   mlpack/conf/jenkins-conf/benchmark/benchmark/make_reports.py
   mlpack/conf/jenkins-conf/benchmark/benchmark/memory_benchmark.py
   mlpack/conf/jenkins-conf/benchmark/benchmark/run_benchmark.py
   mlpack/conf/jenkins-conf/benchmark/util/graph.py
   mlpack/conf/jenkins-conf/benchmark/util/parser.py

Modified: mlpack/conf/jenkins-conf/benchmark/benchmark/make_reports.py
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/benchmark/make_reports.py	(original)
+++ mlpack/conf/jenkins-conf/benchmark/benchmark/make_reports.py	Fri Sep 13 11:28:53 2013
@@ -343,6 +343,8 @@
 
 '''
 Adjust the pagination for all index.html files.
+
+ at param maxFiles - The number of files to keep.
 '''
 def AdjustPagination(maxFiles):
   maxId, files = GetMaxIndex()
@@ -352,36 +354,40 @@
     maxId -= 1
 
   for i in range(1, files + 1):
-    with open("reports/index_" + str(i) + ".html", "r+") as fid:
-      content = fid.read()
-      pattern = '<ul class="pagination">'
-      pos = content.rfind(pattern)
-      content = content[:pos+len(pattern)]
-
-      if i == 1:
-        content += '<li class="previous"><a href="index.html">&larr; Newer</a></li>\n'
-      else:
-        content += '<li class="previous"><a href="index_' + str(i - 1) + '.html">&larr; Newer</a></li>\n'
-      
-      if i == maxId:
-        content += '<li class="next disabled"><a href="#">Older &rarr;</a></li>'
-      else:
-        content += '<li class="next"><a href="index_' + str(i + 1) + '.html">Older &rarr;</a></li>\n'
-
-      content += paginationTemplate
-      fid.seek(0)
-      fid.write(content)
-      fid.truncate()
-
-      # Delete unneeded files.
-      if i < maxFiles:
-        delFiles.extend(re.findall('src="img/(.*?)"', content))
-      else:
-        c = re.findall('src="img/(.*?)"', content)
-        delFiles = ["reports/img" + img for img in c if img not in delFiles]
-        delFiles.append("reports/index_" + str(i) + ".html")
-        fid.close()
-        RemoveDataset(delFiles)
+    try:
+      with open("reports/index_" + str(i) + ".html", "r+") as fid:
+        content = fid.read()
+        pattern = '<ul class="pagination">'
+        pos = content.rfind(pattern)
+        content = content[:pos+len(pattern)]
+
+        if i == 1:
+          content += '<li class="previous"><a href="index.html">&larr; Newer</a></li>\n'
+        else:
+          content += '<li class="previous"><a href="index_' + str(i - 1) + '.html">&larr; Newer</a></li>\n'
+        
+        if i == maxId:
+          content += '<li class="next disabled"><a href="#">Older &rarr;</a></li>'
+        else:
+          content += '<li class="next"><a href="index_' + str(i + 1) + '.html">Older &rarr;</a></li>\n'
+
+        content += paginationTemplate
+        fid.seek(0)
+        fid.write(content)
+        fid.truncate()
+
+        # Delete unneeded files.
+        if i < maxFiles:
+          delFiles.extend(re.findall('src="img/(.*?)"', content))
+        else:
+          c = re.findall('src="img/(.*?)"', content)
+          delFiles = ["reports/img" + img for img in c if img not in delFiles]
+          delFiles.append("reports/index_" + str(i) + ".html")
+          fid.close()
+          RemoveDataset(delFiles)
+    except IOError as e:
+      Log.Fatal("Exception: " + str(e))
+      return
 
 '''
 Get the pagination for the new index.html file.

Modified: mlpack/conf/jenkins-conf/benchmark/benchmark/memory_benchmark.py
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/benchmark/memory_benchmark.py	(original)
+++ mlpack/conf/jenkins-conf/benchmark/benchmark/memory_benchmark.py	Fri Sep 13 11:28:53 2013
@@ -66,6 +66,13 @@
 
   return (datasetList, modifiedList)
 
+'''
+Create the new memory report.
+
+ at param configfile - Create the reports with the given configuration file.
+ at param blocks - Run only the specified blocks.
+ at param log - If True save the reports otherwise use stdout and print the reports.
+'''
 def Main(configfile, blocks, log):
   # Benchmark settings.
   timeout = 23000

Modified: mlpack/conf/jenkins-conf/benchmark/benchmark/run_benchmark.py
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/benchmark/run_benchmark.py	(original)
+++ mlpack/conf/jenkins-conf/benchmark/benchmark/run_benchmark.py	Fri Sep 13 11:28:53 2013
@@ -80,7 +80,7 @@
 '''
 Count all datasets to determine the dataset size.
 
- at param libraries - Contains the Dataset List.
+ at param libraries - Contains the dataset list.
 @return Dataset count.
 '''
 def CountLibrariesDatasets(libraries):

Modified: mlpack/conf/jenkins-conf/benchmark/util/graph.py
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/util/graph.py	(original)
+++ mlpack/conf/jenkins-conf/benchmark/util/graph.py	Fri Sep 13 11:28:53 2013
@@ -15,6 +15,7 @@
   sys.path.insert(0, cmd_subfolder)
 
 from misc import *
+from log import *
 
 import numpy as np
 import matplotlib
@@ -303,8 +304,12 @@
     ax.spines['bottom'].set_linewidth(gridLineWidth)
 
     # Read the massif logfile.
-    with open(massiflogFile, "r") as fid:
-      content = fid.read()
+    try:
+      with open(massiflogFile, "r") as fid:
+        content = fid.read()
+    except IOError as e:
+      Log.Fatal("Exception: " + str(e))
+      return
 
     # Parse the massif logfile.
     memHeapB = [(int(i) / 1024) + 0.0001 for i in re.findall(r"mem_heap_B=(\d*)", content)]

Modified: mlpack/conf/jenkins-conf/benchmark/util/parser.py
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/util/parser.py	(original)
+++ mlpack/conf/jenkins-conf/benchmark/util/parser.py	Fri Sep 13 11:28:53 2013
@@ -177,10 +177,9 @@
   @param streamNum - The number of the stream.
   @return False
   '''
-  def CallableMethodErroMsg(self, methodName, methodScript, streamNum):
-    Log.Fatal("Stream number: " + str(streamNum) + " the method: " + methodName 
+  def CallableMethodWarnMsg(self, methodName, methodScript, streamNum):
+    Log.Warn("Stream number: " + str(streamNum) + " the method: " + methodName 
         + " in script: " + methodScript + " is not callable.")
-    return False
 
   '''
   Show a file not available error message.
@@ -207,7 +206,12 @@
     except IOError:
       return False
 
-    module = Loader.ImportModuleFromPath(methodScript)
+    try:
+      module = Loader.ImportModuleFromPath(methodScript)
+    except Exception as e:
+      Log.Warn("Exception: " + str(e))
+      return False
+
     methodClass = getattr(module, methodName, None)
     if callable(methodClass):
       if getattr(methodClass, "RunMethod", None):
@@ -291,7 +295,7 @@
                 return self.KeyErrorMsg("datasets", streamNum)
 
               if not self.CheckIfCallable(key, value["script"]):
-                return self.CallableMethodErroMsg(key, value["script"], streamNum)
+                self.CallableMethodWarnMsg(key, value["script"], streamNum)
 
           except AttributeError as e:
             return self.KeyErrorMsg("methods", streamNum)



More information about the mlpack-svn mailing list