[mlpack-svn] r15643 - mlpack/conf/jenkins-conf/benchmark/util
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Wed Aug 21 08:32:09 EDT 2013
Author: marcus
Date: Wed Aug 21 08:32:09 2013
New Revision: 15643
Log:
Clean and add comments.
Modified:
mlpack/conf/jenkins-conf/benchmark/util/database.py
mlpack/conf/jenkins-conf/benchmark/util/loader.py
mlpack/conf/jenkins-conf/benchmark/util/log.py
mlpack/conf/jenkins-conf/benchmark/util/misc.py
mlpack/conf/jenkins-conf/benchmark/util/parser.py
mlpack/conf/jenkins-conf/benchmark/util/profiler.py
mlpack/conf/jenkins-conf/benchmark/util/system.py
mlpack/conf/jenkins-conf/benchmark/util/timer.py
Modified: mlpack/conf/jenkins-conf/benchmark/util/database.py
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/util/database.py (original)
+++ mlpack/conf/jenkins-conf/benchmark/util/database.py Wed Aug 21 08:32:09 2013
@@ -322,7 +322,7 @@
with self.con:
self.cur.execute("SELECT * FROM results JOIN datasets ON" +
" results.dataset_id = datasets.id WHERE build_id=" + str(buildId) +
- " AND method_id=" + str(methodId) + " ORDER BY datasets.name")
+ " AND method_id=" + str(methodId) + " ORDER BY datasets.name")
return self.cur.fetchall()
'''
Modified: mlpack/conf/jenkins-conf/benchmark/util/loader.py
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/util/loader.py (original)
+++ mlpack/conf/jenkins-conf/benchmark/util/loader.py Wed Aug 21 08:32:09 2013
@@ -8,10 +8,14 @@
import imp
import os
-
+'''
+This class contains a function to import modules and scripts.
+'''
class Loader(object):
- # Import a module from a path.
+ '''
+ Import a module from a path.
+ '''
@staticmethod
def ImportModuleFromPath(path):
Modified: mlpack/conf/jenkins-conf/benchmark/util/log.py
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/util/log.py (original)
+++ mlpack/conf/jenkins-conf/benchmark/util/log.py Wed Aug 21 08:32:09 2013
@@ -9,7 +9,9 @@
import re
import sys
-
+'''
+This class contains functions to unify the console output.
+'''
class Log(object):
# Color code escape sequences -- but not on Windows.
@@ -26,42 +28,80 @@
BASH_CYAN = '\033[0;36m'
BASH_CLEAR = '\033[0m'
- #! Prints debug output with the appropriate tag: [DEBUG].
+ '''
+ Prints debug output with the appropriate tag: [DEBUG].
+
+ @param line - The line to print to the console.
+ @verbose - Display informational messages.
+ '''
@staticmethod
def Debug(line, verbose=True):
if verbose:
- print(Log.BASH_CYAN + '[DEBUG] ' + Log.BASH_CLEAR + Log.WrapLine(line), file=sys.stdout)
+ print(Log.BASH_CYAN + '[DEBUG] ' + Log.BASH_CLEAR + Log.WrapLine(line),
+ file=sys.stdout)
- #! Prints informational messages prefixed with [INFO ].
+ '''
+ Prints informational messages prefixed with [INFO ].
+
+ @param line - The line to print to the console.
+ @verbose - Display informational messages.
+ '''
@staticmethod
def Info(line, verbose=True):
if verbose:
- print(Log.BASH_GREEN + '[INFO ] ' + Log.BASH_CLEAR + Log.WrapLine(line), file=sys.stdout)
+ print(Log.BASH_GREEN + '[INFO ] ' + Log.BASH_CLEAR + Log.WrapLine(line),
+ file=sys.stdout)
+
+ '''
+ Prints warning messages prefixed with [WARN ].
- #! Prints warning messages prefixed with [WARN ].
+ @param line - The line to print to the console.
+ @verbose - Display informational messages.
+ '''
@staticmethod
def Warn(line, verbose=True):
if verbose:
- print(Log.BASH_YELLOW + '[WARN ] ' + Log.BASH_CLEAR + Log.WrapLine(line), file=sys.stdout)
+ print(Log.BASH_YELLOW + '[WARN ] ' + Log.BASH_CLEAR + Log.WrapLine(line),
+ file=sys.stdout)
- #! Prints fatal messages prefixed with [FATAL].
+ '''
+ Prints fatal messages prefixed with [FATAL].
+
+ @param line - The line to print to the console.
+ @verbose - Display informational messages.
+ '''
@staticmethod
def Fatal(line, verbose=True):
if verbose:
- print(Log.BASH_RED + '[FATAL] ' + Log.BASH_CLEAR + Log.WrapLine(line), file=sys.stdout)
+ print(Log.BASH_RED + '[FATAL] ' + Log.BASH_CLEAR + Log.WrapLine(line),
+ file=sys.stdout)
+
+ '''
+ Prints messages without any prefixed.
- #! Prints messages without any prefixed.
+ @param line - The line to print to the console.
+ @verbose - Display informational messages.
+ '''
@staticmethod
def Notice(line, verbose=True):
if verbose:
print(Log.WrapLine(line), file=sys.stdout)
- # Truncate the String into lines of 80 characters.
+ '''
+ Truncate the String into lines of 80 characters.
+
+ @param line - The line to wrap.
+ '''
@staticmethod
def WrapLine(line):
- return '\n'.join(line.strip() for line in re.findall(r'.{1,80}(?:\s+|$)', line))
+ return '\n'.join(line.strip() for line in re.findall(r'.{1,80}(?:\s+|$)',
+ line))
+
+ '''
+ Prints out a table of data.
- #! Prints out a table of data.
+ @param table - A list of a list that contains the table values.
+ '''
@staticmethod
def PrintTable(table):
Modified: mlpack/conf/jenkins-conf/benchmark/util/misc.py
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/util/misc.py (original)
+++ mlpack/conf/jenkins-conf/benchmark/util/misc.py Wed Aug 21 08:32:09 2013
@@ -11,7 +11,7 @@
This function determinate if the given number is a float.
@param n - Number to test.
- at return If the number a float returns True otherwise the function returns False.
+ at return If the number is a float return True otherwise return False.
'''
def isFloat(n):
try:
@@ -23,6 +23,9 @@
'''
Function to seach the minimum scalar in a list.
+
+ at param data - A list that contains the values.
+ at return The minimum scalar of the given list.
'''
def minData(data):
minData = float('Inf')
@@ -138,7 +141,7 @@
@param dataset - Datsets which should be checked.
@param formats - List of supported file formats.
- at return Orginal dataset or dataset with new file format.
+ at return Orginal dataset or dataset with the new file format.
'''
def CheckFileExtension(dataset, formats):
dataExtension = os.path.splitext(dataset)[1][1:]
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 Wed Aug 21 08:32:09 2013
@@ -83,9 +83,10 @@
return attr(libraryName, stream["methods"].items())
'''
- This method return the attributes of a given method.
+ This method returns the attributes of a given method.
- @param methods - Contains the methods attributes.
+ @param methods - Contains the method attributes.
+ @return A tuble that contains the method attributes.
'''
def GetConfigMethod(self, methods):
try:
@@ -145,22 +146,10 @@
return attr(methodName, script, format, datasets, run, iteration)
'''
- Show a key error message.
-
- @return False
- '''
- def ConfigKeyErrorMsg(self, key, streamNum = 0):
- if streamNum == 0:
- Log.Fatal("No [" + key + "] key.")
- else:
- Log.Fatal("Stream number: " + str(streamNum) + " has no [" + key +
- "] key.")
-
- return False
-
- '''
Show a emtpy value error message.
+ @param key - The name of the key.
+ @param streamNum - The number of the stream.
@return False
'''
def EmptyErrorMsg(self, key, streamNum):
@@ -170,6 +159,8 @@
'''
Show a value is not set warn message.
+ @param key - The name of the key.
+ @param streamNum - The number of the stream.
'''
def KeyWarnMsg(self, key, streamNum = 0):
if streamNum == 0:
@@ -181,6 +172,9 @@
'''
Show a method is not callable error message.
+ @param methodName - The name of the method.
+ @param methodScript - The path of the script.
+ @param streamNum - The number of the stream.
@return False
'''
def CallableMethodErroMsg(self, methodName, methodScript, streamNum):
@@ -191,7 +185,8 @@
'''
Show a file not available error message.
- @ return False
+ @param fileName - The name of the file.
+ @return False
'''
def NotAvailableErrorMsg(self, fileName):
Log.Fatal("The file: " + fileName + " is not available.")
@@ -223,6 +218,7 @@
'''
This function checks if a file is readable.
+ @param files - A list of files to check.
@return The function returns True if the file is readable otherwise false.
'''
def CheckIfAvailable(self, files):
Modified: mlpack/conf/jenkins-conf/benchmark/util/profiler.py
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/util/profiler.py (original)
+++ mlpack/conf/jenkins-conf/benchmark/util/profiler.py Wed Aug 21 08:32:09 2013
@@ -35,7 +35,8 @@
successful save the report file in the specified file.
'''
@staticmethod
- def MassifMemoryUsage(command, output, timeout, options, valgrind=os.environ["VALGRIND_BIN"]):
+ def MassifMemoryUsage(command, output, timeout, options,
+ valgrind=os.environ["VALGRIND_BIN"]):
import shlex, subprocess
cmd = shlex.split(("%s --tool=massif --massif-out-file=%s %s ") %
Modified: mlpack/conf/jenkins-conf/benchmark/util/system.py
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/util/system.py (original)
+++ mlpack/conf/jenkins-conf/benchmark/util/system.py Wed Aug 21 08:32:09 2013
@@ -24,10 +24,14 @@
import shlex
import subprocess
-
+'''
+This class implements functions the get system informations.
+'''
class SystemInfo(object):
- # Returns the available memory of this machine.
+ '''
+ Returns the available memory of this machine.
+ '''
@staticmethod
def GetMemory():
if sys.platform.startswith('posix') or sys.platform.startswith('linux'):
@@ -39,19 +43,23 @@
elif sys.platform.startswith('darwin'):
cmd = shlex.split("sysctl -n hw.memsize")
- mem = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=False).strip()
+ mem = subprocess.check_output(cmd, stderr=subprocess.STDOUT,
+ shell=False).strip()
return str(float(mem) / 1024 / 1024 / 1000.0) + ' GB'
else:
return 'N/A'
- # Returns the CPU model name of this machine.
+ '''
+ Returns the CPU model name of this machine.
+ '''
@staticmethod
def GetCPUModel():
if sys.platform.startswith('posix') or sys.platform.startswith('linux'):
cmd = 'cat /proc/cpuinfo'
- s = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).strip()
+ s = subprocess.check_output(cmd, stderr=subprocess.STDOUT,
+ shell=True).strip()
for line in s.decode().split("\n"):
if "model name" in line:
modelName = re.sub( ".*model name.*:", "", line, 1)
@@ -63,7 +71,8 @@
elif sys.platform.startswith('darwin'):
cmd = shlex.split("sysctl -n machdep.cpu.brand_string")
- modelName = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=False).strip()
+ modelName = subprocess.check_output(cmd, stderr=subprocess.STDOUT,
+ shell=False).strip()
return modelName
elif sys.platform.startswith('win'):
@@ -74,7 +83,9 @@
Log.Fatal('Could not get the OS name')
return 'N/A'
- # Returns the distribution name of this machine.
+ '''
+ Returns the distribution name of this machine.
+ '''
@staticmethod
def GetDistribution():
if sys.platform.startswith('posix') or sys.platform.startswith('linux'):
@@ -109,7 +120,9 @@
Log.Fatal('Could not get the OS name')
return 'N/A'
- # Returns the CPU core count of this machine.
+ '''
+ Returns the CPU core count of this machine.
+ '''
@staticmethod
def GetCPUCores():
# Python 2.6+ use multiprocessing module.
@@ -135,7 +148,9 @@
Log.Fatal('Could not specify the OS name')
return 'N/A'
- # Returns the plattform of this machine (e.g. x86_64).
+ '''
+ Returns the plattform of this machine (e.g. x86_64).
+ '''
@staticmethod
def GetPlatform():
return platform.machine()
Modified: mlpack/conf/jenkins-conf/benchmark/util/timer.py
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/util/timer.py (original)
+++ mlpack/conf/jenkins-conf/benchmark/util/timer.py Wed Aug 21 08:32:09 2013
@@ -35,7 +35,7 @@
return self.__finish - self.__start
'''
-This Class provides a Timout Error.
+This Class provides a timeout error.
'''
class TimeoutError(Exception):
errno = 23
More information about the mlpack-svn
mailing list