[mlpack-svn] r15560 - in mlpack/conf/jenkins-conf/benchmark/methods: mlpack weka

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Fri Jul 26 09:24:55 EDT 2013


Author: marcus
Date: Fri Jul 26 09:24:54 2013
New Revision: 15560

Log:
Fix 0 seconds timeout and indentations.

Modified:
   mlpack/conf/jenkins-conf/benchmark/methods/mlpack/hmm_train.py
   mlpack/conf/jenkins-conf/benchmark/methods/weka/allknn.py
   mlpack/conf/jenkins-conf/benchmark/methods/weka/linear_regression.py

Modified: mlpack/conf/jenkins-conf/benchmark/methods/mlpack/hmm_train.py
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/methods/mlpack/hmm_train.py	(original)
+++ mlpack/conf/jenkins-conf/benchmark/methods/mlpack/hmm_train.py	Fri Jul 26 09:24:54 2013
@@ -42,7 +42,7 @@
     self.verbose = verbose
     self.dataset = dataset
     self.path = path
-    self.timeout = 0
+    self.timeout = timeout
 
     # Get description from executable.
     cmd = shlex.split(self.path + "hmm_train -h")

Modified: mlpack/conf/jenkins-conf/benchmark/methods/weka/allknn.py
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/methods/weka/allknn.py	(original)
+++ mlpack/conf/jenkins-conf/benchmark/methods/weka/allknn.py	Fri Jul 26 09:24:54 2013
@@ -12,9 +12,9 @@
 # Import the util path, this method even works if the path contains symlinks to
 # modules.
 cmd_subfolder = os.path.realpath(os.path.abspath(os.path.join(
-	os.path.split(inspect.getfile(inspect.currentframe()))[0], "../../util")))
+  os.path.split(inspect.getfile(inspect.currentframe()))[0], "../../util")))
 if cmd_subfolder not in sys.path:
-	sys.path.insert(0, cmd_subfolder)
+  sys.path.insert(0, cmd_subfolder)
 
 from log import *
 from profiler import *
@@ -29,96 +29,96 @@
 '''
 class ALLKNN(object):
 
-	''' 
-	Create the All K-Nearest-Neighbors benchmark instance.
+  ''' 
+  Create the All K-Nearest-Neighbors benchmark instance.
   
   @param dataset - Input dataset to perform ALLKNN on.
   @param timeout - The time until the timeout. Default no timeout.
   @param path - Path to the mlpack executable.
   @param verbose - Display informational messages.
-	'''
-	def __init__(self, dataset, timeout=0, path=os.environ["WEKA_CLASSPATH"], 
-			verbose = True):
-		self.verbose = verbose
-		self.dataset = dataset
-		self.path = path
-		self.timeout = timeout
-		
-	'''
+  '''
+  def __init__(self, dataset, timeout=0, path=os.environ["WEKA_CLASSPATH"], 
+      verbose = True):
+    self.verbose = verbose
+    self.dataset = dataset
+    self.path = path
+    self.timeout = timeout
+    
+  '''
   All K-Nearest-Neighbors. If the method has been successfully completed return 
   the elapsed time in seconds.
 
   @param options - Extra options for the method.
   @return - Elapsed time in seconds or -1 if the method was not successful.
   '''
-	def RunMethod(self, options):
-		Log.Info("Perform ALLKNN.", self.verbose)
+  def RunMethod(self, options):
+    Log.Info("Perform ALLKNN.", self.verbose)
 
-		# If the dataset contains two files then the second file is the query file.
-		# In this case we add this to the command line.
-		if len(self.dataset) == 2:
-			inputCmd = "-r " + self.dataset[0] + " -q " + self.dataset[1] + " " + options
-		else:
-			inputCmd = "-r " + self.dataset + " " + options
-		
-		# Split the command using shell-like syntax.
-		cmd = shlex.split("java -classpath " + self.path + ":methods/weka" + 
-			" AllKnn " + inputCmd + " " + options)
-		
-		# Run command with the nessecary arguments and return its output as a byte
-		# string. We have untrusted input so we disables all shell based features.
-		try:
-			s = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=False, 
-					timeout=self.timeout)
-		except subprocess.TimeoutExpired as e:
+    # If the dataset contains two files then the second file is the query file.
+    # In this case we add this to the command line.
+    if len(self.dataset) == 2:
+      inputCmd = "-r " + self.dataset[0] + " -q " + self.dataset[1] + " " + options
+    else:
+      inputCmd = "-r " + self.dataset + " " + options
+    
+    # Split the command using shell-like syntax.
+    cmd = shlex.split("java -classpath " + self.path + ":methods/weka" + 
+      " AllKnn " + inputCmd + " " + options)
+    
+    # Run command with the nessecary arguments and return its output as a byte
+    # string. We have untrusted input so we disables all shell based features.
+    try:
+      s = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=False, 
+          timeout=self.timeout)
+    except subprocess.TimeoutExpired as e:
       Log.Warn(str(e))
       return -2
-		except Exception:
-			Log.Fatal("Could not execute command: " + str(cmd))
-			return -1
-			
-		# Return the elapsed time.
-		timer = self.parseTimer(s)
-		if not timer:
-			Log.Fatal("Can't parse the timer")
-			return -1
-		else:
-			time = self.GetTime(timer)
-			Log.Info(("total time: %fs" % time), self.verbose)
-
-			return time
-
-	'''
-	Parse the timer data form a given string.
-
-	@param data - String to parse timer data from.
-	@return - Namedtuple that contains the timer data.
-	'''
-	def parseTimer(self, data):
-		# Compile the regular expression pattern into a regular expression object to
-		# parse the timer data.
-		pattern = re.compile(r"""
-				.*?total_time: (?P<total_time>.*?)s.*?
-				""", re.VERBOSE|re.MULTILINE|re.DOTALL)
-		
-		match = pattern.match(data.decode())
-		if not match:
-			Log.Fatal("Can't parse the data: wrong format")
-			return -1
-		else:
-			# Create a namedtuple and return the timer data.
-			timer = collections.namedtuple("timer", ["total_time"])
-			
-			if match.group("total_time").count(".") == 1:
-				return timer(float(match.group("total_time")))
-			else:
-				return timer(float(match.group("total_time").replace(",", ".")))
-
-	'''
-	Return the elapsed time in seconds.
-
-	@param timer - Namedtuple that contains the timer data.
-	@return Elapsed time in seconds.
-	'''
-	def GetTime(self, timer):
-		return timer.total_time
+    except Exception:
+      Log.Fatal("Could not execute command: " + str(cmd))
+      return -1
+      
+    # Return the elapsed time.
+    timer = self.parseTimer(s)
+    if not timer:
+      Log.Fatal("Can't parse the timer")
+      return -1
+    else:
+      time = self.GetTime(timer)
+      Log.Info(("total time: %fs" % time), self.verbose)
+
+      return time
+
+  '''
+  Parse the timer data form a given string.
+
+  @param data - String to parse timer data from.
+  @return - Namedtuple that contains the timer data.
+  '''
+  def parseTimer(self, data):
+    # Compile the regular expression pattern into a regular expression object to
+    # parse the timer data.
+    pattern = re.compile(r"""
+        .*?total_time: (?P<total_time>.*?)s.*?
+        """, re.VERBOSE|re.MULTILINE|re.DOTALL)
+    
+    match = pattern.match(data.decode())
+    if not match:
+      Log.Fatal("Can't parse the data: wrong format")
+      return -1
+    else:
+      # Create a namedtuple and return the timer data.
+      timer = collections.namedtuple("timer", ["total_time"])
+      
+      if match.group("total_time").count(".") == 1:
+        return timer(float(match.group("total_time")))
+      else:
+        return timer(float(match.group("total_time").replace(",", ".")))
+
+  '''
+  Return the elapsed time in seconds.
+
+  @param timer - Namedtuple that contains the timer data.
+  @return Elapsed time in seconds.
+  '''
+  def GetTime(self, timer):
+    return timer.total_time

Modified: mlpack/conf/jenkins-conf/benchmark/methods/weka/linear_regression.py
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/methods/weka/linear_regression.py	(original)
+++ mlpack/conf/jenkins-conf/benchmark/methods/weka/linear_regression.py	Fri Jul 26 09:24:54 2013
@@ -12,9 +12,9 @@
 # Import the util path, this method even works if the path contains symlinks to
 # modules.
 cmd_subfolder = os.path.realpath(os.path.abspath(os.path.join(
-	os.path.split(inspect.getfile(inspect.currentframe()))[0], "../../util")))
+  os.path.split(inspect.getfile(inspect.currentframe()))[0], "../../util")))
 if cmd_subfolder not in sys.path:
-	sys.path.insert(0, cmd_subfolder)
+  sys.path.insert(0, cmd_subfolder)
 
 from log import *
 from profiler import *
@@ -29,96 +29,96 @@
 '''
 class LinearRegression(object):
 
-	''' 
-	Create the Linear Regression benchmark instance.
+  ''' 
+  Create the Linear Regression benchmark instance.
   
   @param dataset - Input dataset to perform Linear Regression on.
   @param timeout - The time until the timeout. Default no timeout.
   @param path - Path to the mlpack executable.
   @param verbose - Display informational messages.
-	'''
-	def __init__(self, dataset, timeout=0, path=os.environ["WEKA_CLASSPATH"], 
-			verbose=True): 
-		self.verbose = verbose
-		self.dataset = dataset
-		self.path = path
-		self.timeout = timeout
-		
-	'''
+  '''
+  def __init__(self, dataset, timeout=0, path=os.environ["WEKA_CLASSPATH"], 
+      verbose=True): 
+    self.verbose = verbose
+    self.dataset = dataset
+    self.path = path
+    self.timeout = timeout
+    
+  '''
   Linear Regression. If the method has been successfully completed return 
   the elapsed time in seconds.
 
   @param options - Extra options for the method.
   @return - Elapsed time in seconds or -1 if the method was not successful.
   '''
-	def RunMethod(self, options):
-		Log.Info("Perform Linear Regression.", self.verbose)
+  def RunMethod(self, options):
+    Log.Info("Perform Linear Regression.", self.verbose)
 
-		# Load input dataset.
+    # Load input dataset.
     # If the dataset contains two files then the second file is the responses
     # file. In this case we add this to the command line.
-		if len(self.dataset) == 2:
-			cmd = shlex.split("java -classpath " + self.path + ":methods/weka" + 
-				" LinearRegression -i " + self.dataset[0] + " -r " + self.dataset[1] 
-				+ " " + options)
-		else:
-			cmd = shlex.split("java -classpath " + self.path + ":methods/weka" + 
-				" LinearRegression -i " + self.dataset + " " + options)
-
-		# Run command with the nessecary arguments and return its output as a byte
-		# string. We have untrusted input so we disables all shell based features.
-		try:
-			s = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=False, 
-					timeout=self.timeout)
-		except subprocess.TimeoutExpired as e:
+    if len(self.dataset) == 2:
+      cmd = shlex.split("java -classpath " + self.path + ":methods/weka" + 
+        " LinearRegression -i " + self.dataset[0] + " -r " + self.dataset[1] 
+        + " " + options)
+    else:
+      cmd = shlex.split("java -classpath " + self.path + ":methods/weka" + 
+        " LinearRegression -i " + self.dataset + " " + options)
+
+    # Run command with the nessecary arguments and return its output as a byte
+    # string. We have untrusted input so we disables all shell based features.
+    try:
+      s = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=False, 
+        timeout=self.timeout)
+    except subprocess.TimeoutExpired as e:
       Log.Warn(str(e))
       return -2
-		except Exception:
-			Log.Fatal("Could not execute command: " + str(cmd))
-			return -1
-
-		# Return the elapsed time.
-		timer = self.parseTimer(s)
-		if not timer:
-			Log.Fatal("Can't parse the timer")
-			return -1
-		else:
-			time = self.GetTime(timer)
-			Log.Info(("total time: %fs" % time), self.verbose)
-
-			return time
-
-	'''
-	Parse the timer data form a given string.
-
-	@param data - String to parse timer data from.
-	@return - Namedtuple that contains the timer data.
-	'''
-	def parseTimer(self, data):
-		# Compile the regular expression pattern into a regular expression object to
-		# parse the timer data.
-		pattern = re.compile(r"""
-				.*?total_time: (?P<total_time>.*?)s.*?
-				""", re.VERBOSE|re.MULTILINE|re.DOTALL)
-		
-		match = pattern.match(data.decode())
-		if not match:
-			Log.Fatal("Can't parse the data: wrong format")
-			return -1
-		else:
-			# Create a namedtuple and return the timer data.
-			timer = collections.namedtuple("timer", ["total_time"])
-			
-			if match.group("total_time").count(".") == 1:
-				return timer(float(match.group("total_time")))
-			else:
-				return timer(float(match.group("total_time").replace(",", ".")))
-
-	'''
-	Return the elapsed time in seconds.
-
-	@param timer - Namedtuple that contains the timer data.
-	@return Elapsed time in seconds.
-	'''
-	def GetTime(self, timer):
-		return timer.total_time
+    except Exception:
+      Log.Fatal("Could not execute command: " + str(cmd))
+      return -1
+
+    # Return the elapsed time.
+    timer = self.parseTimer(s)
+    if not timer:
+      Log.Fatal("Can't parse the timer")
+      return -1
+    else:
+      time = self.GetTime(timer)
+      Log.Info(("total time: %fs" % time), self.verbose)
+
+      return time
+
+  '''
+  Parse the timer data form a given string.
+
+  @param data - String to parse timer data from.
+  @return - Namedtuple that contains the timer data.
+  '''
+  def parseTimer(self, data):
+    # Compile the regular expression pattern into a regular expression object to
+    # parse the timer data.
+    pattern = re.compile(r"""
+        .*?total_time: (?P<total_time>.*?)s.*?
+        """, re.VERBOSE|re.MULTILINE|re.DOTALL)
+    
+    match = pattern.match(data.decode())
+    if not match:
+      Log.Fatal("Can't parse the data: wrong format")
+      return -1
+    else:
+      # Create a namedtuple and return the timer data.
+      timer = collections.namedtuple("timer", ["total_time"])
+      
+      if match.group("total_time").count(".") == 1:
+        return timer(float(match.group("total_time")))
+      else:
+        return timer(float(match.group("total_time").replace(",", ".")))
+
+  '''
+  Return the elapsed time in seconds.
+
+  @param timer - Namedtuple that contains the timer data.
+  @return Elapsed time in seconds.
+  '''
+  def GetTime(self, timer):
+    return timer.total_time



More information about the mlpack-svn mailing list